Skip to content
GuidesBlogPlaygroundDashboard

Calculate a distance matrix between points

client.routing.matrix(RoutingMatrixParams { destinations, origins, annotations, 2 more } body, RequestOptionsoptions?): MatrixResult
POST/api/v1/matrix

Calculate a distance matrix between points

ParametersExpand Collapse
body: RoutingMatrixParams { destinations, origins, annotations, 2 more }
destinations: Array<Destination>

Array of destination coordinates (max 50)

lat: number

Latitude in decimal degrees (-90 to 90)

maximum90
minimum-90
lng: number

Longitude in decimal degrees (-180 to 180)

maximum180
minimum-180
origins: Array<Origin>

Array of origin coordinates (max 50)

lat: number

Latitude in decimal degrees (-90 to 90)

maximum90
minimum-90
lng: number

Longitude in decimal degrees (-180 to 180)

maximum180
minimum-180
annotations?: string

Comma-separated list of annotations to include: duration (always included), distance. Example: duration,distance.

fallback_speed?: number | null

Fallback speed in km/h for pairs where no route exists. When set, unreachable pairs get estimated values instead of null.

exclusiveMinimum
minimum0
mode?: "auto" | "foot" | "bicycle"

Travel mode (default: auto)

One of the following:
"auto"
"foot"
"bicycle"
ReturnsExpand Collapse
MatrixResult = Record<string, unknown>

Distance matrix result. The exact response shape depends on the routing backend. Contains duration (and optionally distance) data for all origin-destination pairs. Null values indicate unreachable pairs.

Calculate a distance matrix between points

import Plaza from '@plazafyi/sdk';

const client = new Plaza({
  apiKey: process.env['PLAZA_API_KEY'], // This is the default and can be omitted
});

const matrixResult = await client.routing.matrix({
  destinations: [{ lat: 48.8584, lng: 2.2945 }],
  origins: [
    { lat: 48.8566, lng: 2.3522 },
    { lat: 48.8606, lng: 2.3376 },
  ],
});

console.log(matrixResult);
{
  "foo": "bar"
}
Returns Examples
{
  "foo": "bar"
}