Reverse geocoding
Coordinates in, the nearest address out, or the locality, region or country if that is all you want.
GEThttps://api.mygeocode.com/v1/reverse
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, 1 to 5000. Default 5000. Set it small to get null instead of a far-away address. |
langoptional | string | ISO 639-1 code for names. Default en. |
keyoptional | string | API key, if not sent as a header. |
Example
$ curl "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)).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"}, timeout=10)
result = r.json()["result"]
print(result["formatted"] if result else "nothing nearby")Response
{
"status": "ok",
"lat": 41.8902,
"lon": 12.4922,
"result": {
"formatted": "Piazza del Colosseo 1, 00184 Roma RM, Italia",
"lat": 41.890251,
"lon": 12.492373,
"distance_m": 9,
"type": "address",
"precision": "house",
"place_id": "it.addr.5d09aa31",
"components": {
"house_number": "1",
"road": "Piazza del Colosseo",
"suburb": "Municipio Roma I",
"city": "Roma",
"county": "Roma",
"state": "Lazio",
"postcode": "00184",
"country": "Italia",
"country_code": "it"
}
}
}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 the feature. 0 when the point is inside it. |
result.type, result.precision, result.place_id, result.components | As in forward geocoding. |
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
nullataddresslevel and, within territorial waters, the country atcountrylevel.
Errors
400 invalid_request when lat or lon is missing or out of range, or level is not one of the listed values.