Geocoder
Turn an address into map locations, and a location back into an address.
The geocoder converts between addresses and coordinates. geocoder/search_address takes an address and returns the locations that match it, most relevant first. geocoder/search_location takes a coordinate pair and returns the address at that point.
The two directions overlap in one place: a q value that is two decimal numbers separated by a comma, such as 37.825014,-122.372020, is read as a coordinate pair, so geocoder/search_address performs a reverse lookup instead and returns a single result. Both numbers must carry a decimal point for that to happen.
Each request names the provider it wants in its geocoder parameter. Accounts with premium GIS always use Google, whatever the request asks for.
API actions
API base path: /geocoder.
Operations that list no errors of their own return only the general error codes.
Forward geocoding: return the locations matching an address, most relevant first.
A coordinate pair in q is handled as reverse geocoding instead. When q is two decimal numbers separated by a comma, such as 37.825014,-122.372020, it is read as latitude and longitude and the address at that point is returned as a single result. Both numbers must carry a decimal point for this to trigger.
Returns error 210 when nothing matches.
Either a user session hash or an API key, with the "NVX " prefix, for example "NVX 22eac1c27af4be7b9d04da2ce1af111b". Obtain a session hash from the userAuth operation, or create an API key from the API keys operations. A small number of operations accept a session hash only and reject an API key with error code 4; each says so in its description.
Address, place name, or a lat,lng coordinate pair. Trimmed of surrounding whitespace and cannot be empty.
Optional. Preferred geocoder. Accounts with premium GIS always use Google regardless of this value.
Optional. ISO 639 language code for the result, at most 5 characters, for example en or en_US. Defaults to the session language.
Optional. Default false. Include the parsed details object in the response.
Matching locations
true if request finished successfully.
trueBad request. The response body carries the API-level error code in status.code. Validation failures also include an errors array naming each offending parameter.
Error 210: no location matched the query.
Error response object
POST /v2/geocoder/search_address HTTP/1.1
Host: api.eu.navixy.com
Authorization: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 123
{
"q": "text",
"geocoder": "google",
"bounds": {
"nw": {
"lat": 1,
"lng": 1
},
"se": {
"lat": 1,
"lng": 1
}
},
"lang": "text",
"with_details": true
}{
"success": true,
"locations": [
{
"lat": 1,
"lng": 1,
"address": "text",
"details": {
"country": "text",
"province": "text",
"locality": "text",
"street": "text",
"house": "text",
"postcode": "text",
"bounds": {
"nw": {
"lat": 1,
"lng": 1
},
"se": {
"lat": 1,
"lng": 1
}
}
}
}
]
}Errors
These errors come in addition to the general error codes:
210 - No location matched the query.
Reverse geocoding: return the address at a coordinate pair.
The point may be given either as the location object or as separate top-level lat and lng parameters. location wins if both are present.
Either a user session hash or an API key, with the "NVX " prefix, for example "NVX 22eac1c27af4be7b9d04da2ce1af111b". Obtain a session hash from the userAuth operation, or create an API key from the API keys operations. A small number of operations accept a session hash only and reject an API key with error code 4; each says so in its description.
Latitude. Use with lng instead of location.
Longitude. Use with lat instead of location.
Optional. Preferred geocoder. Accounts with premium GIS always use Google regardless of this value.
Optional. ISO 639 language code for the result, at most 5 characters, for example en or en_US. Defaults to the session language.
Optional. Default false. Include the parsed details object in the response.
Optional. Default ui. What the lookup is for, which decides the geocoder chosen. Use ui_user_action for a lookup a user asked for directly, ui otherwise. An unrecognised value is silently treated as ui.
The address
true if request finished successfully.
trueThe address at the point.
Bad request. The response body carries the API-level error code in status.code. Validation failures also include an errors array naming each offending parameter.
Error response object
POST /v2/geocoder/search_location HTTP/1.1
Host: api.eu.navixy.com
Authorization: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 112
{
"location": {
"lat": 1,
"lng": 1
},
"lat": 1,
"lng": 1,
"geocoder": "google",
"lang": "text",
"with_details": true,
"goal": "ui"
}{
"success": true,
"value": "text",
"details": {
"country": "text",
"province": "text",
"locality": "text",
"street": "text",
"house": "text",
"postcode": "text",
"bounds": {
"nw": {
"lat": 1,
"lng": 1
},
"se": {
"lat": 1,
"lng": 1
}
}
}
}Last updated
Was this helpful?