POST /v1/distance/batch

Batch Distance API for consecutive stops and mileage

Send an ordered list of points — a rep’s check-ins, a driver’s stops — and get the road distance and drive time for every consecutive leg plus the totals, in one request.

Request and response

Copy, paste and run with your test key. The response below is an illustrative 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
}

What the Batch Distance API gives you

  • N points, N − 1 legs

    Each consecutive pair is routed independently, so the result matches how the trip was driven.

  • Totals included

    total_distance_meters and total_duration_seconds (plus miles with units=imperial) for reimbursement reports.

  • Per-leg status

    A single unroutable leg returns NO_ROUTE without failing the batch.

  • Billed per pair

    Units charged = number of pairs (points − 1).

Built for mileage reimbursement

Group check-ins by day in the employee’s time zone, send each day as one batch and store the per-leg results with the map version for audit trails. Our guide shows the full pattern.

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.

Why not use the matrix endpoint for consecutive stops?

A matrix computes every origin-destination combination, so 10 stops would cost 100 elements. The batch endpoint computes only the 9 consecutive legs you need.

Start building in minutes

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