Documentation menu
Search docs…⌘K

API reference

Many-to-many travel time and road distance matrix

Calculates road distances and durations between every origin and destination. Units charged equals `origins × destinations`.

Endpoint

POSThttps://api.wayline.cloud/v1/matrix
Bearer Auth

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

Request body

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

Request body fields
FieldTypeDescription
originsPoint[]
destinationsPoint[]
pointsPoint[]Alternative for symmetric N x N matrices.
metricsstringOne of: distance, duration, bothDefault: both
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/matrix" \
  -H "Authorization: Bearer $WAYLINE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"origins":[{"lat":37.788,"lng":-122.4075},{"lat":37.8313,"lng":-122.2852}],"destinations":[{"lat":37.8044,"lng":-122.2712},{"lat":37.8716,"lng":-122.2727},{"lat":37.9358,"lng":-122.3478}],"units":"imperial"}'
Response (example)
{
  "request_id": "req_01JD8Q7H3W8R",
  "rows": [
    {
      "elements": [
        {
          "distance_meters": 19870,
          "duration_seconds": 1260,
          "status": "OK"
        },
        {
          "distance_meters": 6120,
          "duration_seconds": 840,
          "status": "OK"
        },
        {
          "distance_meters": 14210,
          "duration_seconds": 1290,
          "status": "OK"
        }
      ]
    },
    {
      "elements": [
        {
          "distance_meters": 11880,
          "duration_seconds": 1500,
          "status": "OK"
        },
        {
          "distance_meters": 3010,
          "duration_seconds": 420,
          "status": "OK"
        },
        {
          "distance_meters": 12840,
          "duration_seconds": 1080,
          "status": "OK"
        }
      ]
    }
  ],
  "origins": [
    "…"
  ],
  "destinations": [
    "…"
  ],
  "region": "us",
  "map_version": "20261121-2330",
  "units_charged": 6
}

Response

200 — Successful matrix response.

Response fields
FieldTypeDescription
rowsrequiredMatrixRow[]
rows[].elementsrequiredMatrixElement[]
rows[].elements[].distance_metersinteger
rows[].elements[].duration_secondsinteger
rows[].elements[].distance_milesnumber
rows[].elements[].distance_textstring
rows[].elements[].duration_textstring
rows[].elements[].statusrequiredstringOne of: OK, NO_ROUTE
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/matrix

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?