/v1/routing/optimized Pass up to 25 waypoints and get back the optimal visit order - minimising total travel time across the real road network, not straight-line distance.
Solves the travelling salesman problem with real-world road constraints: one-way streets, turn restrictions, vehicle profiles, and time windows. Returns the reordered waypoint sequence, full route geometry, and leg-by-leg durations and distances - ready to pass to your fleet or driver app.
25
Max waypoints
<800ms
P95 latency
$1.00
Per 1k requests
# Optimise a 5-stop delivery run
curl -X POST "https://api.farun.io/v1/routing/optimized" \
-H "X-RapidAPI-Key: YOUR_KEY" \
-H "X-RapidAPI-Host: farun-maps.p.rapidapi.com" \
-H "Content-Type: application/json" \
-d '{
"origin":[77.2090, 28.6139],
"destination":[77.2090, 28.6139],
"waypoints": [[77.1025, 28.7041],[77.2311, 28.5355],[77.0688, 28.6692],
[77.3910, 28.5245],
[77.1734, 28.6867]
],
"profile": "driving",
"return_geometry": true
}' Returns
Ordered waypoints + geometry
Profiles
driving · truck · bicycle
Max stops
25 waypoints
The problem it solves
With 10 stops there are 3.6 million possible orderings. A driver choosing manually or a system using straight-line distance will rarely find the shortest-time route. The Optimized Route API solves it against real road data in under a second.
Without optimisation
Drivers sequence stops by gut feel or nearest-neighbour on a map. One-way streets, turn restrictions, and traffic patterns mean the obvious order is rarely the fastest. Extra kilometres compound across every vehicle in a fleet, every day.
What the API does
Farun's optimisation engine runs a constrained vehicle routing algorithm against the full road graph including one-way streets, turn restrictions, and vehicle-specific road access to find the minimum total-time visit order.
What you get back
The response includes the optimised waypoint sequence, each leg's duration and distance, the full GeoJSON route geometry, and the total trip time. Pass it directly to a navigation device or driver app with no further processing.
Who uses it
Route optimisation pays back immediately in reduced fuel cost, fewer driver hours, and higher delivery density. The API is priced per-request so it makes sense to optimise on every dispatch event not just for bulk planning runs.
Last-Mile Delivery
Optimise each driver's stop sequence at the start of every shift. Pass the depot as origin and destination, the day's delivery addresses as waypoints, and the profile as 'driving' or 'truck'. The response sequences stops to minimise total drive time.
Field Service
Sequence site visits for maintenance crews, meter readers, and field engineers to minimise drive time between jobs. Combine with time_window constraints to respect appointment slots while still finding the best overall ordering.
Agriculture & Land
Coordinate inspection runs, equipment deliveries, and harvest logistics across multiple landholdings. The truck profile respects weight and height restrictions on rural roads that car-profile routing would ignore.
Healthcare & Emergency
Sequence home visits for district nurses, care workers, and sample collection crews. Time-window constraints ensure patients with fixed appointment windows are visited in the right slot while the overall run is minimised.
Waste & Utilities
Sequence refuse, recycling, and utility meter collection runs across dense urban areas. The truck profile handles road access rules for large vehicles. Combine with return_to_origin: true for circular depot runs.
SaaS & Platforms
Add a 'Optimise route' button to any logistics SaaS product. Send the user's stop list to this endpoint and render the reordered sequence and the full GeoJSON geometry back onto a Farun vector tile map in the same flow.
Response shape
The response gives you everything needed to hand off to a driver app or navigation device, the reordered stop list, the full route as a GeoJSON LineString, and per-leg breakdowns for ETA calculation and progress tracking.
waypoints_ordered The input waypoints resequenced into the optimal visit order legs Array of leg objects - each with duration (s), distance (m), and GeoJSON geometry total_duration Total trip time in seconds across all legs total_distance Total distance in metres geometry Full GeoJSON LineString for the complete optimised route savings Time saved (seconds) vs the input waypoint order - useful for showing optimisation value in a UI {
"waypoints_ordered": [
{ "index": 0, "coordinates": [77.1025, 28.7041] },
{ "index": 3, "coordinates": [77.0688, 28.6692] },
// ... reordered stops
],
"total_duration": 5820, // seconds
"total_distance": 68400, // metres
"savings": 1140, // 19 min saved vs input order
"legs": [
{
"duration": 840,
"distance": 9200,
"geometry": { "type": "LineString", "coordinates": [...] }
}
// one leg per stop transition
],
"geometry": {
"type": "LineString",
"coordinates": [...] // full route
}
} Endpoint reference
https://api.farun.io/v1/routing/optimized Request body - JSON
origin req waypoints req destination profile return_geometry time_windows approach overview Response codes
200 application/json Optimised route with ordered waypoints, legs, and geometry. 400 Bad request Missing required fields, fewer than 2 waypoints, or invalid coordinates. 401 Unauthorized Missing or invalid RapidAPI key. 422 Unroutable No feasible route found between the given waypoints - check that all coordinates are on a routable road. 429 Rate limited Request rate exceeds your plan. Upgrade on RapidAPI. Integration example
async function optimiseRun(
depot: [number, number],
stops: [number, number][]
) {
const res = await fetch(
'https://api.farun.io/v1/routing/optimized',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-RapidAPI-Key': process.env.RAPIDAPI_KEY,
},
body: JSON.stringify(
origin: depot,
destination: depot, // return to depot
waypoints: stops,
profile: 'driving',
return_geometry: true,
),
}
);
const data = await res.json();
return {
orderedStops: data.waypoints_ordered,
routeLine: data.geometry, // → Static Images overlay
savedMins: Math.round(data.savings / 60),
};
} Method
POST - JSON body
Max waypoints
25 per request
Profiles
driving · truck · bicycle
Time windows
Per-waypoint [open, close]
Geometry format
GeoJSON LineString per leg
P95 latency
< 800 ms for 25 stops
Navigation API family
Turn-by-turn routes between waypoints with full geometry and instructions.
Solve the Travelling Salesman Problem to find the most efficient stop order.
Compute many-to-many travel times and distances in a single batched request.
Generate reachability polygons based on travel time or physical distance.
Often used together
Calculate a single origin-to-destination route. Use for the individual legs after the Optimized Route API has determined the stop order.
Sample elevation along the route path for gradient analysis and risk scoring.
Resolve customer address strings to coordinates before passing them as waypoints to the optimisation request.
Generate reachability zones from a depot to understand which stops are feasible within a time budget before running optimisation.
Start building
Subscribe on RapidAPI for instant key access. The free tier covers 50 optimisation requests per month, enough to build and test a complete dispatch flow end to end.