API REFERENCE · /SEARCH

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_KEY
curl "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.
format
json or xml. Always set it explicitly.
limit
Maximum number of results to return. Use 1 when you only need the best match.
addressdetails
Set to 1 to receive the address broken into fields such as road, city, postcode and country.
countrycodes
Restrict results to one or more countries using ISO 3166-1 alpha-2 codes, comma separated, for example pk or gb,ie.
accept-language
Preferred language for place names, for example en or de. 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

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 statuserror.codeWhat it means
401invalid_api_keyThe key is missing, wrong, disabled or not allowed for this request.
403plan_disabledThe plan on the account is not currently available.
429rate_limit_exceededMore requests per second than your plan allows. Slow down and retry.
429daily_quota_exceededThe daily allowance is used up. It resets at 00:00 UTC.
429monthly_quota_exceededThe 30-day allowance is used up. It resets when your 30-day period renews.
429global_limit_exceededThe service is busy. Wait briefly and retry.
503 / 504gateway_unavailable or emptyTemporary 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

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

Get your free API key Try the live demo ↗

Map data © OpenStreetMap contributors, available under the Open Database License. Results come from Nominatim and depend on mapped coverage.