API / Routing
POST /route

Routing API.

Turn-by-turn directions between two or more locations. Full GeoJSON shape_format, step instructions, distance, and duration in a single REST call.

Built on the Farun routing engine with road graph data derived from OpenStreetMap. Supports car, truck, walking, cycling, motorcycle, scooter, bus, and taxi costing modes, plus alternates and route-shape options.

API OPERATIONAL
curl -X POST "https://YOUR-RAPIDAPI-HOST/route" \
  -H "X-RapidAPI-Key: YOUR_RAPIDAPI_KEY" \
  -H "X-RapidAPI-Host: YOUR_RAPIDAPI_HOST" \
  -H "Content-Type: application/json" \
  -d '{
    "locations":[
      { "lon": 18.4241, "lat": -33.9249 },
      { "lon": 18.8602, "lat": -33.9321 }
    ],
    "costing": "auto",
    "shape_format": "polyline6"
  }'

Returns

GeoJSON shape_format

Profiles

auto · walking · cycling

Waypoints

2 - 25 per request

Response anatomy

Everything you need to render and act on a route.

One request returns the full picture, shape_format for the map, instructions for the driver, and leg-level data for your backend logic.

Example response (abbreviated) 200 OK
{
  "routes": [{
    "distance_m":   1423600,   // 1,423 km
    "duration_s":   50940,    // ~14.1 hours
    "shape_format": {              // GeoJSON LineString
      "type":        "LineString",
      "coordinates": [[77.209, 28.613], ...]
    },
    "legs": [{
      "distance_m": 1423600,
      "duration_s": 50940,
      "steps": [{
        "instruction": "Head south on NH-48",
        "distance_m":  4200,
        "duration_s":  312,
        "maneuver":    "depart"
      }, ...]
    }, ...]
  }, ...],
  "locations": [{        // snapped coordinates
    "lon": 77.2091, "lat": 28.6138
  }, ...]
}
routes[].shape_format GeoJSON LineString

The full route path as a GeoJSON LineString. Pass directly to MapLibre GL as a source, or to Leaflet as a polyline. Coordinates are [longitude, latitude] in EPSG:4326.

routes[].distance_m number

Total route distance in metres. Divide by 1000 for kilometres. Accurate to the road graph resolution not straight-line distance.

routes[].duration_s number

Estimated travel time in seconds based on road speed limits and classification. Does not account for live traffic use this as the baseline for ETA calculation.

routes[].legs[].steps array

Turn-by-turn instruction array. Each step includes a human-readable instruction string, distance, duration, maneuver type, and bearing. Use for driver display or voice prompt generation.

locations[].lon/lat number

Snapped waypoint coordinates. The routing engine snaps your input coordinates to the nearest navigable road. Use these in your UI rather than the raw input coordinates for accurate map pin placement.

Who uses it

Built for the teams that move things.

The Routing API is the backbone of any application where real-world navigation matters from last-mile delivery dispatch to field service scheduling to maritime passage planning.

Unlike cloud-first providers, Farun's routing is designed to work at the edge on-device in the GPS Navigator, or via API in environments with intermittent connectivity.

Fleet & Logistics

Dispatch and Route Assignment

Calculate routes for each vehicle in a dispatch queue. Return shape_format for the driver's map view and step instructions for turn-by-turn guidance. Pair with the Optimized Route API to reorder multi-stop runs.

Field Services

Technician and Engineer Routing

Route field engineers between job sites, calculate ETA for customer notifications, and log actual vs planned route adherence. The leg-level breakdown lets you attribute travel time to individual site visits.

Agriculture

Farm Access and Supply Chain Routing

Route between farm gates, collection points, and processing facilities across rural road networks that urban-centric APIs handle poorly. Farun's road graph includes rural tracks and agricultural access roads.

Emergency Services

Incident Response Routing

Calculate fastest routes for emergency response teams based on current position. The shape_format and step data can feed directly into CAD systems and mobile MDT displays without an additional mapping layer.

Travel & Tourism

Itinerary and Tour Routing

Build multi-day road trip itineraries with per-leg distance and duration. Show route lines on a trip planning map. Generate auto directions for guided tour apps without paying per-map-load fees.

Insurance & Telematics

Planned vs Actual Route Comparison

Generate the planned route for a given trip and compare it against GPS telemetry logs from the vehicle. Deviation scoring, excess mileage detection, and route adherence reporting for fleet insurance products.

Endpoint reference

POST https://YOUR-RAPIDAPI-HOST/route

Request body (JSON)

locations req
array
Array of {lon, lat} objects. Minimum 2, maximum 25. Order determines route direction.
costing req
string
Routing costing. One of: auto, walking, cycling.
shape_format
string
Response shape_format format. polyline6 (default) or polyline6 for compact encoding.
alternates
boolean
Return up to 3 alternative routes. Default: false. Increases response time slightly.
steps
boolean
Include turn-by-turn step instructions in each leg. Default: true.
language
string
Instruction language code. Default: en. Supported: en, hi, fr, de, es, ar.

Response codes

200 application/json Route calculated successfully. Returns routes array with shape_format and legs.
400 Bad request Invalid locations, unsupported costing, or malformed request body.
401 Unauthorized Missing or invalid RapidAPI key.
422 Unroutable No valid route found between the given locations. Check coordinates are on a navigable road.
429 Rate limited Exceeded plan request rate. Upgrade on RapidAPI.

Integration example

Fleet dispatch - route + draw on map Python
import requests, json

# Build route for a dispatch job
res = requests.post(
  f"https://YOUR-RAPIDAPI-HOST/route",
  headers={
    "X-RapidAPI-Key":  API_KEY,
    "X-RapidAPI-Host": "YOUR_RAPIDAPI_HOST"
  },
  json={
    "locations": [
      {"lon": 77.2090, "lat": 28.6139},
      {"lon": 72.8777, "lat": 19.0760}
    ],
    "costing":  "auto",
    "shape_format": "polyline6"
  }
)

route = res.json()["routes"][0]

# Store for driver display
dispatch_job.update({
  "shape_format":    route["shape_format"],
  "distance_km": route["distance_m"] / 1000,
  "eta_mins":    route["duration_s"] // 60
})

Method

POST

Body format

application/json

Profiles

auto · walking · cycling

Max stops

25 locations per request

Geometry

GeoJSON or polyline6

Languages

en, hi, fr, de, es, ar

Navigation API family

Often used together

Start routing

500 free routing requests
every month.

The Starter plan on RapidAPI includes 500 routing requests per month at no cost. Enough to build and test a full dispatch or navigation integration before committing to Pro.