Get Distance and Route
Calculate the distance and draw the shortest route between the coordinates in the order
HTTP Request
- cURL
- JavaScript
curl -X GET \
'https://ep.ahamove.com/routing/{profile}/route/v1/driving/{coordinates}'\
-H 'api-key: {apiKey}'
var myHeaders = new Headers();
myHeaders.append('api-key', '{apiKey}');
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow',
};
fetch(
'https://ep.ahamove.com/routing/{profile}/route/v1/driving/{coordinates}',
requestOptions
)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log('error', error));
GET https://ep.ahamove.com/routing/{profile}/route/v1/driving/{coordinates}
Header
Key | Value |
---|---|
api-key | The apiKey that partners received from team Onwheel of Ahamove |
Query Parameters
Parameter | Type | Required | Description |
---|---|---|---|
profile | String | Yes | car or bike . Type of vehicle |
coordinates | String | Yes | The longitude, latitude of the pick-up and drop-off points with the format: lng[0],lat[0];lng[1],lat[1]; ... |
Sample Request
curl -X GET \
'https://ep.ahamove.com/routing/bike/route/v1/driving/106.662262,10.955419;106.692807,10.791757'\
-H 'api-key: {apiKey}'
Response
Status-Code: 200 OK
JSON response example:
{
"code": "Ok",
"routes": [ # An array of Route objects
{
"geometry": "ovzaA{l_jS}{@og@pXal@hn@aIjj@_kAjTaHoFuEhK_Z~~Aik@lmA`J~jAwP|Ggv@~uAy^zg@oYfKdDrbAcg@vLt\\`UcFbrAhf@te@rAp`@jXz_A{@hu@`Hjb@dU~cAOrLvUnu@~q@yGlHTvR",
"legs": [
{
"steps": [],
"summary": "",
"weight": 6578.4,
"duration": 6578.4,
"distance": 26292.8
}
],
"weight_name": "duration",
"weight": 6578.4,
"duration": 6578.4, # Estimated time to complete the route (in seconds)
"distance": 26292.8
}
],
"waypoints": [ # Array of Waypoint objects representing all waypoints in order
{
"hint": "BIoJgFJvbIA_AAAAEAEAACEAAAAAAAAAOSbTQbZ24kJHwF5BAAAAAD8AAAAQAQAAIQAAAAAAAAA6AgAAsIhbBrEqpwB2iVsGmyqnAAEArwsk0y4r",
"distance": 21.777153493,
"name": "Võ Minh Đức",
"location": [
106.662064,
10.955441
]
},
{
"hint": "KCUJgP___3-0AAAAIgEAAAAAAAAAAAAAGipIQqSN80EAAAAAAAAAALQAAAAiAQAAAAAAAAAAAAA6AgAAygBcBharpADHAFwGTaukAAAAvxAk0y4r",
"distance": 6.092561625,
"name": "Đường Nguyễn Phi Khanh",
"location": [
106.69281,
10.791702
]
}
]
}
Errors
Code | Text | Description |
---|---|---|
400 | Bad Request | - Query string malformed - Number of coordinates needs to be at least two |
401 | Unauthorized | Invalid authentication credentials, api-key not found |
404 | Not Found | Profile not found |
500 | Internal Server Error | We had a problem with our server. Try again later. |