Traffic & routing integration guide
Traffic & routing integration guide
This guide takes you from an API key to a complete traffic and routing integration: a traffic layer on your map, directions with travel times you can promise to a customer, ETAs for many trips at once, "what can I reach in 15 minutes" areas, optimised delivery tours, single-road lookups and live turn-by-turn navigation. It explains what every number means, so you can show it correctly, and links to the API reference for every field.
It is written for app developers on web, iOS, Android and backend services. All examples use plain HTTPS and JSON, so they translate directly to any language or SDK.
On this page
- What you get
- Before you start
- Core concepts
- Show traffic on your map
- Directions with a real ETA
- Colour a route by traffic
- Turn-by-turn navigation
- ETAs for many trips: the matrix
- How far can I get: isochrones
- Optimise stops and fleets
- One road, or one view
- Traffic for planning ahead
- Travel modes
- Road signs, closures and borders
- Freshness and caching
- Errors and edge cases
- Contributing traffic data
- Checklist and FAQ
- Endpoint map
What you get
- Traffic on every road, in each direction, at any hour, in every city Navvo covers. Each road's answer says what it is based on: measured recently, typical for that road at that hour, or expected. There is never a blank map and never an unlabelled guess.
- Travel times you can show as an ETA, on every routing endpoint. Each road is timed at the moment the vehicle reaches it, from the speed traffic really drives there, the vehicle's own speed, traffic at that time, and the time lost at junctions and traffic lights for the turn made there.
- Routes chosen by that travel time. Traffic shapes which route comes first, and a route around heavy traffic is offered when it clearly saves time.
- Seven travel modes, each timed its own way: car, truck, motorcycle, scooter, bicycle, walking and wheelchair. Public transport has its own planner.
- Road rules respected: no-entry and turn-ban signs by direction, closures, incidents, and no routes across national borders until crossings are verified.
- The same answer everywhere: the map layer, routes, matrices, isochrones, optimised tours and navigation all use the same traffic and the same timing, so a number on one screen agrees with the number on the next.
Before you start
Base URL and authentication
https://navvo.io/api/v1
Send your developer API key in the x-api-key header on every request. Apps whose users sign in to Navvo can send the user's token as Authorization: Bearer <token> instead.
curl -s "https://navvo.io/api/v1/routing/profiles" -H "x-api-key: $NAVVO_API_KEY"
Keep server keys on your server. For a browser or mobile app, create a key restricted to your website or app in the developer portal, and never ship an unrestricted key.
Scopes
| Scope | Unlocks |
|---|---|
routing | /routing/* (directions, matrix, isochrone, optimise, map-match), /navigation/* |
traffic | /traffic/* (tiles, segments, summary, analysed traffic) |
routing + traffic | POST /traffic/route (a route coloured by traffic) |
optimize | /optimize/* (fleet routing with vehicles, capacities and time windows) |
telemetry | /telemetry/* (contributing trips) |
A request without a valid key returns 401; a key without the scope returns 403.
Coordinates and units
| Where | Coordinates |
|---|---|
/routing/plan, /traffic/route | { "lon": …, "lat": … } objects |
/routing/route, /matrix, /isochrone, /optimize, /map-match | { "lat": …, "lon": … } objects (note lon) |
/navigation/sessions | { "lat": …, "lng": … } |
GeoJSON output, shape arrays in /traffic/route | [lng, lat] |
Encoded route shapes (legs[].shape) | polyline with precision 1e6 |
Times are seconds unless a field name says minutes. Distances are kilometres unless you ask for miles. Speeds are km/h.
Response envelope
Routing endpoints answer 201 and wrap the route in { provider, available, path, data }. Always check available before reading data: if the routing service is briefly unreachable you get available: false rather than an error.
Core concepts
Evidence: measured, typical, expected
Every traffic answer carries its evidence. Show it, so your users know what they are looking at.
| Evidence | Label (en / ar) | Means | Draw it |
|---|---|---|---|
observed | Measured recently / حركة مرصودة مؤخرا | Measured on that road and direction within the last few minutes, by at least three independent contributors, so no single trip can be seen. | Solid line, white casing |
typical | Typical / حركة معتادة | That road's own history on this kind of day at this hour. | Solid or dashed line |
expected | Expected / حركة متوقعة | Navvo's expected traffic for that road at that time. It follows the time of day, the day of the week, each country's weekend, public and school holidays, Ramadan and Eid, salary days near shops, the weather, the direction commuting traffic flows and the queues that form before junctions. | Solid or dashed line |
Route-level answers use a slightly longer list (observed_supplied, observed, forecast, typical, structural, unknown). forecast is the route's word for expected; structural and unknown appear only where no expected value can be computed. Every response that carries evidence also carries the ready-to-show en and ar labels, so you never have to translate.
Note: only
observedis "live". Never labeltypicalorexpectedtraffic as live. The labels above are the honest wording.
Traffic levels and colours
level | congestion | Colour | Meaning |
|---|---|---|---|
free | light | #2DBE60 | Moving at more than about three-quarters of the road's own quiet-hour speed |
slow | moderate | #F9A825 | About half to three-quarters |
heavy | heavy | #E84B36 | About a quarter to a half |
standstill | blocked | #A01A12 | A quarter or less |
Levels compare each road with itself at its quietest, not with its speed limit. A city street never reaches its limit, even when empty, because of lights, junctions and parked cars, so comparing with the limit would paint every city orange.
Colour shows where traffic slows. A street's delay stands in the queue before its lights or busy junction, so from zoom 13 that last stretch is its own line with the queue's colour, while the rest of the street shows how it is moving. Route segments follow the same rule, so a route and the map around it agree. Travel times count the whole delay, queues included.
Travel time
Every time Navvo returns is a travel time: what a person can expect, door to door, on the route given.
- Each road is timed at the moment the vehicle reaches it. A road you reach 20 minutes after leaving is timed with the traffic expected 20 minutes from now.
- It uses the speed traffic really drives on that kind of street, capped by the vehicle's own speed.
- It adds the time lost at each junction for the turn made there: going straight through a small junction costs almost nothing, a left turn across a main road costs much more, and junctions with traffic lights cost the usual wait for the green (short at night, long in the rush hours).
- For walking, cycling and wheelchair routes it follows the travel mode's own pace instead (see Travel modes).
So a kilometre of plain city street takes about one and a half minutes in light traffic, and more with turns, lights and traffic.
Routes also carry the routing graph's own time as static_time, for comparison only. Never show static_time as the ETA.
Departure time
Everything is evaluated for a departure. By default it is now. Pass a departure to plan ahead:
| Endpoint | Field |
|---|---|
/routing/plan, /routing/matrix, /traffic/route | departureTime (ISO 8601, e.g. 2026-12-01T05:30:00Z) |
/routing/route, /isochrone, /optimize | payload.date_time: { "type": 1, "value": "2026-12-01T08:30" } (local time) or { "type": 0 } for now |
/traffic/tiles | t query parameter |
/traffic/segments/{ref} | at query parameter |
Show traffic on your map
One vector-tile source draws traffic on every road, in each direction. This is the recommended traffic layer.
GET /traffic/tiles/{z}/{x}/{y}.mvt?t=<ISO time or epoch ms>
- Zooms 6 to 14; let the map overzoom above 14. Zooms 6–9 carry motorways and trunk roads, 10–11 add primary roads, 12 secondary, 13 tertiary, 14 minor and service roads.
- One layer,
traffic, of lines with these properties:level,ratio(speed as a percentage of the road's quiet-hour speed),ev(observed,typical,expected),cls(road class),rank(0 = motorway) anddir. diris0for a one-way road (or one line for both directions), and1/-1for the two directions of a two-way road. Each direction is already drawn in its own direction of travel, so a positiveline-offsetputs it on its right-hand side.- Service roads (inside compounds, campuses, malls, car parks) and dead-end streets appear only where real measurements exist; they are never drawn from expected traffic.
- Use one URL per 5-minute slot (
trounded down to 5 minutes): tiles for a slot are cacheable, and the next slot brings new traffic.
MapLibre GL JS (web)
const KEY = 'nvvo_YOUR_KEY';
const slot = () => new Date(Math.floor(Date.now() / 300000) * 300000).toISOString();
const tiles = () => [`https://navvo.io/api/v1/traffic/tiles/{z}/{x}/{y}.mvt?t=${encodeURIComponent(slot())}`];
const map = new maplibregl.Map({
container: 'map',
style: `https://navvo.io/api/v1/tiles/style?style=standard&api_key=${KEY}`,
transformRequest: (url) => (url.includes('/traffic/tiles/') ? { url, headers: { 'x-api-key': KEY } } : { url }),
});
const COLOR = ['match', ['get', 'level'], 'slow', '#F9A825', 'heavy', '#E84B36', 'standstill', '#A01A12', '#2DBE60'];
const WIDTH = ['interpolate', ['linear'], ['zoom'], 6, 1, 10, 2, 13, 3, 16, 5, 19, 8];
const OFFSET = ['interpolate', ['linear'], ['zoom'], 14.9, 0, 15, ['*', 1.5, ['get', 'dir']], 18, ['*', 4, ['get', 'dir']]];
const MINOR = ['in', ['get', 'cls'], ['literal', ['minor', 'service']]];
const SORT = ['match', ['get', 'level'], 'standstill', 3, 'heavy', 2, 'slow', 1, 0];
map.on('load', () => {
const before = map.getStyle().layers.find((l) => l.type === 'symbol')?.id; // keep labels on top
map.addSource('navvo-traffic', { type: 'vector', tiles: tiles(), minzoom: 6, maxzoom: 14 });
map.addLayer({ id: 'traffic-measured-casing', type: 'line', source: 'navvo-traffic', 'source-layer': 'traffic',
filter: ['all', ['==', ['get', 'ev'], 'observed'], ['!', MINOR]],
layout: { 'line-cap': 'round', 'line-join': 'round' },
paint: { 'line-color': '#FFFFFF', 'line-width': ['+', WIDTH, 3], 'line-offset': OFFSET } }, before);
map.addLayer({ id: 'traffic-major', type: 'line', source: 'navvo-traffic', 'source-layer': 'traffic',
filter: ['!', MINOR], layout: { 'line-cap': 'round', 'line-join': 'round', 'line-sort-key': SORT },
paint: { 'line-color': COLOR, 'line-width': WIDTH, 'line-offset': OFFSET, 'line-opacity': 0.85 } }, before);
map.addLayer({ id: 'traffic-minor', type: 'line', source: 'navvo-traffic', 'source-layer': 'traffic', minzoom: 15,
filter: MINOR, layout: { 'line-cap': 'round', 'line-join': 'round', 'line-sort-key': SORT },
paint: { 'line-color': COLOR, 'line-width': ['*', WIDTH, 0.6], 'line-offset': OFFSET, 'line-opacity': 0.85 } }, before);
setInterval(() => map.getSource('navvo-traffic').setTiles(tiles()), 300000);
});
// Tooltip: the level and what it is based on
const LABEL = { observed: 'Measured recently', typical: 'Typical', expected: 'Expected' };
map.on('mousemove', 'traffic-major', (e) => {
const p = e.features[0].properties;
console.log(`${p.level} · ${LABEL[p.ev]}`);
});
iOS and Android
MapLibre Native (iOS and Android) and the Navvo mobile SDKs read the same tiles. Add a vector source with the tile URL template above, send the x-api-key header through the SDK's request hook (or a key restricted to your app), and add the same three line layers with the same expressions: MapLibre Native accepts the style expressions shown above unchanged.
Legend
Show the four colours with their labels, and the evidence with more than colour: the white casing marks roads measured recently, and the tooltip or a legend line names the evidence. Use the labels from Evidence in your user's language.
Traffic at another time
Pass t up to 7 days ahead (or within the last day): "What will traffic be like at 8:30 tomorrow?" is the same layer with t=2026-12-01T05:30:00Z. Ahead of time, roads are typical or expected; only the present can be observed.
The 3D cars API
For moving cars that follow the traffic in a 3D view, let Navvo do the traffic work.
GET /traffic/cars/tiles/14/{x}/{y} returns
every lane of a zoom-14 tile. Each lane is already offset to its side of the road and comes with its
speed every ~20 m and its flow of cars. Your app places the cars every frame with the arithmetic
below, with no requests in between.
The cars move like the traffic colour under them. On a main road (60 km/h free speed):
| Colour | Speed | Gap between cars (rush hour) |
|---|---|---|
| Green | 42–60 km/h | 30–60 m, spread out |
| Orange | 7–18 km/h | about 11 m, stacked |
| Red | 3–7 km/h | about 9 m, bumper to bumper |
| Dark red | 1–3 km/h | 7.5–8 m |
Other classes scale with their free speed.
Positions come from the clock (epoch seconds), so every device shows the same cars at the same
moment. GET /traffic/cars/positions returns
exactly the points your code must produce, so use it in your tests.
- With the 3D map at zoom 16 or closer, fetch the zoom-14 tiles that cover the view, and refetch the visible ones every 60 seconds.
- Prepare each lane once. Then, every frame, place its cars and set them as the data of one
symbol layer, below the 3D buildings. 30 frames a second is plenty. Rotate the icon to
bearing, and seticon-rotation-alignmentandicon-pitch-alignmenttomap. - Keep every view uncrowded: about 120 cars on a phone, 200 on a tablet. When the camera settles,
give each lane a
keepshare. Lanes near the centre of the view keep all their cars, and farther lanes fewer (keepByDistancebelow). Cars are hidden in groups of 4 consecutive cars, so what stays of a queue is still a stacked queue. A hidden group never moves a car. Never thin by scalingflow: positions come from the clock, so that moves every car.
// A lane = one feature of /traffic/cars/tiles/14/{x}/{y}. Prepare it once per fetch.
function prepareLane(f) {
const c = f.geometry.coordinates, p = f.properties;
const metres = (a, b) => Math.hypot((b[0] - a[0]) * 111320 * Math.cos(((a[1] + b[1]) / 2) * Math.PI / 180), (b[1] - a[1]) * 110540);
const cum = [0];
for (let i = 1; i < c.length; i++) cum.push(cum[i - 1] + metres(c[i - 1], c[i]));
const length = cum[cum.length - 1], stepEnd = [], stepTime = [];
let t = 0;
p.speeds.forEach((v, k) => { t += p.stepM / v; stepEnd.push(Math.min(length, (k + 1) * p.stepM)); stepTime.push(t); });
return { ...p, coords: c, cum, length, stepEnd, stepTime, totalTime: t };
}
// A stable 0–1 number per lane and group of 4 cars (32-bit hash): the group is drawn when it is below the lane's `keep`.
function carUnit(seed, n) {
const lo = ((n % 4294967296) + 4294967296) % 4294967296;
let h = (seed ^ lo) >>> 0;
h = Math.imul(h, 0x9e3779b1) >>> 0; h = (h ^ (h >>> 15)) >>> 0;
h = Math.imul(h, 0x85ebca77) >>> 0; h = (h ^ (h >>> 13)) >>> 0;
return h / 4294967296;
}
// Every frame: the cars of one lane at `now` (epoch seconds). Cars enter one headway (1 / flow)
// apart and move at the step speeds, so they bunch where it is slow.
function laneCars(L, now, emit) {
if (!(L.flow > 0) || !(L.keep > 0)) return;
const h = 1 / L.flow;
let tau = ((((now / h + L.phase) % 1) + 1) % 1) * h; // seconds since the newest car entered
for (let k = 0; tau < L.totalTime && k < 400; tau += h, k++) {
const car = Math.floor(now * L.flow + L.phase) - k; // stable id while the car drives
if (L.keep < 1 && carUnit(L.seed, Math.floor(car / 4)) >= L.keep) continue; // hidden in groups of 4
let i = 0; while (L.stepTime[i] < tau && i < L.stepTime.length - 1) i++; // step the car is in
const s = Math.min(L.length, (i ? L.stepEnd[i - 1] : 0) + (tau - (i ? L.stepTime[i - 1] : 0)) * L.speeds[i]);
let j = 0; while (j < L.cum.length - 2 && L.cum[j + 1] <= s) j++; // segment it is on
const a = L.coords[j], b = L.coords[j + 1];
const f = Math.min(1, Math.max(0, (s - L.cum[j]) / Math.max(1e-9, L.cum[j + 1] - L.cum[j])));
const bearing = (Math.atan2((b[0] - a[0]) * Math.cos(a[1] * Math.PI / 180) * 111320, (b[1] - a[1]) * 110540) * 180 / Math.PI + 360) % 360;
emit(a[0] + (b[0] - a[0]) * f, a[1] + (b[1] - a[1]) * f, bearing, (((L.seed + car) % 8) + 8) % 8, Math.max(0, Math.min(1, s / 12, (L.length - s) / 12)));
}
}
// When the camera settles: about `budget` cars in view. Lanes within R metres of the centre keep all
// their cars, farther lanes R / distance of them; R by bisection. L.visible = share of vertices in view,
// L.dist = metres from the view centre to the lane's nearest vertex.
function keepByDistance(lanes, budget) {
const keepAt = (R, d) => Math.min(1, R / Math.max(R, d));
const total = (R) => lanes.reduce((n, L) => n + L.cars * L.visible * keepAt(R, L.dist), 0);
if (total(1e9) <= budget) { lanes.forEach((L) => { L.keep = 1; }); return; }
let lo = 0.01, hi = 1e6;
for (let i = 0; i < 50; i++) { const mid = Math.sqrt(lo * hi); if (total(mid) > budget) hi = mid; else lo = mid; }
const scale = total(lo) > budget ? budget / total(lo) : 1; // a jammed road right at the centre
lanes.forEach((L) => { L.keep = keepAt(lo, L.dist) * scale; });
}
Use the numbers exactly as sent, as 64-bit floats. When a refresh changes a lane's numbers, let the
cars already on it finish under the old ones, so nothing jumps: draw the old lane's cars with
tau > now − switchAt and the new lane's with tau ≤ now − switchAt, until the old lane's
totalTime has passed. Lanes whose numbers didn't change keep their cars as they are.
Animated traffic in 3D scenes
To build the cars yourself instead, the traffic tiles can drive them directly: more cars where traffic is heavy, fewer where it flows, and slow, bunched-up cars in the queues before junctions. Navvo's own 3D map does it this way:
- Read the pieces under each lane. For every lane of every direction on screen, look up the
trafficpiece under it every ~20 m. Match the direction as well as the position: each piece is drawn in its direction of travel, so take the nearest piece within ~12 m whose bearing is within ~50° of the lane's. - Speed = the road class's free speed × a share that follows the colour: green (
ratioabove 78) 0.7–1, orange (above 50) 0.12–0.3, red (above 25) 0.05–0.11, dark red 0.02–0.05, linear inside each band. Cars crawl in queues and run on green. Free speeds we use: motorway 100, trunk 80, primary 60, secondary 50, tertiary 40, minor 30, service 15 km/h. - Density (cars per km per lane) is the larger of:
- flowing: 22 × how busy the class is (motorway 1, trunk 0.95, primary 0.85, secondary 0.7, tertiary 0.55, minor 0.28, service 0.12) × how busy the hour is (0.1 at 4 am up to 1 in the afternoon peak);
- slowing: 125 × (1 − the speed share), which rises towards a standstill queue (about 8 m per car).
- One flow per lane. The flow is the lane's average of density × speed, capped at the slowest stretch's speed ÷ your minimum gap between cars (at least the car's length). Cars enter one headway (1 / flow) apart and move at the local speed, so they spread out where it is fast and bunch up where it is slow, and never overlap.
- Streets missing from the tiles get no cars. Service roads and dead ends without real measurements are left out of the tiles, so they stay empty instead of showing made-up traffic.
// cars per km per lane, and metres per second, for one traffic piece
const FREE_KMH = { motorway: 100, trunk: 80, primary: 60, secondary: 50, tertiary: 40, minor: 30, service: 15 };
const BUSY = { motorway: 1, trunk: 0.95, primary: 0.85, secondary: 0.7, tertiary: 0.55, minor: 0.28, service: 0.12 };
const density = (p, hourShare) => Math.max(22 * BUSY[p.cls] * hourShare, 125 * (1 - speedShare(p.ratio)));
// share of free speed per colour band: [up to ratio, share at the band's low end, at its top]
const BANDS = [[25, 0.02, 0.05], [50, 0.05, 0.11], [78, 0.12, 0.3], [100, 0.7, 1]];
function speedShare(ratio) {
let low = 0;
for (const [top, v0, v1] of BANDS) { if (ratio <= top) return v0 + ((ratio - low) / (top - low)) * (v1 - v0); low = top; }
return 1;
}
const speed = (p) => (FREE_KMH[p.cls] / 3.6) * speedShare(p.ratio);
// a lane = steps of ~20 m, each with the piece under it
function laneFlow(steps, hourShare, minGapM) {
const carried = steps.reduce((sum, s) => sum + (density(s.piece, hourShare) / 1000) * speed(s.piece) * s.metres, 0);
const metres = steps.reduce((sum, s) => sum + s.metres, 0);
const slowest = Math.min(...steps.map((s) => speed(s.piece)));
return Math.min(carried / metres, slowest / minGapM); // cars per second
}
// A car that entered the lane `tau` seconds ago is wherever `tau` seconds of travel at the local
// speeds take it; cars enter every 1 / flow seconds.
Keep every view uncrowded: when the total is over budget, keep all the cars of lanes near the centre of the view and fewer of farther lanes, hiding them in groups of a few consecutive cars so queues still read as stacked (as in the 3D cars API above). Refresh the pieces when the 5-minute slot turns.
Directions with a real ETA
POST /routing/plan is the recommended endpoint for directions. You give it stops and preferences; it returns the best route and alternates, each with travel times, traffic, road-sign checks and a routeId for navigation.
curl -s -X POST "https://navvo.io/api/v1/routing/plan" \
-H "x-api-key: $NAVVO_API_KEY" -H "content-type: application/json" \
-d '{
"locations": [ { "lon": 35.9311, "lat": 31.9516 }, { "lon": 35.8999, "lat": 31.9705 } ],
"costing": "auto",
"alternates": 2,
"includeLabels": false
}'
const res = await fetch('https://navvo.io/api/v1/routing/plan', {
method: 'POST',
headers: { 'x-api-key': KEY, 'content-type': 'application/json' },
body: JSON.stringify({
locations: [{ lon: 35.9311, lat: 31.9516 }, { lon: 35.8999, lat: 31.9705 }],
costing: 'auto',
alternates: 2,
includeLabels: false, // skip the AI route label for an instant answer
}),
});
const plan = await res.json();
const minutes = Math.round(plan.trip.summary.time / 60); // the ETA to show
const arrival = plan.eta?.recommended?.arrivalTime; // ISO arrival time
const lightTraffic = Math.round(plan.trip.summary.traffic.free_flow_time / 60);
const routeId = plan.routeId; // start navigation on exactly this route
What to read
| Field | Use |
|---|---|
trip.summary.time | The ETA, in seconds, for this route leaving at the departure time. |
trip.summary.length | Distance in km. |
eta.recommended | { seconds, minutes, arrivalTime, basis: "travelTime" }, ready to show. |
trip.legs[].summary.time, trip.legs[].maneuvers[].time | Time per leg and per instruction, on the same scale; they add up to the trip. |
trip.summary.traffic | { free_flow_time, junction_time, evidence }: the same route in light traffic, the seconds spent at junctions and lights, and how much of the distance is measured, typical or expected. |
trip.summary.static_time | The routing graph's own time. For comparison only. |
alternates[] | Other routes, each { routeId, trip }, already sorted by travel time. |
traffic | The route's traffic evidence: sourceMix, measuredShare, evidenceClass, pathChangedByTraffic and ready-to-show labels. |
travelTime | { chosenFor, candidates, detourTried }. chosenFor: "traffic_detour" means a route around heavy traffic won. |
signRules | Road signs that applied and any rule breaks steered around. |
routeId | Pass to POST /navigation/sessions within 15 minutes to navigate exactly this route. |
Showing "x minutes slower than usual". Compare trip.summary.time with trip.summary.traffic.free_flow_time (the same route in light traffic). Show the difference only when it is meaningful, for example more than 2 minutes and 10%.
Useful options
| Option | Effect |
|---|---|
costing | auto (default), truck, motorcycle, motor_scooter, bicycle, pedestrian, wheelchair. |
departureTime | Leave later (or earlier today); every road is timed for that departure. |
alternates | 0–2 alternative routes. |
avoid | tolls, highways (motorways and trunk expressways), ferries, unpaved, checked road by road. |
vehicle.maxSpeedKph | The vehicle's top speed; route choice and every time respect it. Trucks also take heightM, widthM, lengthM, weightT, axleLoadT, hazmat. |
originHeading, originTrace | For a moving vehicle: the route starts on the road being driven, in the direction of travel. |
includeLabels: false | Skip the AI route label (saves 1–2 s). Recommended for interactive apps. |
language | Instruction language, for example en-US or ar. |
To route to a place's entrance rather than its centre, use the place's recommended arrivalIntelligence.candidates[0].routeTarget as the destination (see Places).
The raw route endpoint
If your app already speaks the routing engine's request format, POST /routing/route takes it as { "payload": { … } } and plans the route the same way: travel times in summary.time, legs[].summary.time and maneuvers[].time (with static_time beside them), traffic-aware choice, road signs and the border check. Its response keeps the engine's shape. See POST /routing/route.
Colour a route by traffic
To draw a route in traffic colours, send the route's own shape to POST /traffic/route. Sending the shape you display guarantees the colours match your line.
const coords = decodePolyline6(plan.trip.legs[0].shape); // [[lon, lat], ...]
const r = await (await fetch('https://navvo.io/api/v1/traffic/route', {
method: 'POST',
headers: { 'x-api-key': KEY, 'content-type': 'application/json' },
body: JSON.stringify({ locations: [origin, destination], shape: coords, costing: 'auto' }),
})).json();
// The route goes ABOVE the traffic layer: wider, with a white edge, so it reads first.
map.addSource('route-traffic', { type: 'geojson', data: r.segments });
map.addLayer({ id: 'route-casing', type: 'line', source: 'route-traffic',
layout: { 'line-cap': 'round', 'line-join': 'round' },
paint: { 'line-color': '#FFFFFF', 'line-width': ['interpolate', ['linear'], ['zoom'], 10, 8, 14, 11.5, 18, 20] } });
map.addLayer({ id: 'route-traffic', type: 'line', source: 'route-traffic',
layout: { 'line-cap': 'round', 'line-join': 'round' },
paint: { 'line-color': ['get', 'color'], 'line-width': ['interpolate', ['linear'], ['zoom'], 10, 5, 14, 8, 18, 15] } });
// Traffic steps back while a route is shown (restore 0.85 when it is cleared).
for (const id of ['traffic-major', 'traffic-minor']) map.setPaintProperty(id, 'line-opacity', 0.45);
// Frame the route ONCE, clear of any panel over the map.
const lons = coords.map((c) => c[0]), lats = coords.map((c) => c[1]);
map.fitBounds([[Math.min(...lons), Math.min(...lats)], [Math.max(...lons), Math.max(...lats)]],
{ padding: { top: 70, right: 80, bottom: 70, left: 430 } }); // left = your panel's width + a margin
console.log(r.durationInTrafficMinutes, 'min, of which', r.delayMinutes, 'min traffic delay');
console.log(r.traffic.evidenceLabel.en); // e.g. "Expected"
segments is a GeoJSON FeatureCollection; each stretch carries its level, colour and evidence. durationInTrafficSeconds is on the same scale as the route's trip.summary.time; baseDurationSeconds is the same route in light traffic.
Keep the traffic layer close to full strength (about 0.85) so its colours read true, and lower it (about 0.45) while a route is on screen. Frame a route once, when it first arrives. When its traffic refreshes or the route is re-planned in the background, update the line without moving the camera, so people can pan and zoom around the route freely.
A minimal polyline decoder (precision 1e6):
function decodePolyline6(str) {
const out = []; let i = 0, lat = 0, lon = 0;
while (i < str.length) {
for (const k of [0, 1]) {
let r = 0, s = 0, b;
do { b = str.charCodeAt(i++) - 63; r |= (b & 31) << s; s += 5; } while (b >= 32);
const d = r & 1 ? ~(r >> 1) : r >> 1;
if (k === 0) lat += d; else lon += d;
}
out.push([lon / 1e6, lat / 1e6]);
}
return out;
}
Turn-by-turn navigation
Navigation sessions keep the ETA and the route up to date while the user drives, rides or walks.
- Plan and preview with
POST /routing/plan. Let the user pick the main route or an alternate. - Start with
POST /navigation/sessions, sending the pickedrouteId(within 15 minutes) plusoriginanddestination. The session starts on exactly that route, so the distance and time match the preview. When the vehicle is already moving, sendorigin.headingandorigin.speed. - Stream positions over the live socket
wss://navvo.io/api/v1/navigation/sessions/{id}/live(recommended) or withPATCH /navigation/sessions/{id}. Each update returns progress, the next instruction, the remaining time and arrival time, and reroutes when the user leaves the route. - Arrive or end with
POST /navigation/sessions/{id}/completeorDELETE.
Every reroute is planned like a new route: travel times with traffic, road signs, the session's avoid list, and a start in the direction the vehicle is already moving. Remaining times count down on the same scale as the preview.
const session = await (await fetch('https://navvo.io/api/v1/navigation/sessions', {
method: 'POST',
headers: { 'x-api-key': KEY, 'content-type': 'application/json' },
body: JSON.stringify({
routeId: plan.routeId,
origin: { lat: 31.9516, lng: 35.9311, heading: 270, speed: 8.3 },
destination: { lat: 31.9705, lng: 35.8999, name: 'Shmeisani' },
costing: 'auto', language: 'en-US',
}),
})).json();
const ws = new WebSocket(`wss://navvo.io/api/v1/navigation/sessions/${session.sessionId}/live?token=${userToken}`);
// send location_update messages; handle progress, instruction and reroute messages
The socket protocol, message types, keep-alive and reconnection rules are in Navigation WebSocket. The REST endpoints, webhooks and arrival detection are in Navigation.
ETAs for many trips: the matrix
POST /routing/matrix returns travel times between many origins and many destinations in one call: nearest-driver searches, dispatch boards, delivery planning. Each duration is a travel time on the same scale as /routing/plan, including traffic at the departure time, junctions and lights.
const out = await (await fetch('https://navvo.io/api/v1/routing/matrix', {
method: 'POST',
headers: { 'x-api-key': KEY, 'content-type': 'application/json' },
body: JSON.stringify({
origins: drivers.map((d) => ({ lat: d.lat, lon: d.lon })),
destinations: [{ lat: pickup.lat, lon: pickup.lon }],
costing: 'auto',
}),
})).json();
const m = out.matrix;
const best = m.cells
.filter((c) => c.status === 'ok')
.sort((a, b) => a.duration - b.duration)[0];
console.log(`Driver ${best.originIndex} is ${Math.round(best.duration / 60)} min away`);
console.log(m.traffic.applied ? 'with traffic now' : m.traffic.message);
| Field | Meaning |
|---|---|
cells[].duration | Travel time in seconds for the pair. Show this. |
cells[].delay | Seconds lost to traffic versus light traffic (null without traffic). |
cells[].trafficDuration | Equal to duration when traffic is applied; null otherwise. |
cells[].status, reason | ok, unreachable, out_of_range, out_of_coverage or engine_error, with a reason. |
traffic.applied, traffic.reason | Whether traffic is included, and why not. |
traffic.network.updatedAt | When the road network's traffic was last refreshed (about every 15 minutes). |
departureTimeplans ahead;trafficAware: falseasks for light-traffic durations.- Up to 2,500 pairs per call (for example 50 × 50). For up to 250,000 pairs, submit
POST /routing/matrix/jobsand poll. Read the live limits fromGET /routing/matrix/limits. - Large answers: ask for
format: "grid"to get compact row-major arrays. - A matrix with traffic is cached for at most 10 minutes; ask again for fresh traffic.
A matrix answer and a planned route for the same trip agree closely. They can differ slightly, because a planned route picks among several candidates and its time is computed road by road; use the matrix to rank and estimate, and /routing/plan for the route you will actually drive.
How far can I get: isochrones
POST /routing/isochrone draws the area reachable within N minutes (or N km). The minutes are travel minutes on the same scale as a planned route, and motor modes leave now with traffic unless you set payload.date_time.
{
"payload": {
"locations": [ { "lat": 31.9539, "lon": 35.9106 } ],
"costing": "auto",
"contours": [ { "time": 10 }, { "time": 20 } ],
"polygons": true
}
}
The answer is a GeoJSON FeatureCollection; properties.contour is the minutes you asked for, and the top-level timing says whether traffic was applied. Typical uses: delivery zones, "open now within 15 minutes", store catchments. A place inside the 15-minute area is about 15 minutes away by /routing/plan.
Optimise stops and fleets
| Need | Endpoint |
|---|---|
| One vehicle, best order for a few stops | POST /routing/optimize (or POST /routing/plan with optimize: true) |
| Many vehicles, capacities, time windows, pickups and deliveries | POST /optimize/routes (scope optimize) |
Both decide with travel times that include traffic for motor modes. /routing/optimize returns one trip whose summary.time, legs and instructions are travel times (static_time beside them), and data.trip.locations[].original_index maps the order back to your input. A tour that would cross a national border is refused with 422 BORDER_CROSSING_UNAVAILABLE. See Route optimization for the fleet solver.
One road, or one view
One road: GET /traffic/segments/{ref}
What one road is like, in one direction, when a vehicle enters it, split into parts by evidence.
curl -s "https://navvo.io/api/v1/traffic/segments/osm%3A123456%3Af%3A9a8b7c6d?at=2026-11-30T12:05:00Z" \
-H "x-api-key: $NAVVO_API_KEY"
running_time_s is the time to drive the road at that moment; parts[] says which stretch is measured, typical or expected (forecast). Every road has an answer: stretches with no measurement or history of their own carry the road's expected traffic. Use a stable road reference you received from Navvo, or g:<graph id> with lat/lon.
One view: GET /traffic/summary?bbox=west,south,east,north
A sentence and numbers for the current map view, in English and Arabic: "Slow moving", with a breakdown. With a view up to about 0.6° wide, roads describes every road in view, each direction separately, in kilometres per level, with the share that is measured, typical or expected. Use it for a banner such as "Traffic in view: slow (38% of roads)". conditions keeps the area-level summary with its basis and freshness labels.
const s = await (await fetch(`https://navvo.io/api/v1/traffic/summary?bbox=${b.join(',')}`, { headers: { 'x-api-key': KEY } })).json();
if (s.roads) banner(`${s.roads.summary} · ${s.roads.breakdown.find((x) => x.level === s.roads.level).share}% of roads`);
Traffic for planning ahead
For "when should I leave?" and planning screens, Navvo's analysed traffic gives the usual traffic for any place and time, with the day type, holidays, Ramadan, the season and the weather applied:
GET /traffic/analysed?lat=…&lng=…&at=…: the expected traffic at a point and time, with its main factors.GET /traffic/analysed/week: a week of hourly expectations for a place.GET /traffic/analysed/grid?bbox=…&at=…: a coloured grid for a view.GET /traffic/analysed/outlook: the next hours.
These are area-level answers, ideal for "usually busy at 8 am" messages. For a specific road or route use the tiles, segments, /traffic/route or /routing/plan with a departureTime. See Analysed traffic.
Travel modes
| Mode | costing | How traffic affects it | What else is timed |
|---|---|---|---|
| Car | auto | In full | Street speeds, junctions, turns and traffic lights |
| Truck | truck | In full | Truck speed limits, slower climbs and careful descents, wider and slower turns. Send vehicle dimensions and weight to keep off restricted roads. |
| Motorcycle | motorcycle | Partly: it passes queues | Reaches the front at traffic lights, so waits less |
| Scooter | motor_scooter | Partly | Scooter speeds, slower on steep climbs |
| Bicycle | bicycle | Hardly | Rider effort: hills matter, rough surfaces are slower, red lights still apply |
| Walking | pedestrian | Not at all | Walking pace on the real slope, stairs, and the wait to cross busy roads at busy hours |
| Wheelchair | wheelchair | Not at all | A gentler pace, slopes weigh much more, step-free paths, longer crossings |
| Public transport | POST /transit/plan | Buses ride in traffic | Walk to the stop, the usual wait, the ride, the walk to the destination |
GET /routing/profiles lists the profiles this deployment offers and whether each is available. Every endpoint in this guide accepts the same costing values (the raw endpoints use the engine names, such as pedestrian with a wheelchair option).
Road signs, closures and borders
- No-entry signs are followed by direction: a street is not entered from the end a sign closes, you can still leave it the other way, and a destination on such a street is reached from its open end. This holds for motor modes on every routing endpoint, including matrices, isochrones and optimised tours. Walking and cycling are not bound by it.
- Turn bans (no left turn, no right turn, no U-turn) are followed on
/routing/planand/routing/route. - Closures, restrictions and confirmed incidents are routed around on
/routing/plan(see itsroadEditConstraints,incidentConstraintsandreportedConstraints). SetavoidIncidents: falseoravoidReported: falseto opt out of community reports. - A sign never makes a route fail: when no clean route exists the best route is returned and
signRules.remainingsays so. A rider'sdisregardlist switches individual signs off. - Borders. Routes across national borders are not offered until crossings are verified. An in-country route is always preferred; when every route crosses, the request fails with
422 BORDER_CROSSING_UNAVAILABLEanddetails.crossing: { from, to }. Plan a cross-border journey in two parts, up to the border and on from the other side.
Freshness and caching
| Data | Refreshed | Cache in your app |
|---|---|---|
| Traffic tiles | Each 5-minute slot | One URL per slot (t rounded to 5 minutes); the server allows 5 minutes with t, 60 seconds without |
| Road network traffic used by routes, matrices and isochrones | About every 15 minutes; measured roads every 2 minutes | Do not cache a route's ETA for long; re-plan or use a navigation session |
| Matrix answers with traffic | Server cache up to 10 minutes | Ask again for fresh traffic; cache: false forces a recompute |
GET /traffic/summary | On request | Refresh with the map view, at most once a minute |
| Analysed traffic | Fitted daily | Cache for an hour |
Two calls a few minutes apart can return slightly different times. That is traffic changing, not an error.
Errors and edge cases
| Status / field | Meaning | What to do |
|---|---|---|
available: false | The routing service did not answer this time | Retry with backoff; keep the last answer on screen |
400 | Invalid body (bad coordinates, unknown option) | Fix the request; message and details say what is wrong |
401 / 403 | Missing key, or a key without the scope or not allowed for this site or app | Check the key, its scopes and its restrictions |
422 BORDER_CROSSING_UNAVAILABLE | Every route crosses a national border | Plan in two parts |
422 DESTINATION_OUT_OF_COVERAGE | A location is outside the routable network (on /routing/plan) | Ask the user to pick a point on a road; or send allowOutOfCoverage: true knowingly |
Matrix status other than ok | That pair has no duration | Read reason; other pairs still answer |
signRules.remaining > 0 | No route avoided every sign | Show the route; optionally warn |
traffic.applied: false in a matrix | Durations are for light traffic | Show traffic.message |
429 | Rate limit for your key | Back off; batch with the matrix instead of many single routes |
Contributing traffic data
Measured traffic comes from trips. If your app has its own location stream (delivery drivers, ride-hail, fleets), sending it improves traffic for everyone, including your own ETAs.
POST /telemetry/batchessends a trip while it happens, in small batches of 2–600 points with time, position, accuracy, speed and heading (scopetelemetry). Each answer says what was measured. Trips feed aggregate traffic only; a road is shown as measured only when at least three independent contributors drove it, and individual trips are never exposed.- Navigation sessions contribute automatically.
- Data owners with their own road measurements can supply them with
POST /traffic/imports.
See Telemetry and Supplying your own traffic measurements. Tell your users how their location is used, in your own privacy notice.
Checklist and FAQ
Integration checklist
- Restricted API key with only the scopes you use
- Traffic layer: one tile URL per 5-minute slot, labels kept above traffic, minor roads from zoom 15
- Route drawn above traffic, wider and with a white edge; traffic lighter while a route is shown
- Camera framed once per new route, clear of your panels; refreshes never move the user's map
- Evidence shown with labels (measured / typical / expected), never "live" for typical or expected
- ETA from
trip.summary.time(oreta.recommended), neverstatic_time -
includeLabels: falseon interactive directions -
routeIdpassed to navigation sessions - Matrix for many trips instead of many single routes
-
available: falsehandled with retry and the last answer kept -
422border and coverage errors shown with clear text - Arabic labels used for Arabic users (every label ships in both languages)
FAQ
Why is the ETA longer than static_time? static_time is the routing graph's own figure, close to speed limits with almost no junction time. The ETA adds real street speeds, traffic and the time lost at junctions and lights.
Why did the ETA change between two calls? Traffic changes, and the network's traffic is refreshed every few minutes. A route planned for "now" at 07:55 and at 08:05 meets different traffic.
Why does a walking route ignore traffic? Traffic does not slow walking. It does lengthen waits to cross busy roads, which walking times include.
Why doesn't the route take the shortest street? That street may be closed by a no-entry sign in your direction, or the slower option once junctions and traffic are counted. signRules and travelTime.chosenFor say which.
Is "Expected" traffic real? It is Navvo's expected traffic for that road and time, from the time of day, the calendar, the place and the road. It is labelled as expected so it is never mistaken for a measurement. Where people have recently driven, the road shows as measured instead.
Can I get traffic for tomorrow morning? Yes: tiles with t, routes and matrices with departureTime, segments with at, and analysed traffic for any time.
Which countries are covered? The Middle East markets Navvo serves. A location outside the routable network is reported, never silently snapped to a distant road.
Endpoint map
| Task | Endpoint | Scope |
|---|---|---|
| Traffic layer | GET /traffic/tiles/{z}/{x}/{y}.mvt | traffic |
| Moving cars for a 3D map | GET /traffic/cars/tiles/14/{x}/{y}, GET /traffic/cars, GET /traffic/cars/positions | traffic |
| Traffic in a view | GET /traffic/summary?bbox=… | traffic |
| One road | GET /traffic/segments/{ref} | traffic |
| Route coloured by traffic | POST /traffic/route | routing + traffic |
| Directions (recommended) | POST /routing/plan | routing |
| Directions, engine format | POST /routing/route | routing |
| Many origins × destinations | POST /routing/matrix, /routing/matrix/jobs | routing |
| Reachable area | POST /routing/isochrone | routing |
| Best stop order | POST /routing/optimize | routing |
| Fleet routing | POST /optimize/routes | optimize |
| Turn-by-turn | POST /navigation/sessions, wss://…/navigation/sessions/{id}/live | routing |
| Snap a GPS trace | POST /routing/map-match | routing |
| Speed limits along a route | POST /routing/route-attributes | routing |
| Public transport | POST /transit/plan | routing |
| Usual traffic for planning | GET /traffic/analysed* | traffic |
| Contribute trips | POST /telemetry/batches | telemetry |
Full field-by-field reference: Routing · Traffic · Navigation · Navigation WebSocket · Route optimization · Telemetry · Transit