Routing
💻 Purpose of the API
The Routeplanner Routing API calculates routes between two or more locations for a variety of transport modes, including car, truck, pedestrian, bicycle, scooter, and electric vehicle. It returns detailed route information including travel time, distance, turn-by-turn instructions, the route geometry as an encoded polyline, and notices about road restrictions or conditions.
Use it to:
- Calculate the fastest or shortest route between an origin and destination
- Plan multi-stop routes with intermediate waypoints
- Generate turn-by-turn navigation instructions
- Calculate truck routes respecting physical and load restrictions
- Avoid specific road features, areas, or environmental zones
- Obtain the route polyline for display on a map (e.g. via the Mapview API)
🤔 How to use?
Base URL
https://api.company.info/routeplanner/routing
Authentication
All requests require an API key passed as a request header:
X-API-Key: YOUR_API_KEY
GET /routes
GET /routesCalculate a route between an origin and a destination, with optional intermediate stops.
Required parameters
| Parameter | Description |
|---|---|
transportMode | The mode of transport for the route calculation |
origin | The starting point of the trip |
destination | The end point of the trip |
Transport modes
| Mode | Notes |
|---|---|
car | Standard passenger car routing |
truck | Heavy vehicle routing — respects weight, height, width, length, and hazardous goods restrictions |
pedestrian | Walking route |
bicycle | Cycling route. Only supports fast routing mode |
scooter | Scooter routing. Only supports fast routing mode. Highway usage disabled by default |
taxi | ⚠️ Alpha — behaviour may change without warning |
bus | ⚠️ Alpha — behaviour may change without warning |
Waypoint format
Origin, destination, and via waypoints all use the same format:
{lat},{lng}[;placeOption=value][!waypointOption=value]
Place options (separated by ;) control how the router interprets the location:
| Option | Description |
|---|---|
course | Direction of travel in degrees clockwise from north (e.g. 90 = east). Useful for GPS coordinates of moving vehicles |
sideOfStreetHint | A second coordinate indicating which side of the street to prefer. Required when matchSideOfStreet=always |
matchSideOfStreet | always or onlyIfDivided (default). Controls how strictly the side-of-street hint is applied |
nameHint | A name to help the router select the correct road when multiple options exist at the same coordinate |
radius | Search radius in meters (max 200) — considers all locations within this radius as candidates |
minCourseDistance | Minimum distance in meters before the first routing action. Useful for moving vehicles where early turns are impractical |
Waypoint options (separated by !) control stop behaviour:
| Option | Supported on | Description |
|---|---|---|
stopDuration | destination, via | Planned stop duration in seconds at this waypoint |
passThrough | via only | If true, the router passes through without stopping or splitting the route into sections |
Examples:
# Simple coordinate
52.3676,4.9041
# Avoid ending up on wrong side of a divided road
52.531052,13.384872;sideOfStreetHint=52.530941,13.384939;matchSideOfStreet=always
# Moving vehicle with uncertain GPS position
51.611571,11.351608;course=170;radius=20;minCourseDistance=500
# Via stop with a 10-minute dwell time
51.611571,11.351608!stopDuration=600
# Pass-through waypoint (no stop, no section split)
51.611571,11.351608!passThrough=true
Multi-stop routes
To add intermediate stops, use one or more via parameters. The route will visit each stop in the order specified.
/routes?transportMode=car
&origin=52.3676,4.9041
&via=52.0907,5.1214
&via=51.9244,4.4777
&destination=51.5048,3.8598
Routing mode
| Value | Description |
|---|---|
fast (default) | Optimise for travel time. May prefer highways even when a shortcut through side roads is technically faster |
short | Optimise for distance. Does not necessarily return the absolute shortest path — turns are penalised to keep the route sensible |
bicycle,bus,pedestrian,scooter, andtaximodes only supportfast.
Departure time
Use departureTime to account for time-dependent traffic and schedules.
| Value | Behaviour |
|---|---|
ISO 8601 datetime (e.g. 2024-06-01T09:00:00) | Calculate route for this specific departure time |
any | Ignore time — calculate as if traffic conditions don't apply |
| (not specified) | Use current time at departure location |
Avoiding road features and areas
Use avoid to exclude certain road types or geographic areas. This is a soft preference — if no alternative exists, the router may still use the avoided feature and will note this in the response.
Avoid road features:
avoid[features]=tollRoad,tunnel,ferry
Available features: seasonalClosure, tollRoad, controlledAccessHighway, ferry, carShuttleTrain, tunnel, dirtRoad, difficultTurns
Avoid a geographic bounding box:
avoid[areas]=bbox:4.728,52.278,5.079,52.431
Avoid multiple areas (use | as separator):
avoid[areas]=bbox:4.728,52.278,5.079,52.431|bbox:4.832,52.352,4.901,52.401
Avoid environmental or congestion zones:
avoid[zoneCategories]=environmental
avoid[zoneCategories]=congestionPricing,vignette
If the origin or destination is located within an avoided area, the router will still produce a route but will try to minimise how much of the avoided area is used.
What to include in the response (return)
return)By default the response includes basic route information. Use return to opt into additional data:
| Value | What it adds |
|---|---|
polyline | The route geometry as an encoded Flexible Polyline string |
summary | Duration and distance per section |
actions | Maneuvers required to complete the route. Requires polyline |
instructions | Human-readable turn instructions. Requires actions |
turnByTurnActions | Full turn-by-turn guidance data. Requires polyline |
elevation | Altitude information in coordinates and geometry |
incidents | Traffic incidents affecting the route |
routeHandle | An encoded handle that can be used to retrieve this route later via /routes/{routeHandle} |
routingZones | Environmental, congestion, or vignette zones the route passes through |
passthrough | Information about pass-through via waypoints |
mlDuration | ⚠️ Beta — ML-based duration estimate |
Example requesting polyline + instructions:
return=polyline,actions,instructions
actionsrequirespolyline.instructionsrequiresactions.turnByTurnActionsrequirespolyline.
Truck routing
When transportMode=truck, use the truck parameter group to specify vehicle characteristics. The router will automatically avoid roads with restrictions that the vehicle cannot comply with.
| Parameter | Unit | Description |
|---|---|---|
truck[grossWeight] | kg | Total vehicle weight including trailers and cargo |
truck[weightPerAxle] | kg | Weight per axle |
truck[height] | cm | Vehicle height |
truck[width] | cm | Vehicle width |
truck[length] | cm | Vehicle length |
truck[axleCount] | — | Total number of axles |
truck[type] | — | straight (rigid truck) or tractor (semi-truck) |
truck[trailerCount] | — | Number of trailers |
truck[tunnelCategory] | — | ADR tunnel category: B, C, D, or E |
truck[shippedHazardousGoods] | — | Comma-separated list of hazardous materials carried |
Hazardous goods values: explosive, gas, flammable, combustible, organic, poison, radioactive, corrosive, poisonousInhalation, harmfulToWater, other
Example:
transportMode=truck
&truck[grossWeight]=20000
&truck[height]=400
&truck[length]=1600
&truck[shippedHazardousGoods]=flammable,gas
Alternative routes
Request up to 6 alternative routes alongside the primary route:
alternatives=3
Other parameters
| Parameter | Default | Description |
|---|---|---|
routingMode | fast | fast or short |
alternatives | 0 | Number of alternative routes (max 6) |
units | metric | Units for instructions: metric or imperial |
lang | en-US | Language for instructions (BCP 47) |
spans | — | Additional per-segment attributes in the response (requires polyline in return) |
X-Request-ID | — | Optional request identifier for logging and error tracing |
Example request
Calculate a car route from Amsterdam to Rotterdam with polyline and instructions:
curl --request GET \
--url 'https://api.company.info/routeplanner/routing/routes?transportMode=car&origin=52.3676,4.9041&destination=51.9244,4.4777&routingMode=fast&return=polyline,actions,instructions&lang=en-US' \
--header 'X-API-Key: YOUR_API_KEY'Example response
{
"routes": [
{
"id": "1793a897-0843-4957-ab63-c61e0f13aff2",
"sections": [
{
"id": "c3e300ab-a880-4fab-9bb2-702355b2bf6b",
"type": "vehicle",
"departure": {
"time": "2024-06-01T09:00:00+02:00",
"place": {
"type": "place",
"location": { "lat": 52.3676, "lng": 4.9041 }
}
},
"arrival": {
"time": "2024-06-01T09:48:00+02:00",
"place": {
"type": "place",
"location": { "lat": 51.9244, "lng": 4.4777 }
}
},
"summary": {
"duration": 2880,
"length": 76000
},
"polyline": "BG2znmkDi89wZ...",
"actions": [
{
"action": "depart",
"duration": 120,
"instruction": "Head south on Damrak. Go for 500 m.",
"offset": 0
},
{
"action": "arrive",
"duration": 0,
"instruction": "Arrive at your destination.",
"offset": 892
}
],
"transport": {
"mode": "car"
}
}
]
}
]
}Understanding the response
Routes and sections
A route consists of one or more sections. With a direct trip (no via stops), there is typically one section. Each via stop with stopDuration > 0 creates a new section. Pass-through waypoints (passThrough=true) do not split the route into sections.
summary
Contains duration (seconds) and length (meters) for the section.
polyline
The route geometry in Flexible Polyline encoding. Pass this directly to the Mapview API to render the route as a map image.
actions
A list of maneuvers in sequence. Each action has a type (e.g. depart, arrive, turn, roundaboutExit), a duration, an instruction string, and an offset indicating its position in the polyline.
Notices
If the route violates a restriction (e.g. a truck route passes a weight-restricted bridge), a notice is included in the response with a severity of critical or warning. Always check for notices in truck routing use cases.
GET /routes/{routeHandle} ⚠️ Alpha
GET /routes/{routeHandle} ⚠️ AlphaRetrieve and decode a previously calculated route using a route handle.
A route handle is returned when routeHandle is included in the return parameter of a /routes request. It encodes the calculated route so it can be retrieved later without recalculating.
This endpoint is in Alpha state and subject to breaking changes. The handle is only valid as long as the service uses the same map data version as when the route was originally calculated.
Not supported on this endpoint: origin, destination, via, alternatives, routingMode — these are encoded in the handle from the original calculation.
⚠️ Possible errors
| HTTP Status | When it occurs | What to do |
|---|---|---|
400 Bad Request | Invalid parameter values (e.g. unknown transportMode, alternatives exceeding max) | Check parameter values match the accepted formats and ranges |
401 Unauthorized | Missing or invalid API key | Verify the X-API-Key header is present and correct |
403 Forbidden | Calculating routes in a region your credentials do not cover | Contact support to extend geographic permissions |
500 Internal Server Error | Unexpected server-side issue | Retry after a short delay; contact support if it persists |
Route calculation errors (e.g. origin could not be matched) are not returned as HTTP errors — they appear as notices in the200response withseverity: critical.
🛠️ Try it yourself!
Test the API directly in our API reference.
🔤 Glossary
Section A continuous segment of a route. A route with no via stops has one section. Each stopping via waypoint adds a new section.
Polyline The route geometry encoded as a Flexible Polyline string. Can be passed to the Mapview API to render the route as a static map image.
Route handle An encoded string representing a previously calculated route. Allows the route to be retrieved later without recalculation, as long as the underlying map data has not changed.
Notice
A message in the route response indicating that a restriction or condition applies. A critical notice means the route violates a hard restriction (e.g. a truck weight limit). A warning means a softer condition was encountered.
Pass-through waypoint A via waypoint that the route passes through without stopping, without splitting into a new section, and without requiring a direction change.
ADR tunnel category
A European classification (B, C, D, E) specifying which hazardous goods are permitted in which tunnels. Required for truck routing with hazardous cargo.
Flexible Polyline A compact encoding format for sequences of geographic coordinates. See the Mapview API documentation for details on how to use the polyline to render a route image.
❓ FAQ
How do I get turn-by-turn instructions?
Add return=polyline,actions,instructions to your request. Instructions require actions, and actions require polyline — all three must be requested together.
Can I calculate a route with multiple stops?
Yes, use one or more via parameters between origin and destination. The route will visit each via stop in the order specified.
What is the difference between via with stopDuration and passThrough?
A via with stopDuration creates a real stop — the route pauses there for the specified time and the trip is split into separate sections. A passThrough via simply constrains the route to pass through that point without stopping or creating a new section.
Why does my truck route include a restricted road?
If no alternative exists, the router will include the restricted road and include a notice with severity: critical in the response. Always check for notices in truck routing applications.
How do I render the route on a map?
Request return=polyline and pass the returned polyline string to the Routeplanner Mapview API (GET /route?polyline=...).
What happens if the origin cannot be matched to a road?
The route calculation fails but the API still returns HTTP 200. The failure is communicated as a notice with code: couldNotMatchOrigin and severity: critical in the response. Check for notices before consuming route data.
Can I save a route and retrieve it later?
Yes, include routeHandle in the return parameter. Store the returned handle and use GET /routes/{routeHandle} to retrieve the route later. Note that handles are invalidated when the underlying map data is updated.
Which transport modes support alternative routes?
All modes support alternatives, but note that bicycle, bus, pedestrian, scooter, and taxi only support fast routing mode, which may limit the variety of alternatives returned.
Updated about 2 hours ago
