Skip to content
GuidesPlaygroundDashboard

Calculate a distance matrix between points

POST/api/v1/matrix

Calculate a distance matrix between points

Body ParametersJSONExpand Collapse
destinations: GeoJsonGeometry { coordinates, type }

Destination points (GeoJSON MultiPoint geometry)

coordinates: array of number or array of array of number or array of array of array of number or array of array of array of array of number

GeoJSON coordinates array (nesting depth varies by geometry type)

One of the following:
array of number
array of array of number
array of array of array of number
array of array of array of array of number
type: "Point" or "LineString" or "Polygon" or 3 more
One of the following:
"Point"
"LineString"
"Polygon"
"MultiPoint"
"MultiLineString"
"MultiPolygon"
origins: GeoJsonGeometry { coordinates, type }

Origin points (GeoJSON MultiPoint geometry)

coordinates: array of number or array of array of number or array of array of array of number or array of array of array of array of number

GeoJSON coordinates array (nesting depth varies by geometry type)

One of the following:
array of number
array of array of number
array of array of array of number
array of array of array of array of number
type: "Point" or "LineString" or "Polygon" or 3 more
One of the following:
"Point"
"LineString"
"Polygon"
"MultiPoint"
"MultiLineString"
"MultiPolygon"
mode: optional "auto" or "foot" or "bicycle"

Travel mode

One of the following:
"auto"
"foot"
"bicycle"
ReturnsExpand Collapse
MatrixResult = object { distances, durations }
distances: array of array of number

Distance matrix (meters), origins x destinations

durations: array of array of number

Duration matrix (seconds), origins x destinations

Calculate a distance matrix between points

curl https://plaza.fyi/api/v1/matrix \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $PLAZA_API_KEY" \
    -d '{
          "destinations": {
            "coordinates": [
              0
            ],
            "type": "Point"
          },
          "origins": {
            "coordinates": [
              0
            ],
            "type": "Point"
          }
        }'
{
  "distances": [
    [
      0
    ]
  ],
  "durations": [
    [
      0
    ]
  ]
}
Returns Examples
{
  "distances": [
    [
      0
    ]
  ],
  "durations": [
    [
      0
    ]
  ]
}