Skip to content
GuidesPlaygroundDashboard

Calculate a route between two points

client.routing.route(RoutingRouteParams { destination, origin, mode } body, RequestOptionsoptions?): RouteResult { geometry, properties, type }
POST/api/v1/route

Calculate a route between two points

ParametersExpand Collapse
body: RoutingRouteParams { destination, origin, mode }
destination: GeoJsonGeometry { coordinates, type }

Destination point (GeoJSON Point geometry)

coordinates: Array<number> | Array<Array<number>> | Array<Array<Array<number>>> | Array<Array<Array<Array<number>>>>

GeoJSON coordinates array (nesting depth varies by geometry type)

One of the following:
Array<number>
Array<Array<number>>
Array<Array<Array<number>>>
Array<Array<Array<Array<number>>>>
type: "Point" | "LineString" | "Polygon" | 3 more
One of the following:
"Point"
"LineString"
"Polygon"
"MultiPoint"
"MultiLineString"
"MultiPolygon"
origin: GeoJsonGeometry { coordinates, type }

Origin point (GeoJSON Point geometry)

coordinates: Array<number> | Array<Array<number>> | Array<Array<Array<number>>> | Array<Array<Array<Array<number>>>>

GeoJSON coordinates array (nesting depth varies by geometry type)

One of the following:
Array<number>
Array<Array<number>>
Array<Array<Array<number>>>
Array<Array<Array<Array<number>>>>
type: "Point" | "LineString" | "Polygon" | 3 more
One of the following:
"Point"
"LineString"
"Polygon"
"MultiPoint"
"MultiLineString"
"MultiPolygon"
mode?: "auto" | "foot" | "bicycle"
One of the following:
"auto"
"foot"
"bicycle"
ReturnsExpand Collapse
RouteResult { geometry, properties, type }
geometry: GeoJsonGeometry { coordinates, type }
coordinates: Array<number> | Array<Array<number>> | Array<Array<Array<number>>> | Array<Array<Array<Array<number>>>>

GeoJSON coordinates array (nesting depth varies by geometry type)

One of the following:
Array<number>
Array<Array<number>>
Array<Array<Array<number>>>
Array<Array<Array<Array<number>>>>
type: "Point" | "LineString" | "Polygon" | 3 more
One of the following:
"Point"
"LineString"
"Polygon"
"MultiPoint"
"MultiLineString"
"MultiPolygon"
properties: Properties { distance, duration, mode }
distance?: number

Total distance in meters

duration?: number

Estimated duration in seconds

mode?: string

Travel mode used

type: "Feature"

Calculate a route between two 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 routeResult = await client.routing.route({
  destination: { coordinates: [0], type: 'Point' },
  origin: { coordinates: [0], type: 'Point' },
});

console.log(routeResult.geometry);
Returns Examples