geonamescache
Geonames data for continents, cities and US states.
What it is and what it does
GeonamesCache wraps geographic reference data from GeoNames into a Python library, letting you query continents, countries, US states, counties, and cities as dictionaries. It includes country codes, state and county codes, population figures, and geographic coordinates. The library loads data into memory on initialization, then provides lookup and search methods to retrieve records by code, name, or partial match.
You'd use it when you need reliable geographic identifiers and metadata in your application—mapping user input to country codes, validating state abbreviations, finding cities by name, or building reference data for location-based features. It's a reference library rather than a mapping or geocoding service; it doesn't convert addresses to coordinates or vice versa, but it does provide the canonical codes and names you'd use alongside such services.
Use it for:
- Validate and normalize country or state codes in user input or data imports.
- Build dropdown menus or autocomplete for location selection in web forms.
- Map city names to population and geographic coordinates for analytics or filtering.
- Create reference lookups for codes in data pipelines.
- Search for cities by partial name match across the dataset.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides Python dictionaries of geographic data including continents, countries, US states, counties, and cities with names, ISO and FIPS codes, population, and coordinates sourced from GeoNames.
Yes. It's a lightweight, actively maintained reference library with no security vulnerabilities, permissive licensing, and a narrow, well-defined purpose. Install it if you need reliable geographic codes and names; skip it if you need real-time geocoding or mapping services.
Install
geonamescache on PyPI
pip
pip install geonamescacheuv
uv add geonamescachepoetry
poetry add geonamescacheInstalling geonamescache
Before you install
Low friction install with a single lightweight dependency (typing-extensions). Actively maintained with a recent release 17 days ago and continuous repository activity.
License in practice
MIT license permits commercial and private use with minimal restrictions, making it safe for most projects.
Quickstart
pip install geonamescache
import geonamescache
gc = geonamescache.GeonamesCache()
countries = gc.get_countries()
print(countries)
Requires Python 3.10 or later.
Verify before relying
- Whether the bundled GeoNames dataset is updated regularly or requires manual refresh.
- Performance characteristics when searching across large city datasets.
- Memory footprint when loading all cities at minimum population threshold.
- Specific ISO and FIPS code standards covered by the dataset.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — typing-extensions |
| Maintenance | actively maintained — 17 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 931,913/month — #4,700 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: geonamescache-3.0.2-py3-none-any.whl
Keywords: counties, countries, fips, geo, geodata, geonames, iso-codes, states
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
countryinfoCountryinfo provides a Python interface to…
permissive · top 15,000 on PyPI
geotextGeotext extracts mentions of countries and…
permissive · top 15,000 on PyPI
usProvides structured access to US state and…
unclear · top 5,000 on PyPI
reverse-geocodeReverse Geocode converts latitude/longitude…
copyleft · top 15,000 on PyPI
country_listProvides ISO 3166-1 country codes and names in…
permissive · top 15,000 on PyPI
isocodesisocodes provides programmatic access to ISO…
permissive · top 15,000 on PyPI
pycountryProvides programmatic access to ISO standard…
copyleft · top 1,000 on PyPI
names-datasetLooks up demographic information about first…
permissive · top 15,000 on PyPI
pgeocodepgeocode queries postal codes to retrieve GPS…
permissive · top 5,000 on PyPI
censusProvides a Python wrapper for the United States…
permissive · top 15,000 on PyPI