GET /v1/distance

Distance API for real road distance and drive time

Send an origin and a destination, get back driving distance in meters and miles and an estimated drive time — computed on the actual road network, in milliseconds.

Request and response

Copy, paste and run with your test key. The response below is an illustrative example.
curl "https://api.wayline.cloud/v1/distance?origin=37.788,-122.4075&destination=37.8044,-122.2712&units=imperial" \
  -H "Authorization: Bearer $WAYLINE_API_KEY"
Response (example)
{
  "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
}

What the Distance API gives you

  • Road network, not straight lines

    Distances follow real roads from OpenStreetMap with a car profile, including one-way streets and turn restrictions.

  • Meters, miles and readable text

    Pass units=imperial for distance_miles plus ready-to-display strings like “6.5 mi” and “23 mins”.

  • Snapping you can see

    Each endpoint returns the snapped road location and how far it moved, so you can flag bad GPS fixes.

  • One unit per request

    A successful call costs one unit. Errors (4xx/5xx) are never billed, and cache hits cost the same as fresh results.

How the Distance API works

Wayline finds the region that contains both points, snaps each coordinate to the nearest drivable road and runs a shortest-time route on the Wayline routing engine. The response includes distance_meters, duration_seconds, the snapped locations, the region and the exact map version used, so results are reproducible and auditable.

Accepted coordinate formats

Coordinates use Google’s lat,lng order. GET requests take origin=23.7925,90.4078 strings; the POST variant also accepts {"lat":…, "lng":…} objects or [lat, lng] arrays.

Frequently asked questions

Is the distance a straight line or a real road distance?

Always real road distance. Every result is computed along the OpenStreetMap road network with a driving profile, never as a straight-line (haversine) estimate.

Which areas do you cover?

Coverage is region-based. The Coverage page lists every enabled region with its map data date. Points outside an enabled region return an OUT_OF_COVERAGE error and are never billed.

Does the drive time include live traffic?

Not yet. Drive times are free-flow estimates based on road types and speed data in OpenStreetMap. Traffic-aware ETAs are on the roadmap; we will announce them in the changelog.

How fast is a distance request?

Most of the time is spent in the routing engine for your region, and identical requests are served from cache. We will publish measured latency with our benchmark methodology rather than quoting unverified numbers.

Start building in minutes

Create an account, grab a test key and make your first request in under five minutes.