Skip to main content
Python applications can use the live Country State City API or install versioned offline data snapshots:
  • Live API SDK: countrystatecity-api provides typed synchronous and asynchronous clients, structured errors, and current managed data.
  • Offline packages: the suffixed countrystatecity-* packages bundle data for applications that cannot use an API key or network connection.
Install the live client with pip install countrystatecity-api, then import it as countrystatecity. There is no bare countrystatecity distribution on PyPI.

Live API SDK

Install the official API client and keep your key in a server-side environment variable:
Create a free API key and compare plans.
Use AsyncCountryStateCity with async with for non-blocking applications. Both clients cover countries, states, cities, regions, subregions, timezones, currencies, dial codes, ISO conversion, phone parsing, and fuzzy search.

Get a free API key

Start on the free tier and create a server-side API key.

Compare API plans

Review quotas and plan-specific capabilities.

Offline Packages

The offline packages use full type hints, Pydantic models, and lazy loading. Their data is bundled directly, so they do not require an API key or network request.

Available Packages

Installation

Install only what you need:

Usage

Countries

States

Cities

Country Details

Timezones

Currencies

Translations

Phone Codes

Features

Type-safe

Full type hints with Pydantic models and mypy support.

Lazy loading

Data loads on first access and caches with LRU cache for minimal memory footprint.

Zero dependencies

Only requires Pydantic — no other external packages.

Full coverage

250+ countries, 5,299+ states, 153,765+ cities with coordinates and metadata.

Offline Data Updates

To get the latest data, upgrade any package:

Source

GitHub Repository

View source, open issues, or contribute.

countrystatecity-api

Official live API client on PyPI.

countrystatecity-countries

Countries, states, and cities on PyPI.

countrystatecity-timezones

Timezone data on PyPI.

countrystatecity-currencies

Currency data on PyPI.

countrystatecity-translations

Translations data on PyPI.

countrystatecity-phonecodes

Phone codes data on PyPI.

countrystatecity-regions

Regions and subregions on PyPI.

countrystatecity-postal-codes

Postal code records and validation on PyPI.