/optimised_route Pass up to 2+ locations 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 costings, and time windows. Returns the reordered location sequence, full route geometry, and leg-by-leg durations and distances - ready to pass to your fleet or driver app.
25
Max locations
<800ms
P95 latency
$1.80
Per 1k requests
# Optimise a 5-stop delivery run
curl -X POST "https://YOUR-RAPIDAPI-HOST/optimised_route" \
-H "X-RapidAPI-Key: YOUR_RAPIDAPI_KEY" \
-H "X-RapidAPI-Host: YOUR_RAPIDAPI_HOST" \
-H "Content-Type: application/json" \
-d '{
"origin":[77.2090, 28.6139],
"destination":[77.2090, 28.6139],
"locations": [[77.1025, 28.7041],[77.2311, 28.5355],[77.0688, 28.6692],
[77.3910, 28.5245],
[77.1734, 28.6867]
],
"costing": "auto",
"return_geometry": true
}' Returns
Ordered locations + geometry
Costings
auto · truck · bicycle
Stops
2+ locations
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 location 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 locations, and the costing as 'auto' 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 costing respects weight and height restrictions on rural roads that car-costing 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 costing 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.
optimized_locations The input locations 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 {
"optimized_locations": [
{ "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://YOUR-RAPIDAPI-HOST/optimised_route Request body - JSON
origin req locations req destination costing return_geometry time_windows approach overview Response codes
200 application/json Optimised route with ordered locations, legs, and geometry. 400 Bad request Missing required fields, fewer than 2 locations, or invalid coordinates. 401 Unauthorized Missing or invalid RapidAPI key. 422 Unroutable No feasible route found between the given locations - 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://YOUR-RAPIDAPI-HOST/optimised_route',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-RapidAPI-Key': process.env.RAPIDAPI_KEY,
},
body: JSON.stringify(
origin: depot,
destination: depot, // return to depot
locations: stops,
costing: 'auto',
return_geometry: true,
),
}
);
const data = await res.json();
return {
orderedStops: data.optimized_locations,
routeLine: data.geometry, // route geometry
savedMins: Math.round(data.savings / 60),
};
} Method
POST - JSON body
Max locations
minimum 2
Costings
auto · 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 locations 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.
Resolve customer address strings to coordinates before passing them as locations 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.