- Home
- Docs
- API reference
- Driving directions and full route geometry (JSON body)
API reference
Driving directions and full route geometry (JSON body)
Calculates optimal driving directions, turn-by-turn maneuvers, and geometries.
Endpoint
POST
Bearer Authhttps://api.wayline.cloud/v1/routeRequires an API key (authentication). Product overview: Routing API (JSON body). Billing: see units & pricing.
Request body
JSON object (RouteRequest). Points accept "lat,lng" strings, {lat, lng} objects or [lat, lng] arrays.
| Field | Type | Description |
|---|---|---|
originrequired | Point | Flexible coordinate input accepted as string, object, or array. |
destinationrequired | Point | Flexible coordinate input accepted as string, object, or array. |
waypoints | Point[] | Ordered intermediate waypoints. |
profile | string | One of: car, driving, motorcycle, bike, motorbike, two_wheeler, bicycle, cyclingDefault: car |
units | string | One of: metric, imperialDefault: metric |
alternatives | integer | Default: 0 |
geometry | string | One of: none, polyline, polyline6, geojsonDefault: polyline |
overview | string | Geometry detail. simplified keeps static map URLs short.One of: full, simplifiedDefault: full |
steps | boolean | Default: false |
annotations | boolean | Default: false |
origin_bearing | number | Angle in degrees [0, 360) pointing toward departure direction. |
origin_bearing_range | number | Default: 45 |
destination_bearing | number | Angle in degrees [0, 360) pointing toward arrival direction. |
destination_bearing_range | number | Default: 45 |
bearings | string | Semicolon-delimited bearing,range tokens (e.g. 90,45;180,45). |
origin_radius | number | Max road snapping search radius in meters. |
destination_radius | number | Max road snapping search radius in meters. |
radiuses | string | Semicolon-delimited road snapping search radiuses in meters (e.g. 25;50). |
origin_approach | string | One of: curb, unrestrictedDefault: unrestricted |
destination_approach | string | One of: curb, unrestrictedDefault: unrestricted |
approaches | string | Semicolon-delimited curb approach constraints (curb;curb). |
Example
curl -X POST "https://api.wayline.cloud/v1/route" \
-H "Authorization: Bearer $WAYLINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"origin":"37.788,-122.4075","destination":"37.8044,-122.2712","steps":true,"geometry":"polyline"}'{
"request_id": "req_01JD8Q5B2M1X",
"routes": [
{
"distance_meters": 19870,
"duration_seconds": 1260,
"geometry": "o~ywFdmbbMh@`@…",
"legs": [
{
"distance_meters": 19870,
"duration_seconds": 1260,
"summary": "",
"steps": [
"…"
]
}
]
}
],
"waypoints": [
{
"location": [
37.788,
-122.4075
],
"snapped": [
37.7881,
-122.4076
],
"distance_to_road_meters": 4
},
{
"location": [
37.8044,
-122.2712
],
"snapped": [
37.8045,
-122.2713
],
"distance_to_road_meters": 7
}
],
"region": "us",
"map_version": "20261121-2330",
"units_charged": 1
}Response
200 — Successful route directions response.
| Field | Type | Description |
|---|---|---|
routesrequired | Route[] | |
routes[].distance_metersrequired | integer | |
routes[].duration_secondsrequired | integer | |
routes[].distance_miles | number | |
routes[].distance_text | string | |
routes[].duration_text | string | |
routes[].geometry | any | Encoded polyline string or GeoJSON LineString object. |
routes[].legsrequired | RouteLeg[] | |
routes[].legs[].distance_metersrequired | integer | |
routes[].legs[].duration_secondsrequired | integer | |
routes[].legs[].distance_miles | number | |
routes[].legs[].distance_text | string | |
routes[].legs[].duration_text | string | |
routes[].legs[].summary | string | |
routes[].legs[].steps | RouteStep[] | |
originrequired | SnappedLocation | A requested coordinate and where it joined the road network. |
origin.latrequired | number | Requested latitude. |
origin.lngrequired | number | Requested longitude. |
origin.snapped | Point | Flexible coordinate input accepted as string, object, or array. |
destinationrequired | SnappedLocation | A requested coordinate and where it joined the road network. |
destination.latrequired | number | Requested latitude. |
destination.lngrequired | number | Requested longitude. |
destination.snapped | Point | Flexible coordinate input accepted as string, object, or array. |
profilerequired | string | Canonical routing profile used (car, motorcycle or bicycle). |
regionrequired | string | |
map_versionrequired | string | |
warnings | string[] | |
units_chargedrequired | integer |
Response headers
X-Request-Id— Unique identifier for tracking and debugging this request.X-RateLimit-Limit— Maximum permitted requests in current window.X-RateLimit-Remaining— Remaining request quota in current window.X-RateLimit-Reset— Seconds until the rate limit window resets.X-Units-Charged— Billable request units consumed by this request.X-Cache— Cache lookup status (`HIT` or `MISS`).X-Region— Region code serving this routing request (e.g. `bd`).
Errors
| Status | When |
|---|---|
400 | Bad request (invalid coordinates, out of coverage, too many elements, etc.). |
401 | Missing or invalid API key, or expired key. |
402 | Free quota exhausted, no payment method, account suspended, or the monthly spend limit you set was reached. Never billed. Raise or remove the limit in the dashboard (Billing) and retry; nothing else changes. |
403 | Account disabled, key IP restriction failed, origin not allowed, or scope not permitted. |
404 | No route found between the requested coordinates. |
429 | Rate limit exceeded or test key daily quota reached. |
500 | Internal server error. |
503 | Upstream routing service temporarily unavailable. |
Error bodies contain a code such as OUT_OF_COVERAGE — see the error reference.
Try it
Interactive API Console
Sends a real request from your browser using a test key (free, never billed). The key stays in this browser tab only.
No key yet? Create a free test key.