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 route is automatically sent to the Yandex Courier app. The route order is optimized based on delivery windows and the traffic forecast.
Use your company ID to access the Track & Trace API. If you don't have an ID, contact us.
Building routes
In the API, routes are assigned to couriers on a specific date.
Send a request to the routes-batch resource. The request must contain information about the orders.
To send API requests via Postman, you can use the RouteQ API collection.
The specification contains required fields for existing objects, but there are more fields for new objects. When you add new objects by sending a request to the routes-batch
resource, fill in all of the fields that are required for 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. Orders on the route 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 contain information about the orders.
The specification contains required fields for existing objects, but new objects require more fields to be filled out. When you add new objects by sending a request to the orders-batch
resource, fill in all of the fields that are required for 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":"476 5th Avenue", "lat": 73.9823, "lon": 40.7532, "customer_name": "Will", "phone": "+12125551234", "status":"new", "time_interval":"11-12" }, { "number":"222241", "route_number":"23423-2001", "address":"477 5th Avenue", "lat": 73.9824, "lon": 40.7534, "customer_name": "Ashley", "phone": "+12125551235", "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":"476 5th Avenue", "lat": 73.9823, "lon": 40.7532, "customer_name": "Will", "phone": "+12125551234", "status":"new", "time_interval":"11-12"}, {"number":"222241", "route_number":"23423-2001", "address":"477 5th Avenue", "lat": 55.7448, "lon": 37.6729, "customer_name": "Ashley", "phone": "+12125551235", "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's database.
Request
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": "+12125551234",
"address": "476 5th Avenue",
"lat": 73.9823,
"lon": 40.7532
},
{
"order_id": "20170513-329",
"time_interval": "12-52",
"route_number": "23423-2001",
"courier_id": "8272",
"status": "finished",
"phone": "+12125551235",
"address": "477 5th Avenue",
"lat": 73.9824,
"lon": 40.7533
}
]