Endpoints
Routing
Calculate the fastest route between two points, with distance, estimated travel time and a GeoJSON line.
Request
GET
/v1/routeRequires an API key in the Authorization header.
Parameters
Parameters
originrequiredstringStart point as
longitude,latitude (GeoJSON order), for example 106.9177,47.9184.destinationrequiredstringEnd point as
longitude,latitude, for example 106.9057,47.9220.modeoptionalstringdriving (default) or walking.Longitude first
origin and destination put longitude before latitude, like GeoJSON. Swapping them usually gives a 400 error (latitude out of range) or a point in the wrong place.Example
curl -G "https://developers.ubhub.mn/v1/route" \
-d origin=106.9177,47.9184 \
-d destination=106.9057,47.9220 \
-d mode=driving \
-H "Authorization: Bearer YOUR_API_KEY"Response
{
"route": {
"distance_meters": 4200,
"duration_seconds": 620,
"geometry": {
"type": "LineString",
"coordinates": [
[
106.9177,
47.9184
],
[
106.9176,
47.918
],
[
106.911,
47.918
],
[
106.9057,
47.918
],
[
106.9057,
47.922
]
]
}
},
"mode": "driving",
"waypoints": [
{
"input": {
"latitude": 47.9184,
"longitude": 106.9177
},
"location": {
"latitude": 47.9184,
"longitude": 106.9176
},
"snap_distance_meters": 7.6,
"name": "Chingis Avenue"
},
{
"input": {
"latitude": 47.922,
"longitude": 106.9057
},
"location": {
"latitude": 47.922,
"longitude": 106.9057
},
"snap_distance_meters": 0.4,
"name": "Seoul Street"
}
]
}Response fields
route.distance_metersnumberLength of the route in meters.
route.duration_secondsnumberEstimated travel time in seconds.
route.geometryLineStringGeoJSON LineString.
coordinates are [longitude, latitude] pairs from origin to destination.modestringThe travel mode used.
waypointsarrayTwo entries, origin then destination, describing where each point joined the road network.
waypoints[].inputobjectThe coordinate you sent.
waypoints[].locationobjectThe point on the road network used instead.
waypoints[].snap_distance_metersnumberDistance between input and location.
waypoints[].namestring | nullName of the road at the snapped point.
Travel modes
Travel modes
drivingUses roads open to cars, respects one-way streets, and estimates time from road speeds.
walkingUses streets and footpaths, ignores one-way rules, avoids motorways, at about 5 km/h.
More modes may be added to /v1 later; adding a mode is not a breaking change.
Snapping to roads
- Origin and destination are moved to the nearest road the chosen mode can use.
waypointsshows where. - If no usable road is close enough to a point, the API answers
404 NOT_FOUNDwithdetails.reasonset toorigin_not_on_networkordestination_not_on_network. - Origin and destination must be within the maximum route distance for this deployment (100 km by default); otherwise you get
400 INVALID_REQUESTondestination.
Errors
{
"error": {
"code": "NOT_FOUND",
"message": "No driving route connects the origin and the destination.",
"details": {
"reason": "no_path"
}
}
}Errors
400
INVALID_REQUESTA parameter is missing or invalid.
details.field names it. Also used with status 405 for a wrong HTTP method and 413 for an oversized body.401
INVALID_API_KEYThe Authorization header is missing or malformed, the key does not exist, or it has expired (
details.reason is expired).403
API_KEY_REVOKEDThe key was revoked in the dashboard.
403
ENDPOINT_NOT_ALLOWEDThe key is not allowed to call this endpoint. Each key is limited to the endpoints chosen when it was created;
details.allowed_endpoints lists them.404
NOT_FOUNDNothing was found: no address near the point (reverse geocoding), no route or no road near a waypoint (routing,
details.reason explains), or an unknown path.408
REQUEST_TIMEOUTThe data service behind the API did not answer in time.
429
RATE_LIMIT_EXCEEDEDThe key used up its requests for the current one-minute window.
429
QUOTA_EXCEEDEDThe authenticated key or tenant used its daily or monthly cost-unit quota.
500
INTERNAL_ERRORAn unexpected error in the API.
502
UPSTREAM_ERRORThe data service behind the API failed or returned an invalid answer.
503
SERVICE_UNAVAILABLEThe service is temporarily unavailable, for example while a data source is being configured or loaded.
See Errors for how to handle each code.
Try it
GET
/v1/routePlaygroundRequest
GET /v1/route?origin=106.9177%2C47.9184&destination=106.9057%2C47.9220&mode=driving
curl "https://developers.ubhub.mn/v1/route?origin=106.9177%2C47.9184&destination=106.9057%2C47.9220&mode=driving" \ -H "Authorization: Bearer YOUR_API_KEY"
Response
Send a request to see the response.