Сервис DistanceMatrix API позволяет рассчитать параметры попарных маршрутов между многими точками на карте, с учётом текущей ситуации на дорогах, а также прогноза на заданное время. С помощью сервиса можно найти все точки, которые достижимы из пункта назначения за определённое время, и использовать эту информацию для решения транспортных задач. Можно получить информацию для всех комбинаций пунктов отправления и назначения. Максимально допустимое количество точек для расчёта — 100.
При расчёте маршрута учитывается статистическая информация по пробкам — для каждого сегмента маршрута между двумя точками посещения, с момента въезда в сегмент маршрута.
Для авторизации ключ API указывается в качестве значения параметра Api-Key заголовка запроса.
Ограничения устанавливаются для ключа: максимальное количество запросов в минуту, в день. Для построения одного маршрута можно указать до 100 точек.
Сервисы TSP API, DistanceMatrixAPI, IsochronesAP пока доступны только для карты Российской Федерации.
Для создания задачи на построение матрицы сегментов (дистанций) маршрута нужно отправить POST-запрос /calculateDistanceMatrix.
URL: https://webmapapi.navitel.ru/api/v1/calculateDistanceMatrix/
Координаты точек маршрута и другие параметры передаются в виде JSON в теле запроса.
| Параметр | Описание | Обязательно/ Опционально | Тип данных | Формат данных |
| points | Массив координат точек | required | array [сoordi-nates] | |
| sources | Массив индексов, показывающий, какие точки из массива points являются отправными (стартовыми) точками | required | array [integer] | int64 |
| targets | Массив индексов, показывающий, какие точки из массива points являются конечными (финишными) точками | required | array [integer] | int64 |
| start_time | Время отправления. Если не задано, будет использоваться текущее время | optional | string example: 2025-02-28T15:30:00Z | date-time |
| vehicle_type | Вид транспортного средства. Возможные варианты: • car – машина, • truck – самосвал, • heavy_truck – фура, • van – фургон, • bicycle – велосипед, • pedestrian – пешеход. | optional | string enum: [car, truck, heavy_truck, van, bicycle, pedestrian] | |
| mz_pass | Наличие у водителей грузовых транспортных средств пропусков в зоны Московской кольцевой автомобильной дороги (МКАД), Третьего транспортного кольца (ТТК), Садового кольца (СК). | optional | object {MzPass} – см. Типы данных ниже | |
| jams | Учитывать ли при построении маршрута информацию о текущих дорожных пробках. Значение по умолчанию: false | optional | boolean | |
| optimization | Тип оптимизации маршрута: • по времени: fastest – самый быстрый; • по расстоянию: • shortest – кратчайший. Значение по умолчанию: fastest | optional | string enum: [fastest, shortest] |
| Код ответа | Параметр | Тип данных | Описание |
| 200 | routes | object {DMRoute} – 0. | Построенный маршрут между указанными точками |
| 200 | calculation_time_ms | integer (int64) | Расчётное время, в миллисекундах |
| 200 | road_lookup_time_ms | integer (int64) | Время поиска ближайшей дороги к точкам маршрута, в миллисекундах |
| 200 | matrix_build_time_ms | integer (int64) | Время построения матрицы маршрутов, в миллисекундах |
| 400 | code | string enum: [bad_points, no_route, too_many_points, inva-lid_time] | Неверный запрос. Возможные варианты code: • bad_points – точки находятся за пределами карты, • no_route – маршрут не может быть построен, • too_many_points – количество точек превышает допустимое значение, • invalid_time – неверное время отправления |
| 400 | message | string | Неверный запрос. Возможные варианты code: • bad_points – точки находятся за пределами карты, • no_route – маршрут не может быть построен, • too_many_points – количество точек превышает допустимое значение, • invalid_time – неверное время отправления |
| 401 | Ключ API отсутствует или недействителен | ||
| 403 | Истёк срок действия ключа API, превышены пределы поиска | ||
| 500 | Внутренняя ошибка сервера |
Сoordinates – координаты точки
| Параметр | Описание | Обязательно/ Опционально | Тип данных | Формат данных |
| longitude | Долгота | required | number | double |
| latitude | Широта | required | number | double |
DMRoute – матрица дистанций маршрута
| Параметр | Описание | Обязательно/ Опционально | Тип данных | Формат данных |
| source_pt | Индекс начальной (стартовой) точки (из массива точек) | optional | object {PointIndex} – см. Типы данных для DistanceMatrix API | int64 |
| target_pt | Индекс конечной (финишной) точки (из массива точек) | optional | object {PointIndex} – см. Типы данных для DistanceMatrix API | int64 |
| source_road_pt | Точка дороги, ближайшая к начальной (стартовой) точке) | optional | object {Coordinates} | |
| target_road_pt | Точка дороги, ближайшая к конечной (финишной) точке | optional | object {Coordinates} | |
| distance_m | Длина маршрута, в метрах | optional | integer | int32 |
| duration_sec | Расчётное время в пути, в секундах | optional | integer | int32 |
| restrictions | Ограничения, используемые при построении матрицы дистанций маршрута | optional | array [DMRouteRestriction] | |
| status | Статус построения матрицы дистанций маршрута | optional | object {DMRouteStatus} |
PointIndex – индекс точки из массива точек
| Параметр | Описание | Обязательно/ Опционально | Тип данных | Формат данных |
| point | Точка маршрута из массива точек | optional | object {Coordinates} | int32 |
| index | Индекс точки маршрута из массива точек | optional | integer | int32 |
DMRouteRestriction – ограничения при построении матрицы дистанций маршрута
| Параметр | Описание | Обязательно/ Опционально | Тип данных | Формат данных |
| Ограничения, используемые при построении дистанций маршрута. Возможные варианты: • toll_road – платная дорога, • ferry – паром, • dirt_road – грунтовая дорога, • highways – шоссе | optional | string enum: [toll_road, ferry, dirt_road, highways] |
DMRouteStatus – статус построения матрицы дистанций маршрута
| Параметр | Описание | Обязательно/ Опционально | Тип данных | Формат данных |
| code | Код. Возможные варианты code: • route_ok – маршрут был успешно проложен/построен; • route_not_exist – данные точки не связаны дорожной сетью; • route_fail – при расчёте маршрута произошла неизвестная ошибка; • lookup_fail – одна из точек находится более чем в 10 км от дорожной сети | optional | string enum: [route_ok, route_not_exist, route_fail, lookup_fail] | |
| message | Сообщение | optional | string |
MzPass – наличие пропуска в зоны МКАД, ТТК, СК
| Параметр | Описание | Обязательно/ Опционально | Тип данных | Формат данных |
| mkad | Наличие пропуска в зону Московской кольцевой автодороги (МКАД). Значение по умолчанию: false | optional | boolean | |
| ttk | Наличие пропуска в зону Третьего транпортного кольца (ТТК). Значение по умолчанию: false | optional | boolean | |
| sk | Наличие пропуска в зону Садового кольца (СК). Значение по умолчанию: false | optional | boolean |
Запрос
Тело ответа
The service allows you to calculate the parameters of paired routes between many points on the map, taking into account the current situation on the roads, as well as the forecast for a given time. Using the service, you can find all points that are reachable from your destination within a certain time, and use this information to solve transport problems. Information can be obtained for all combinations of points of departure and destination. The maximum allowed number of points for calculation is 100.
When calculating the route, statistical information on traffic jams is taken into account – for each route segment between two visiting points, from the moment of entering the route segment.
For authorization, the API key is specified as the value of the Api-Key parameter of the request header.
Limits are set for the key: the maximum number of requests per minute, per day. To build one route, you can specify up to 100 points.
TSP API, DistanceMatrixAPI, IsochronesAP services are currently available only for the Russian Federation.
To create a task to build a matrix of route segments (distances), you need to send a POST request / cal-culateDistanceMatrix.
URL: https://webmapapi.navitel.ru/api/v1/calculateDistanceMatrix/
Waypoint coordinates and other parameters are sent as JSON in the body of the request.
| Parameter | Description | Required/ Optional | Data type | Data Format |
| points | Array of coordinates of points | required | array [сoordinates] | |
| sources | An array of indexes showing which points from the points array are the starting points | required | array [integer] | int64 |
| targets | An array of indexes showing which points from the points array are the end (finish) points | required | array [integer] | int64 |
| start_time | Departure time. If not specified, the current time will be used | optional | string example: 2025-02-28T15:30:00Z | date-time |
| vehicle_type | Type of vehicle. Possible options:
| optional | string enum: [car, truck, heavy_truck, van, bicycle, pedestrian] | |
| mz_pass | Drivers of freight vehicles must have passes to the Moscow Ring Road (MKAD), Third Transport Ring (TTK), and Garden Ring (GR) zones | optional | object {MzPass} – see Data types below | |
| jams | To take into account or not when planning a route information about current traffic jams. Default value: false | optional | boolean | |
| optimization | Type of route optimization:
| optional | string enum: [fastest, shortest] |
| Response Code | Parameter | Data type | Description |
| 200 | routes | object {DMRoute} – please refer to Data types for DistanceMatrix API | The route built between the specified points |
| 200 | calculation_time_ms | integer (int64) | Estimated time, in milliseconds |
| 200 | road_lookup_time_ms | integer (int64) | Time to search for the road closest to the route points, in milliseconds |
| 200 | matrix_build_time_ms | integer (int64) | The time to build the route matrix, in milliseconds |
| 400 | code | string enum: [bad_points, no_route, too_many_points, invalid_time] | Invalid request. Possible code options: • bad_points – points are outside the map; • no_route – the route cannot be built; • too_many_points – the number of points exceeds the allowed value; • invalid_time – incorrect departure time |
| 400 | message | string | Invalid request. Possible code options: • bad_points – points are outside the map; • no_route – the route cannot be built; • too_many_points – the number of points exceeds the allowed value; • invalid_time – incorrect departure time |
| 401 | The API key is missing or invalid | ||
| 403 | API key has expired and search limits have been exceeded | ||
| 500 | Internal server error |
Coordinates – point coordinates
| Parameter | Description | Required/ Optional | Data type | Data Format |
| longitude | Longitude | required | number | double |
| latitude | Latitude | required | number | double |
DMRoute — matrix of route distances
| Parameter | Description | Required/ Optional | Data type | Data Format |
| source_pt | Index of the initial (starting) point (from an array of points) | optional | object {PointIndex} – see Data types for DistanceMatrix API | int64 |
| target_pt | Index of the final (finish) point (from an array of points) | optional | object {PointIndex} – see Data types for DistanceMatrix API | int64 |
| source_road_pt | The point of the road closest to the starting point | optional | object {Сoordinates} | |
| target_road_pt | The point of the road closest to the final (finish) point | optional | object {Сoordinates} | |
| distance_m | Route length, in meters | optional | integer | int32 |
| duration_sec | Estimated travel time, in seconds | optional | integer | int32 |
| restrictions | Restrictions used in constructing the route distance matrix | optional | array [DMRouteRestriction] | |
| status | Status of the route distance matrix construction | optional | object {DMRouteStatus} |
PointIndex — the index of a point from an array of points
| Parameter | Description | Required/ Optional | Data type | Data Format |
| point | Route point from an array of points | optional | object {Сoordinates} | int32 |
| index | Index of a waypoint from an array of points | optional | integer | int32 |
DMRouteRestriction – restrictions used in constructing the route distance matrix
| Parameter | Description | Required/ Optional | Data type | Data Format |
| Restrictions used when building route distances. Possible options: • toll_road; • ferry; • dirt_road; • highways | optional | string enum: [toll_road, ferry, dirt_road, highways] |
DMRouteStatus — status of the route distance matrix construction
| Parameter | Description | Required/ Optional | Data type | Data Format |
| code | Code. Possible code options: • route_ok – the route was successfully laid/built; • route_not_exist — these points are not connected by the road network; • route_fail — an unknown error occurred when calculating the route; • lookup_fail — one of the points is more than 10 km from the road network | optional | string enum: [route_ok, route_not_exist, route_fail, lookup_fail] | |
| message | Message | optional | string |
MzPass – availability of a pass to the MKAD, TTK, SK zones
| Parameter | Description | Required/ Optional | Data type | Data format |
|---|---|---|---|---|
| mkad | Availability of a pass to the Moscow Ring Road (MKAD) zone. Default value: false | optional | boolean | |
| ttk | Availability of a pass to the Third Transport Ring (TTK) zone. Default value: false | optional | boolean | |
| sk | Availability of a pass to the Garden Ring (GR) zone. Default value: false | optional | boolean |
Request
Response body