Setting routes for the day
At the beginning of each work day, the delivery company should upload information about routes and orders to the Track & Trace database. The generated route is automatically sent to the Yandex Courier app. The order of delivery addresses in the route is automatically optimized using data about delivery times and the traffic forecast.
Building routes
In the API, routes are assigned to courier on a specific date.
Send a request to the routes-batch resource. The request must provide order information.
routes-batch
resource, fill out the required fields when sending a request to the routes resource.Request
cURL
curl -H "Content-Type: application/json" -H "Authorization: Auth your-token" -X POST -d @<File_path_in_UTF-8_encoding> https://courier.yandex.ru/api/v1/companies/your-company-id/routes-batch
Copied to clipboard
File
[ { "courier_number":"222", "number":"23423-2000", "date": "2017-08-08", "depot_number":"111" }, { "courier_number":"224", "number":"23423-2001", "date": "2017-08-08", "depot_number":"112" } ]
Copied to clipboard
cURL
curl -H "Content-Type: application/json" -H "Authorization: Auth your-OAuth-token" -X POST -d '[{"courier_number":"222", "number":"23423-2000", "date": "2017-08-08", "depot_number":"111"}, {"courier_number":"224", "number":"23423-2001", "date": "2017-08-08", "depot_number":"112"}]' https://courier.yandex.ru/api/v1/companies/your-company-id/routes-batch
Copied to clipboard
Result:
{
"inserted": 2,
"updated": 0
}
Adding orders to the database
Orders in the API are assigned to a route. Route orders are arranged in the order they were added. If necessary, you can change their sequence by sending a request to the orders-sequence resource.
Send a request to the orders-batch resource. The request must provide order information.
orders-batch
resource, fill out the required fields when sending a request to the orders resource.Request
cURL
curl -H "Content-Type: application/json" -H "Authorization: Auth your-token" -X POST -d @<File_path_in_UTF-8_encoding> https://courier.yandex.ru/api/v1/companies/{your-company-id}/orders-batch
Copied to clipboard
File
[ { "number":"222239", "route_number":"23423-2000", "address":"ul. Lva Tolstogo, 16", "lat": 55.7447, "lon": 37.6728, "customer_name": "Igor", "phone": "+712345678", "status":"new", "time_interval":"11-12" }, { "number":"222241", "route_number":"23423-2001", "address":"ul. Lva Tolstogo, 17", "lat": 55.7448, "lon": 37.6729, "customer_name": "Olga", "phone": "+712345679", "status":"new", "time_interval":"10:00 - 11:00" } ]
Copied to clipboard
cURL
curl -H "Content-Type: application/json" -H "Authorization: Auth your-OAuth-token" -X POST -d '[{"number":"222239", "route_number":"23423-2000", "address":"Ulitsa Lva Tolstogo 16", "lat": 55.7447, "lon": 37.6728, "customer_name": "Igor", "phone": "+712345678", "status":"new", "time_interval":"11-12"}, {"number":"222241", "route_number":"23423-2001", "address":"Ulitsa Lva Tolstogo 17", "lat": 55.7448, "lon": 37.6729, "customer_name": "Olga", "phone": "+712345679", "status":"new", "time_interval":"10:00 - 11:00"}]' https://courier.yandex.ru/api/v1/companies/your-company-id/orders-batch
Copied to clipboard
Result:
{
"inserted": 2,
"updated": 0
}
Checking uploaded data
To check if data was uploaded successfully, send a request to the verification resource. The server response contains information about all orders for the specified date. You can compare the information you receive with the information in the delivery company database.
curl -H "Authorization: Auth your-OAuth-token" -X GET https://courier.yandex.ru/api/v1/companies/your-company-id/verification?date=2018-01-01
Copied to clipboard
Result:
[
{
"order_id": "20170513-713",
"time_interval": "12-23",
"route_number": "23423-2000",
"courier_id": "your-courier-number",
"status": "finished",
"phone": "+712345678",
"address": "Ulitsa Lva Tolstogo 16",
"lat": 55.7448,
"lon": 37.6729
},
{
"order_id": "20170513-329",
"time_interval": "12-52",
"route_number": "23423-2001",
"courier_id": "8272",
"status": "finished",
"phone": "+712345679",
"address": "Ulitsa Lva Tolstogo 17",
"lat": 55.7448,
"lon": 37.6729
}
]