countryinfo
A Python module for returning data about countries, ISO info, and states/provinces within them.
What it is and what it does
Countryinfo is a lightweight, zero-dependency library that wraps a curated dataset of country metadata and exposes it through a simple object-oriented API. You instantiate a CountryInfo object with a country name, ISO code (alpha-2, alpha-3, or numeric), or alternate spelling, then call methods to retrieve specific attributes: capital, population, area, currencies, languages, calling codes, borders, timezones, GeoJSON geometry, and more. The library also supports reverse queries (all countries, filtered searches) and optional extras for fuzzy matching and Pydantic model integration.
It is designed for applications that need reliable, structured access to country reference data without external API calls or heavy dependencies. Common use cases include form validation, geographic filtering, localization, and data enrichment pipelines. The API is straightforward and the install footprint is minimal, making it suitable for both CLI tools and embedded library use.
Use it for:
- Validate and normalize country input in web forms or APIs by accepting multiple identifier formats (names, codes, spellings).
- Build geographic filters or dashboards that need to display country metadata like capital, population, or official languages.
- Enrich datasets with country-level attributes (currencies, timezones, calling codes) during ETL or data processing workflows.
- Generate GeoJSON boundaries for mapping applications or spatial analysis without external geospatial libraries.
- Implement country-aware features such as timezone detection, language selection, or regional grouping in multi-region applications.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Countryinfo provides a Python interface to query comprehensive geographic and administrative data for any country, including ISO codes, capitals, currencies, languages, borders, and GeoJSON boundaries.
Yes. Countryinfo is a stable, well-maintained library with zero dependencies, permissive licensing, and no known vulnerabilities. It fills a genuine need for reliable country metadata lookup. Install it if you need to work with country codes, geographic data, or reference information in a Python application.
Install
countryinfo on PyPI
pip
pip install countryinfouv
uv add countryinfopoetry
poetry add countryinfoInstalling countryinfo
Before you install
Low install friction with no runtime dependencies. Active maintenance since 2018, last commit 2026-06-21, and supports current Python versions (3.11–3.14). No known vulnerabilities.
License in practice
MIT license is permissive; you may use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install countryinfo
from countryinfo import CountryInfo
country = CountryInfo("Singapore")
print(country.capital()) # Singapore
print(country.iso(2)) # SG
print(country.currencies()) # ['SGD']
Verify before relying
- Whether the bundled country dataset is kept current with official ISO and geographic standards
- Performance characteristics when querying large numbers of countries or calling methods repeatedly
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 160 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 614,728/month — #5,746 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: countryinfo-1.0.1-py3-none-any.whl
Keywords: countryinfo, country, iso, geography
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
geonamescacheProvides Python dictionaries of geographic data…
permissive · top 5,000 on PyPI
hdx-python-countryMaps country and region codes and names,…
permissive · top 15,000 on PyPI
pycountryProvides programmatic access to ISO standard…
copyleft · top 1,000 on PyPI
isocodesisocodes provides programmatic access to ISO…
permissive · top 15,000 on PyPI
country_listProvides ISO 3166-1 country codes and names in…
permissive · top 15,000 on PyPI
names-datasetLooks up demographic information about first…
permissive · top 15,000 on PyPI
iso3166Converts between ISO 3166-1 country codes…
permissive · top 5,000 on PyPI
geotextGeotext extracts mentions of countries and…
permissive · top 15,000 on PyPI
django-countriesProvides a Django model field for storing…
permissive · top 5,000 on PyPI
language-dataProvides multilingual language names, speaker…
permissive · top 5,000 on PyPI