Documentation menu
Search docs…⌘K

API reference

Consecutive distance calculation across an ordered sequence of points

Computes road distance and duration for each consecutive leg in an ordered sequence of waypoints. Units charged equals the number of pairs (N - 1).

Endpoint

POSThttps://api.wayline.cloud/v1/distance/batch
Bearer Auth

Requires an API key (authentication). Product overview: Batch Distance API. Billing: see units & pricing.

Request body

JSON object (BatchDistanceRequest). Points accept "lat,lng" strings, {lat, lng} objects or [lat, lng] arrays.

Request body fields
FieldTypeDescription
pointsrequiredPoint[]Ordered sequence of points.
profilestringOne of: car, driving, motorcycle, bike, motorbike, two_wheeler, bicycle, cyclingDefault: car
unitsstringOne of: metric, imperialDefault: metric

Example

curl -X POST "https://api.wayline.cloud/v1/distance/batch" \
  -H "Authorization: Bearer $WAYLINE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"points":[{"lat":37.788,"lng":-122.4075},{"lat":37.8313,"lng":-122.2852},{"lat":37.8716,"lng":-122.2727},{"lat":37.9358,"lng":-122.3478}],"units":"imperial"}'
Response (example)
{
  "request_id": "req_01JD8Q6C9T4P",
  "legs": [
    {
      "from_index": 0,
      "to_index": 1,
      "distance_meters": 6120,
      "duration_seconds": 840,
      "status": "OK"
    },
    {
      "from_index": 1,
      "to_index": 2,
      "distance_meters": 3010,
      "duration_seconds": 420,
      "status": "OK"
    },
    {
      "from_index": 2,
      "to_index": 3,
      "distance_meters": 12840,
      "duration_seconds": 1080,
      "status": "OK"
    }
  ],
  "total_distance_meters": 21970,
  "total_duration_seconds": 2340,
  "region": "us",
  "map_version": "20261121-2330",
  "units_charged": 3
}

Response

200 — Successful batch distance response.

Response fields
FieldTypeDescription
legsrequiredBatchLeg[]
legs[].from_indexrequiredinteger
legs[].to_indexrequiredinteger
legs[].distance_metersinteger
legs[].duration_secondsinteger
legs[].distance_milesnumber
legs[].distance_textstring
legs[].duration_textstring
legs[].statusrequiredstringOne of: OK, NO_ROUTE
total_distance_metersrequiredinteger
total_duration_secondsrequiredinteger
total_distance_milesnumber
total_distance_textstring
total_duration_textstring
profilerequiredstringCanonical routing profile used (car, motorcycle or bicycle).
regionrequiredstring
map_versionrequiredstring
warningsstring[]
units_chargedrequiredinteger

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

StatusWhen
400Bad request (invalid coordinates, out of coverage, too many elements, etc.).
401Missing or invalid API key, or expired key.
402Free 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.
403Account disabled, key IP restriction failed, origin not allowed, or scope not permitted.
429Rate limit exceeded or test key daily quota reached.
500Internal server error.
503Upstream routing service temporarily unavailable.

Error bodies contain a code such as OUT_OF_COVERAGE — see the error reference.

Try it

Interactive API Console

POST /v1/distance/batch

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.

Was this page helpful?