Reverse geocoding API: turn coordinates into addresses.
The /reverse endpoint takes a latitude and longitude and returns the nearest mapped place with a readable address, city, state, postcode and country.
Request
Send an HTTPS GET request to /reverse with the latitude and longitude of a point.
GET https://api.geocoding.info/reverse?lat=31.5880&lon=74.3107&format=json&addressdetails=1&key=YOUR_API_KEYcurl "https://api.geocoding.info/reverse?lat=31.5880&lon=74.3107&format=json&key=$GEOCODING_API_KEY"Parameters
lat- Required. Latitude in WGS84 decimal degrees, from -90 to 90.
lon- Required. Longitude in WGS84 decimal degrees, from -180 to 180. Use the named parameters so latitude and longitude are never swapped.
key- Required. Your API key from the dashboard.
formatjsonorxml. Always set it explicitly.zoom- How detailed the result should be, from
3(country) through10(city) and14(neighbourhood) to18(building, the default). addressdetails- Set to
1to include the address split into fields. accept-language- Preferred language for place names. English is used when this is not set.
Response
A successful request returns a single JSON object describing the nearest suitable mapped feature. This is a real response for lat=31.5880&lon=74.3107 (shortened):
{
"place_id": 251015865,
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright",
"osm_type": "relation",
"osm_id": 12271286,
"lat": "31.5881260",
"lon": "74.3093528",
"class": "amenity",
"type": "place_of_worship",
"place_rank": 30,
"addresstype": "amenity",
"name": "Badshahi Mosque",
"display_name": "Badshahi Mosque, Fort Road, Shahi Mohallah, Walled City of Lahore, Walled City, Lahore City Tehsil, Lahore District, Lahore Division, Punjab, 54100, Pakistan",
"address": {
"amenity": "Badshahi Mosque",
"road": "Fort Road",
"neighbourhood": "Shahi Mohallah",
"town": "Walled City of Lahore",
"district": "Lahore District",
"state": "Punjab",
"postcode": "54100",
"country": "Pakistan",
"country_code": "pk"
},
"boundingbox": [
"31.5871671",
"31.5890673",
"74.3090171",
"74.3112784"
]
}Notice that the returned lat/lon belong to the feature that was found, not to the point you sent. Reverse geocoding finds the closest suitable object in the map data, which may be a building, a street or an area.
Reading the address
The address object uses different keys depending on the place. A settlement can appear as city, town, village or hamlet, so check them in order rather than relying on one key. country_code is always the two-letter ISO code in lower case.
When nothing is found
For points with no suitable mapped feature nearby, for example in the open ocean, the response is an object with an error field such as {"error":"Unable to geocode"} instead of an address. Check for it before reading display_name.
Errors
Authentication and limit errors use the same JSON shape on every endpoint:
{"error": {"code": "invalid_api_key", "message": "API key is missing, invalid, or not permitted for this request."}}| HTTP status | error.code | What it means |
|---|---|---|
| 401 | invalid_api_key | The key is missing, wrong, disabled or not allowed for this request. |
| 403 | plan_disabled | The plan on the account is not currently available. |
| 429 | rate_limit_exceeded | More requests per second than your plan allows. Slow down and retry. |
| 429 | daily_quota_exceeded | The daily allowance is used up. It resets at 00:00 UTC. |
| 429 | monthly_quota_exceeded | The 30-day allowance is used up. It resets when your 30-day period renews. |
| 429 | global_limit_exceeded | The service is busy. Wait briefly and retry. |
| 503 / 504 | gateway_unavailable or empty | Temporary problem. Retry later with a delay; do not retry in a tight loop. |
Common uses
- Show a readable address for a GPS position from a phone, vehicle tracker or IoT device.
- Fill in the city and country when a user drops a pin on a map.
- Label photos or check-ins with the place where they were taken.
- Group points by district, state or country for reports.
Use a lower zoom such as 10 when you only need the city; it avoids street-level detail you will not use.
Frequently asked questions
What is reverse geocoding?
Reverse geocoding converts a latitude and longitude into a readable place: a street address, a neighbourhood, a city or a country. It is the opposite of geocoding, which turns an address into coordinates.
Will I always get an exact street address?
No. The API returns the nearest suitable feature in OpenStreetMap. In well-mapped areas that is often a building or street; elsewhere it may be a road, a village or a larger area.
How do I get only the city or country for a coordinate?
Request the point with a lower zoom, such as 10 for city level or 3 for country level, and read the city, town, village, state or country fields from the address object.
Does reverse geocoding find the location of a device?
No. Your application supplies the coordinates. Getting a device location is a separate step that usually requires the user's permission.
More developer guides
Map data © OpenStreetMap contributors, available under the Open Database License. Results come from Nominatim and depend on mapped coverage.