Запросы осуществляются методом POST, все необходимые параметры передаются в формате JSON. Ответы формируются в формате JSON.
В запросе передаются координаты точек маршрута. В ответ приходят длина маршрута и время в пути. Все параметры запроса и ответа приведены в описании API.
Пример запроса
На видео представлен пример построения маршрута для грузового транспорта с учётом ограничений на габариты автомобиля.
This video shows an example of building a route for trucks avoiding the streets, where movement of such transport is prohibited.
To retrieve route data used in these video examples make a POST request to https://catalog.api.2gis.com/truck/6.0.0/global?key=YOUR_KEY
with Content-Type application/json.
The request takes the following parameters:
key=YOUR_KEY
— your API key.
{
"locale": "en",
"point_a_name": "Source",
"point_b_name": "Target",
"points": [
{
"type": "pedo",
"x": 37.604503,
"y": 55.763114
},
{
"object_id": "4504235282733728",
"type": "pedo",
"x": 37.607681,
"y": 55.766273
}
],
"type": "truck_jam"
}
Example of Response
[
{
"query": {
"locale": "en",
"point_a_name": "Source",
"point_b_name": "Target",
"points": [],
"type": "truck_jam"
},
"result": [
{
"algorithm": "including traffic jams",
"begin_pedestrian_path": {
"geometry": {}
},
"end_pedestrian_path": {
"geometry": {}
},
"requested_filters": "full",
"filter_road_types": [],
"id": "1805336109018823561",
"maneuvers": [],
"route_id": "em9.n3/carrouting/1588235082.031",
"total_distance": 15153,
"total_duration": 2204,
"type": "carrouting",
"ui_total_distance": {
"unit": "km",
"value": "15"
},
"ui_total_duration": "36 min",
"waypoints": [
{
"original_point": {
"lat": 54.94365877886301,
"lon": 82.93066878237848
},
"projected_point": {
"lat": 54.94365877886301,
"lon": 82.93066878237848
},
"transit": false
},
{
"original_point": {
"lat": 55.03387872014941,
"lon": 82.9446599530971
},
"projected_point": {
"lat": 55.03387872014941,
"lon": 82.9446599530971
},
"transit": false
}
]
}
],
"type": "string"
}
]