Reverse geocoding
Coordinates in, the nearest address out, or the locality, region or country if that is all you want.
Parameters
| Parameter | Type | Description |
|---|---|---|
latrequired | number | -90 to 90. |
lonrequired | number | -180 to 180. |
leveloptional | string | The most specific level to return: address (default), street, postcode, city, region, country. Coarser levels are faster and never fall below the requested level. |
radiusoptional | integer | Search radius in metres for addresses and streets, 1 to 5000. Default 5000. Set it small to get null instead of a far-away address. |
langoptional | string | ISO 639-1 code for the language of the response. Default en. The whole address comes back in that language: places, regions and countries by their own names in it, the street with its type and direction translated and its name written in the language's script by how it sounds. |
boundariesoptional | integer | Set to 1 to add a boundaries object with every Australian boundary the point falls in: suburb, local government area, ward, federal and state electoral division, statistical areas, Indigenous areas, postal area and, once the ABS publishes them for the current edition, remoteness and urban areas. Nothing is added outside Australia. |
timezone, elevation, wikidata, country_info, codes, sun, regions, districts, census, demographics, road, siteoptional | flag | Extra blocks, each added when its flag is 1, for example timezone=1&sun=1. All are off by default, so a plain lookup stays small and fast. See annotations. |
annotationsoptional | integer | 1 switches on every flag above at once. Default 0. |
keyoptional | string | API key, if not sent as a header. |
Example
$ curl -H "X-API-Key: YOUR_KEY" "https://api.mygeocode.com/v1/reverse?lat=41.8902&lon=12.4922&lang=it"const url = new URL("https://api.mygeocode.com/v1/reverse");
url.searchParams.set("lat", 41.8902);
url.searchParams.set("lon", 12.4922);
url.searchParams.set("lang", "it");
const { result } = await (await fetch(url, { headers: { "X-API-Key": "YOUR_KEY" } })).json();
console.log(result ? result.formatted : "nothing nearby");import requests
r = requests.get("https://api.mygeocode.com/v1/reverse",
params={"lat": 41.8902, "lon": 12.4922, "lang": "it"}, headers={"X-API-Key": "YOUR_KEY"}, timeout=10)
result = r.json()["result"]
print(result["formatted"] if result else "nothing nearby"){
"status": "ok",
"lat": 41.8902,
"lon": 12.4922,
"result": {
"formatted": "Piazza del Colosseo 23, 00118 Roma, Italia",
"lat": 41.891367,
"lon": 12.491512,
"distance_m": 142,
"type": "address",
"precision": "house",
"confidence": 0.7,
"place_id": "oHvVTPHTmCutza8QQ_Vz4W1M_PHkbXNzDA",
"components": {
"house_number": "23",
"road": "Piazza del Colosseo",
"city": "Roma",
"state": "Lazio",
"postcode": "00118",
"country": "Italia",
"country_code": "it"
},
"bounds": { "north": 41.891867, "south": 41.890869, "east": 12.492014, "west": 12.491015 },
"codes": {
"plus_code": "8FHJVFRR+GJ",
"geohash": "sr2yk604ckf3",
"mgrs": "33TTG9189240757",
"maidenhead": "JN61fv83",
"dms": {
"lat": "41° 53' 28.9\" N",
"lon": "12° 29' 29.4\" E"
},
"mapcode": "ITA HJ.PV",
"mapcode_international": "TJLFM.J2LH"
}
}
}Response fields
| Field | Type | Description |
|---|---|---|
lat, lon | number | The point you sent, echoed. |
result | object or null | null when nothing is within radius at the requested level. |
result.formatted | string | The address, or the locality name for coarser levels. |
result.lat, result.lon | number | The position of the returned feature, not your point. |
result.distance_m | integer | Metres from your point to result.lat, result.lon. |
result.type, result.precision, result.confidence, result.place_id, result.components, result.bounds, result.parcel, result.place, result.formatted_place | As in forward geocoding. | |
result.codes | object | The point as a plus code, geohash, MGRS reference and other location codes. Present for houses, streets and points of interest; for other results only with codes=1. See annotations. |
result.population | integer | For a city, region or country from our worldwide gazetteer: its population. |
result.timezone, elevation_m, wikidata, country_info, sun, regions, districts, census, demographics, road, intersection, site | object | Only when their flag is set, or with annotations=1. See annotations. |
boundaries | object | Only with boundaries=1 for a point in Australia: the boundaries listed under the parameter. |
Notes
- A large
distance_mis a signal. A point in a park may be 300 m from the nearest address; in that case showing the neighbourhood is usually better than showing the address. level=countryanswers in about a millisecond and is the cheapest way to answer "which country is this point in".- Points at sea return the nearest named place while one is a few tens of kilometres away (a
cityresult with a largedistance_m, or the country atcountrylevel), andnullfurther out at every level.
The same lookup in other providers' formats
If you already have code written against one of these providers, keep it: the drop-in host accepts the same path and parameters and answers in that provider's response shape, with this endpoint behind it. See how the drop-ins work.
| Provider | Host | Path |
|---|---|---|
| Google Maps Platform | gapi.mygeocode.com | /maps/api/geocode/json?latlng=lat,lng |
| Bing Maps REST Services | bing.mygeocode.com | /REST/v1/Locations/{lat},{lon} |
| HERE Geocoding and Search | here.mygeocode.com | /v1/revgeocode?at=lat,lng |
| Mapbox Geocoding | mapbox.mygeocode.com | /geocoding/v5/mapbox.places/{lon},{lat}.json/search/geocode/v6/reverse?longitude=...&latitude=... |
| Geocode.Farm | farm.mygeocode.com | /reverse/?lat=...&lon=.../v3/json/reverse/?lat=...&lon=... |
| OpenStreetMap Nominatim | osm.mygeocode.com | /reverse?lat=...&lon=...&format=json |
| OpenCage | opencage.mygeocode.com | /geocode/v1/json?q=lat,lng |
| LocationIQ | locationiq.mygeocode.com | /v1/reverse?lat=...&lon=...&format=json |
| Geoapify | geoapify.mygeocode.com | /v1/geocode/reverse?lat=...&lon=... |
| TomTom Search | tomtom.mygeocode.com | /search/2/reverseGeocode/{lat},{lon}.json |
| MapQuest Geocoding | mapquest.mygeocode.com | /geocoding/v1/reverse?location=lat,lng |
| Geocodio | geocodio.mygeocode.com | /v1.7/reverse?q=lat,lng |
| PositionStack | positionstack.mygeocode.com | /v1/reverse?query=lat,lng |
Bulk lookups
Post a JSON body to the same path with coords, an array of up to 100 [lat, lon] pairs, and the answer carries a results array with one entry per pair in the order sent. Each entry counts as one request, and a batch larger than what is left of the allowance is refused whole.
$ curl -X POST "https://api.mygeocode.com/v1/reverse" -H "Content-Type: application/json" -d '{"coords": [[52.5163, 13.3777], [47.3769, 8.5417]]}'Errors
400 invalid_request when lat or lon is missing or out of range, level is not one of the listed values, radius is not 1 to 5000, or a bulk body has more than 100 pairs or an entry that is not a [lat, lon] pair.