Skip to main content

Overview

API availability

Pairs Directions API is only available in particular deployment options.

Pairs Directions API allows you to build multiple routes in a single call. For each route you can get its length, travel time, and geometry.

Each route can only consist of two points: departure and arrival.

Pairs Directions API supports the following types of routes:

  • car routes
  • car routes including public transport lanes (taxi routes)
  • pedestrian routes
  • bicycle routes

Request example​

To get route information, send a POST request to the /get_pairs/1.0/{routing_type} endpoint, where routing_type is the required type of route:

  • driving - car route
  • walking - pedestrian route
  • taxi - car route that includes public transport lanes
  • bicycle - bicycle route

Specify your API key as the key parameter in the query string.

https://routing.api.2gis.com/get_pairs/1.0/driving?key=API_KEY

Coordinates for the route and other parameters must be sent as a JSON string in the request body.

In the simplest case, the JSON object may contain only three fields:

  • points - an array of routes. Each object in the array must contain four fields: the latitude and longitude of the point of departure (lat1 and lon1) and the latitude and longitude of the point of arrival (lat2 and lon2).
  • type - route type (the optimal route taking traffic into account or just the shortest route between the points).
  • output - output format (simplified or full).
curl --request POST \
--url 'https://routing.api.2gis.com/get_pairs/1.0/driving?key=API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"points": [
{
"lon1": 82.933328,
"lat1": 55.102268,
"lon2": 82.958722,
"lat2": 55.032594
}
],
"type": "jam",
"output": "simple"
}'

You can use additional parameters to exclude specific areas and road types from the route. For more information on route types and additional parameters, see Directions API.

Response example​

The request will return information about each route, including the route length in meters (distance) and travel time in seconds (duration). If you specify the full output format ("output": "full"), the request will also return the full geometry of the route.

[
{
"lon1": 82.933328,
"lat1": 55.102268,
"lon2": 82.958722,
"lat2": 55.032594,
"distance": 11146,
"duration": 1509,
"status": "OK"
}
]

Deployment options​

  • Cloud-based: Pairs Directions API methods are not available. To send routing requests to 2GIS public endpoints, use Routing API.
  • On-Premise: Pairs Directions API is used as a utility service required for the operation of other navigation APIs in a private network and not intended for standalone use. For more information, see the API Platform for server.