API / Routing
POST /v1/routing/directions

Routing API.

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

Built on an OSRM-based routing engine with road graph data derived from OpenStreetMap. Supports driving, walking, and cycling profiles. Returns alternatives, snapped coordinates, and leg-level breakdown for multi-stop routes.

API OPERATIONAL · View status
curl -X POST "https://api.farun.io/v1/routing/directions" \
  -H "X-RapidAPI-Key: YOUR_KEY" \
  -H "X-RapidAPI-Host: farun-maps.p.rapidapi.com" \
  -H "Content-Type: application/json" \
  -d '{
    "waypoints":[
      { "lon": 77.2090, "lat": 28.6139 },
      { "lon": 72.8777, "lat": 19.0760 }
    ],
    "profile":      "driving",
    "geometry":     "geojson",
    "alternatives": false
  }'

Returns

GeoJSON geometry

Profiles

driving · 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, geometry 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
    "geometry": {              // 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"
      }, ...]
    }, ...]
  }, ...],
  "waypoints": [{        // snapped coordinates
    "lon": 77.2091, "lat": 28.6138
  }, ...]
}
routes[].geometry 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.

waypoints[].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 geometry 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 geometry 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 driving 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://api.farun.io/v1/routing/directions

Request body (JSON)

waypoints req
array
Array of {lon, lat} objects. Minimum 2, maximum 25. Order determines route direction.
profile req
string
Routing profile. One of: driving, walking, cycling.
geometry
string
Response geometry format. geojson (default) or polyline6 for compact encoding.
alternatives
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 geometry and legs.
400 Bad request Invalid waypoints, unsupported profile, or malformed request body.
401 Unauthorized Missing or invalid RapidAPI key.
422 Unroutable No valid route found between the given waypoints. 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://api.farun.io/v1/routing/directions",
  headers={
    "X-RapidAPI-Key":  API_KEY,
    "X-RapidAPI-Host": "farun-maps.p.rapidapi.com"
  },
  json={
    "waypoints": [
      {"lon": 77.2090, "lat": 28.6139},
      {"lon": 72.8777, "lat": 19.0760}
    ],
    "profile":  "driving",
    "geometry": "geojson"
  }
)

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

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

Method

POST

Body format

application/json

Profiles

driving · walking · cycling

Max stops

25 waypoints 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.