- Home
- Docs
- API reference
- Point-to-point road distance and travel time (JSON body)
API reference
Point-to-point road distance and travel time (JSON body)
POST alternative for distance calculation, allowing structured coordinates.
Endpoint
POST
Bearer Authhttps://api.wayline.cloud/v1/distanceRequires an API key (authentication). Product overview: Distance API (JSON body). Billing: see units & pricing.
Request body
JSON object (DistanceRequest). 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. |
profile | string | One of: car, driving, motorcycle, bike, motorbike, two_wheeler, bicycle, cyclingDefault: car |
units | string | One of: metric, imperialDefault: metric |
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). |
departure_time | string | Reserved for future traffic profiles. |
Example
curl -X POST "https://api.wayline.cloud/v1/distance" \
-H "Authorization: Bearer $WAYLINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"origin":"37.788,-122.4075","destination":"37.8044,-122.2712","units":"imperial"}'{
"request_id": "req_01JD8Q4ZK7V3",
"distance_meters": 19870,
"duration_seconds": 1260,
"distance_miles": 12.3,
"distance_text": "12.3 mi",
"duration_text": "21 mins",
"origin": {
"location": [
37.788,
-122.4075
],
"snapped": [
37.7881,
-122.4076
],
"distance_to_road_meters": 4
},
"destination": {
"location": [
37.8044,
-122.2712
],
"snapped": [
37.8045,
-122.2713
],
"distance_to_road_meters": 7
},
"snap_distance_meters": 7,
"region": "us",
"map_version": "20261121-2330",
"units_charged": 1
}Response
200 — Successful point-to-point distance response.
| Field | Type | Description |
|---|---|---|
distance_metersrequired | integer | Driving distance in meters along the road network. |
duration_secondsrequired | integer | Estimated driving time in seconds. |
distance_miles | number | Driving distance in miles (present when units=imperial). |
distance_text | string | Human-readable distance string (e.g. 3.4 mi or 5.5 km). |
duration_text | string | Human-readable duration string (e.g. 12 mins). |
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. |
snap_distance_metersrequired | integer | Maximum snapping distance among endpoints in meters. |
profilerequired | string | Canonical routing profile used (car, motorcycle or bicycle). |
regionrequired | string | Region code that handled the request. |
map_versionrequired | string | Version identifier of the map dataset used. |
warnings | string[] | Warning flags (e.g. POINT_FAR_FROM_ROAD, ROUTE_USES_FERRY). |
units_chargedrequired | integer | Number of billable request units consumed. |
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.