Endpoints
Geocoding
One endpoint in two directions: a place name or address to coordinates (q), or coordinates to the nearest place (lat & lon).
Request
/v1/geocodeRequires an API key in the Authorization header. See Authentication.
Parameters
Parameters
qoptionalstringSukhbaatar Square or Сүхбаатарын талбай.limitoptionalinteger5. The response can hold fewer results when fewer places match.latoptionalnumberlonoptionalnumberExample
curl -G "https://developers.ubhub.mn/v1/geocode" \
--data-urlencode "q=Sukhbaatar Square" \
-d limit=5 \
-H "Authorization: Bearer YOUR_API_KEY"Response
{
"query": "Sukhbaatar",
"results": [
{
"id": "loc_3f2a9c1d8e7b6a50",
"name": "Sukhbaatar District",
"address": "7-р хороо, Сүхбаатар, Mongolia",
"latitude": 47.92662,
"longitude": 106.929681,
"type": "poi"
},
{
"id": "loc_9b1e4d7c2a6f3e81",
"name": "Sukhbaatar District General Hospital",
"address": "11-р хороо, Сүхбаатар, Mongolia",
"latitude": 47.931345,
"longitude": 106.928361,
"type": "poi"
}
],
"count": 2
}Response fields
querystringresultsarrayresults[].idstringresults[].namestringresults[].addressstring | nullresults[].latitudenumberresults[].longitudenumberresults[].typestringpoi for a point of interest, or place when no category is known.countintegerNo match is not an error: you get 200 OK with an empty list.
{
"query": "Nowhere Street",
"results": [],
"count": 0
}Ranking
Results are ordered by how well the name matches the query:
- Exact name matches.
- Names that start with the query.
- Names where every word of the query starts a word.
- Names that contain every word of the query.
Within each group, more prominent places come first, then shorter names.
Building autocomplete
AbortController signal to fetch), and do not search until the user has typed at least 2 characters.Reverse geocoding
Send lat and lon instead of q to turn a coordinate into the nearest meaningful place. The response is the same shape as a forward search, with one result: type is the match kind (address, place or street) and distance_meters is how far the match is from your point. Nothing found nearby is 200 OK with an empty results list, not an error. Send either q or both lat and lon, never both and never neither.
curl -G "https://developers.ubhub.mn/v1/geocode" \
-d lat=47.9184 \
-d lon=106.9177 \
-H "Authorization: Bearer YOUR_API_KEY"Errors
Errors
INVALID_REQUESTdetails.field names it. Also used with status 405 for a wrong HTTP method and 413 for an oversized body.INVALID_API_KEYdetails.reason is expired).API_KEY_REVOKEDENDPOINT_NOT_ALLOWEDdetails.allowed_endpoints lists them.REQUEST_TIMEOUTRATE_LIMIT_EXCEEDEDQUOTA_EXCEEDEDINTERNAL_ERRORUPSTREAM_ERRORSERVICE_UNAVAILABLESee Errors for the response format and how to handle each code.
Try it
Send a real request with one of your keys.
/v1/geocodePlaygroundRequest
curl "https://developers.ubhub.mn/v1/geocode?q=Sukhbaatar%20Square&limit=5" \ -H "Authorization: Bearer YOUR_API_KEY"
Response
Send a request to see the response.