Skip to main content

Overview

Distance Matrix API returns an N×N matrix of driving times (seconds) and distances (meters) in a single request, powered by the 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

Service options

Unlike the array-encoded general options, sources and destinations may contain fewer entries than the number of input coordinates. With skip_waypoints=true, both arrays are skipped in the response.

General options

These options apply to all routing services. Options that take one value per coordinate use the array-like encoding {option}={element};{element}[;...] — the number of elements must match the number of coordinates (except generate_hints and exclude). Pass an empty element to use the default for that coordinate, e.g. bearings=;90,20;.

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.

Errors

See Errors for the full list.

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