API Directory › 🌍 Geo & Location › GeoNames
No authHTTPS

GeoNames API

Geographical database API — places, postal codes, timezones and more.

Auth
No auth needed
HTTPS
Yes
CORS
Unknown
Open GeoNames docs ↗

What it does

GeoNames is a large open geographical database exposed as a web service: place-name search, nearby places, hierarchies, elevation, timezone by coordinates, country info, postal-code lookup and reverse geocoding across millions of features worldwide.

Base URL

http://api.geonames.org

Authentication

Free, but you must register a username and pass it as &username=YOUR_NAME. You also have to enable the free web service in your account settings. Use https://secure.geonames.org for TLS.

Code examples

curl
curl -s "http://api.geonames.org/searchJSON?q=Lagos&maxRows=3&username=$GEONAMES_USER"
Python
import requests

r = requests.get("http://api.geonames.org/findNearbyPlaceNameJSON",
    params={"lat": 6.45, "lng": 3.39, "username": USER}, timeout=10)
g = r.json()["geonames"][0]
print(g["name"], g["countryName"], g["adminName1"])

Rate limits & quotas

The free account allows about 20,000 credits/day and 1,000 credits/hour. Endpoints cost different credit amounts (a search is more than a simple lookup). Over the limit you get a JSON status object with an error code, not an HTTP error. Heavy or commercial use should self-host the data dumps or buy a premium plan.

Key response fields

geonames[]Array of matched features
geonames[].name / toponymNameDisplay name and canonical name
geonames[].lat / lngCoordinates (strings)
geonames[].countryName / adminName1Country and first-level admin region
status.message / status.valuePresent when the request failed

Common errors

status 10Invalid or missing username.
status 18 / 19 / 20Hourly, daily or per-minute credit limit exceeded.
status 15No result found for the query.
status 13Server overloaded — retry later.

When to use it (and alternatives)

Best for rich place-name search, administrative hierarchies and worldwide postal codes on a hobby budget. For street-address geocoding use Nominatim or OpenCage; for a polished commercial stack see Mapbox.

FAQ

Why do I get error code 10?

Either the username parameter is missing/misspelled, or you have not enabled the free web service on the ‘manage account’ page after registering. Both are required.

The HTTP status is 200 but there is an error — why?

GeoNames returns errors as a JSON status object with a 200 response. Check for status before reading geonames.

Can I use GeoNames commercially?

The free web service is intended for light and non-abusive use. For production volume, download the daily data dumps (CC-BY licensed) and run your own service, or subscribe to the premium endpoint.

New to APIs?

Short guides for working with this API — and any other.

🛠️ Handy LarzOS tools

Free tools to help you work with this API.

IP LookupDNS Lookup

Related Geo & Location APIs

← Back

More Geo & Location APIs · All 196 APIs