Geocoding API: turn addresses into coordinates.
The /search endpoint takes an address, place name or landmark and returns matching places with latitude, longitude and a structured address. It works worldwide and returns JSON or XML.
Request
Send an HTTPS GET request to the /search endpoint with the address in q and your API key in key. Remember to URL-encode the address.
GET https://api.geocoding.info/search?q=Badshahi%20Mosque%2C%20Lahore&format=json&addressdetails=1&limit=5&key=YOUR_API_KEYcurl "https://api.geocoding.info/search?q=Badshahi%20Mosque%2C%20Lahore&format=json&limit=5&key=$GEOCODING_API_KEY"Parameters
q- Required. The address, place name or landmark to find, for example
10 Downing Street, London. Include the city and country for better matches. key- Required. Your API key from the dashboard. Keep it on your server.
formatjsonorxml. Always set it explicitly.limit- Maximum number of results to return. Use
1when you only need the best match. addressdetails- Set to
1to receive the address broken into fields such asroad,city,postcodeandcountry. countrycodes- Restrict results to one or more countries using ISO 3166-1 alpha-2 codes, comma separated, for example
pkorgb,ie. accept-language- Preferred language for place names, for example
enorde. English is used when this is not set.
Other standard Nominatim search parameters, such as viewbox with bounded=1 to prefer an area, are passed through unchanged.
Response
A successful request returns HTTP 200 with a JSON array of matching places, best match first. This is a real response for Badshahi Mosque, Lahore (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"
]
}
]Fields you will use most
latandlon: the coordinates in WGS84 decimal degrees. They are strings, so convert them to numbers before doing maths or placing a map marker.display_name: a full, human-readable label for the place.address: the address split into parts (only withaddressdetails=1). Which fields appear varies by country and place type.boundingbox: south latitude, north latitude, west longitude, east longitude. Useful for zooming a map to the result.osm_typeandosm_id: the OpenStreetMap object, which you can pass to/lookuplater.
When nothing matches, the response is an empty array [] with HTTP 200, so always check the length before reading the first result.
Errors
Errors return a JSON body with a machine-readable code:
{"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. |
Limits and usage
Every plan has a per-second rate, a daily allowance (reset at 00:00 UTC) and a 30-day allowance, shared across all of your API keys. Compare plans on the pricing page. To check how much you have used, call GET https://api.geocoding.info/usage?key=YOUR_API_KEY; it does not count against your quota.
Tips for better results
- Add the city and country to the query, or use
countrycodes, to avoid matches in the wrong place. - Store results you have already looked up instead of geocoding the same address again.
- Send requests one after another and stay within your plan's per-second limit when processing a list.
- Call the API from your backend so your key is never exposed in browser JavaScript.
- If several results come back, let the user choose; the first result is a best guess, not a guarantee.
Frequently asked questions
Is there a free geocoding API plan?
Yes. The Free plan lets you sign up and start geocoding without a credit card. Paid plans add higher daily, 30-day and per-second limits; see the pricing page for current allowances.
Why are lat and lon strings instead of numbers?
The API returns coordinates exactly as Nominatim provides them, as decimal strings, to avoid rounding. Convert them with float() in Python or Number() in JavaScript before using them.
Why did my address return no results?
The address may be misspelled, too vague, or not yet mapped in OpenStreetMap. Try removing apartment or unit details, adding the city and country, or searching for a nearby street or landmark.
Can I geocode addresses in any country?
Yes. Coverage is worldwide and based on OpenStreetMap data, so detail varies by country and area. Use countrycodes to limit results to the countries you care about.
More developer guides
Map data © OpenStreetMap contributors, available under the Open Database License. Results come from Nominatim and depend on mapped coverage.