Navigation | Pairs Directions API | Overview | Urbi Documentation
Pairs Directions APIdeprecated

Pairs Directions API

Pairs Directions API is deprecated. Use Routing API to build car, truck, bicycle, or pedestrian routes through one service.

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

To start using navigation services, get an access key for Routing API:

  1. Sign in to the Platform Manager.
  2. Create a demo key or purchase an access key for using API: see the Access keys instruction.
  3. See the Routing API documentation to start using the service.

To work with access keys, you can use the Platform Manager: see the Platform Manager section.

Note

Examples below are for the deprecated Pairs Directions API. If you have switched to Routing API, refer to the corresponding documentation.

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.

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"
    }
]