Optimizing routes
API call to get optimized order of route checkpoints.
To reduce transit time and costs, it may be helpful to rearrange route checkpoints so that the total travel time between them is minimized. Our platform offers a way to perform this optimization. You don't even need to create a route and checkpoints; you simply provide the necessary data for optimization, and the algorithm returns the order in which the points should be visited.
API actions
API path: /task/route/points/optimize.
optimize
The suggested order for the given route points will correspond to the time windows (from and to) of each point. Points with earlier time windows will have lower ordinal numbers. If time windows overlap, the order of such points may vary to maximize the overall efficiency of the route. The maximum distance per route optimization is 5000 kilometers. When using APIs, the maximum number of points per route optimization is 49 points to visit, plus 1 start point.
required sub-user rights: task_update.
Parameters
start_point - (object) the coordinates of the location from where the performer will depart. The departure time is optional parameter.
{
"lat": 15.233,
"lng": -5.554,
"departure": "2024-03-19 13:30:00"
}route_points - (array of objects) the points that the performer must visit, and the count of points must be within the range of 2 to 49. For example:
[
{"location": {"lat": 11.111, "lng": 11.111}, "from": "2024-03-19 00:00:00", "to": "2024-03-19 23:59:00"},
{"location": {"lat": 22.222, "lng": -2.222}, "from": "2024-03-19 00:00:00", "to": "2024-03-19 23:59:00"},
{"location": {"lat": -3.333, "lng": 33.333}, "from": "2024-03-19 00:00:00", "to": "2024-03-19 23:59:00"},
{"location": {"lat": -4.444, "lng": -4.444}, "from": "2024-03-19 00:00:00", "to": "2024-03-19 23:59:00"},
{"location": {"lat": 55.555, "lng": 55.555}, "from": "2024-03-19 00:00:00", "to": "2024-03-19 23:59:00"}
]Response
The result will return the order in which the points should be visited.
If for route points:
this action returns: [2, 0, 1]
it means "change points order as following":
or with a more tangible example with 5 points. You have the next points to be reordered
The API request will be
cURL
The platform will reply to you with:
So the optimized route with start point from "lat": 38.81476676765485, "lng": -77.1608018875122 should be:
Errors
7 - Invalid parameters.
210 - Path distance exceeds the max distance limit - if the overal route distance is more than 5000 km.
264 - Timeout not reached - too high api call rate.
Last updated
Was this helpful?