API not returning best route

Hi All,

Here is my route :

[
{
“address”: “Pickup - Edinburg”,
“lat”: “55.94329452685436”,
“lng”: “-3.189049056651948”
},
{
“address”: “Oxford”,
“lat”: “51.76348190311011”,
“lng”: “-1.2444539358993745”
},
{
“address”: “Mcr”,
“lat”: “53.519303408708986”,
“lng”: “-2.038725180641028”
}
]

The route am expecting from API “Pickup - Edinburg” → Mcr → Oxford

However am getting back
{
“id”: “2k0pThV5”,
“count”: 3,
“feasible”: true,
“route”: {
“0”: {
“name”: “Pickup - Edinburg”,
“arrival”: 0,
“distance”: 0
},
“1”: {
“name”: “Oxford”,
“arrival”: 371,
“distance”: 578.8
},
“2”: {
“name”: “Mcr”,
“arrival”: 544,
“distance”: 849.1
}
}
}

Please let me know what am missing?

Here is the endpoint am hitting: POST https://api.routexl.com/tour

As per our documentation, the API optimizes your locations between the first and the last elements in the locations array. So, the first location will always be the departure and will appear first in the output, but also the last location will be the final arrival and the last location in the output.

See: RouteXL API | RouteXL

In your case, with only three locations in the input, the first and last are Pickup and Mcr, and Oxford comes in between. If you wish to return to Pickup, you’ll need to add it twice, once at the beginning of the input and once again at the end.