Skip to main content

Distance Matrix API

Returns an N×N matrix of driving times (seconds) and distances (meters) in a single request, powered by the OSRM Table service. Ideal for nearest-store lookup, dispatch, and batch route planning.
Try it first? Switch the Live Demo to the Distance Matrix tab and drag the markers around.

Endpoint

Request Parameters

Quickstart

Response

response-example.json

Response fields

A null cell means no route exists between that pair — it is deliberately distinct from a real 0. The official SDKs preserve null instead of coercing it to 0.

Size limits

Exceeding the limit returns 400 TooBig. For large matrices: trim to the sub-matrix you need with sources/destinations, compute in batches, and cache the results — matrices are stable and rarely need real-time recomputation.

Recipes

  • Nearest store: sources=0 (the user) against destinations=all, pick the column with the smallest duration
  • Dispatch planning: feed the matrix into Fleet Optimization or your own VRP solver