Skip to main content

POST /get_dist_matrix

OpenAPI Specification

2GIS Navigation API (6.0.0)

Algorithms

Getting information about travel distance and time between points.

Getting information about travel distance and time between points.

query Parameters
key
required
string

Developer API key

version
required
string
Default: "2.0"

API version

response_format
string
Default: "json"
Enum: "protobuf" "json"

Response format:

Request Body schema: */*
required

Request parameters

required
Array of objects (RequestPoint) non-empty

An array of points.

sources
required
Array of integers non-empty [ items >= 0 ]

Which points from the points array are starting points (array of indexes).

targets
required
Array of integers non-empty [ items >= 0 ]

Which points from the points array are end points (array of indexes).

string or null

Date and time to use instead of the current date and time. Specified in RFC 3339 format (e.g., 2020-05-15T15:52:01Z).

transport
string
Default: "driving"
Enum: "driving" "taxi" "truck" "walking" "bicycle" "scooter" "motorcycle"

Routing type:

  • driving - car route,
  • taxi - car route (including public transport lanes),
  • truck - сargo transport,
  • walking - walking route,
  • bicycle - bicycle route,
  • scooter - scooter route,
  • motorcycle - motorcycle route,

type
string
Default: "jam"
Enum: "jam" "statistics" "shortest"

Route type:

  • jam - shortest route in time using current traffic data,
  • statistics - shortest route in time using statistical traffic data,
  • shortest - shortest route in distance,

Array of RequestFilter (strings) or RequestFilter (string) or null
boolean or null

If true, the route may include driving on closed roads.

Array of objects (ExcludeObject)

An array of areas to avoid when building a route. Not more than 25 areas.

TruckParams (object) or null
number or null

Average speed limit, km/h

pass_zone_pass_ids
Array of integers
Default: []

Identifier of a pass for a zone (array of numbers).

boolean or null

If true, altitude information will be included in the response.

Responses

Response Schema: application/json
Array of RoutesItem (objects) or null

An array of found routes. For each successive pair of points, there is exactly one route.Thus, in the case of P-P, there will be one route here, but in general there will be N-1 routes for N points.

Any of
Array
status
required
string (StatusType)
Enum: "FAIL" "OK" "POINT_EXCLUDED" "ROUTE_NOT_FOUND" "ROUTE_DOES_NOT_EXISTS" "ATTRACT_FAIL"

Request status:

  • FAIL - an unknown error occurred when calculating the route,
  • OK - route was successfully built,
  • POINT_EXCLUDED - one of the points was excluded by the excluded objects,
  • ROUTE_NOT_FOUND - the route could not be build on the current data of the road graph,
  • ROUTE_DOES_NOT_EXISTS - the route between points on the road graph doesn't exist,
  • ATTRACT_FAIL - an error occurred while attracting the points: one of the points is more than 10 km away from the road graph,

source_id
required
integer >= 0

Index of the starting point (from the points array)

target_id
required
integer >= 0

Index of the end point (from the points array)

distance
required
integer >= 0

Route length in meters

duration
required
integer >= 0

Estimated travel time in seconds

number or null <double>

Accuracy of the route as a number from 0 to 1 (if distance_direction was set)

boolean or null

If true, the route includes closed roads.

AltitudesInfo (object) or null

Response samples

Content type
application/json
{
  • "routes": [
    • {
      }
    ]
}