Skip to content

dr5hn/countrystatecity-pypi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

31 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Country State City PyPI Packages

Official Python packages for accessing comprehensive countries, states, and cities database with type hints and lazy loading.

Python Version License Type Checked

πŸ“¦ Available Packages

Note: All Python distributions are published with an entity suffix (e.g. countrystatecity-countries). Currently there is no bare countrystatecity package on PyPI, so pip install countrystatecity may not work as expected. Pick the suffixed package you need from the list below.

Priority 1 (Released)

Coming Soon

  • countrystatecity-timezones - IANA timezone data and utilities
  • countrystatecity-currencies - Currency codes, symbols, and formatting
  • countrystatecity-languages - Language codes and metadata
  • countrystatecity-phonecodes - International dialing codes and validation

πŸš€ Quick Start

Installation

pip install countrystatecity-countries

⚠️ Don't run pip install countrystatecity β€” that name is unpublished. Always include the entity suffix (-countries, -timezones, etc.).

Usage

from countrystatecity_countries import (
    get_countries,
    get_country_by_code,
    get_states_of_country,
    get_cities_of_state,
)

# Get all countries
countries = get_countries()
print(f"Total countries: {len(countries)}")

# Get specific country
usa = get_country_by_code("US")
print(f"{usa.emoji} {usa.name}")
print(f"Capital: {usa.capital}")
print(f"Currency: {usa.currency_symbol} {usa.currency_name}")

# Get states (lazy loaded)
states = get_states_of_country("US")
print(f"Total states: {len(states)}")

# Get cities (lazy loaded)
cities = get_cities_of_state("US", "CA")
print(f"Cities in California: {len(cities)}")

✨ Features

  • βœ… Type-safe with Pydantic models and mypy support
  • βœ… Lazy loading for minimal memory footprint
  • βœ… 250+ countries with full metadata
  • βœ… 5,000+ states/provinces
  • βœ… 151,000+ cities
  • βœ… Translations in 18+ languages
  • βœ… Timezone data per location
  • βœ… Zero external dependencies (except Pydantic)
  • βœ… Full test coverage with pytest

πŸ“– Documentation

For detailed documentation, please refer to:

πŸ—οΈ Repository Structure

countrystatecity-pypi/
β”œβ”€β”€ python/                        # Python packages root
β”‚   β”œβ”€β”€ packages/
β”‚   β”‚   └── countries/             # Priority 1: Core package
β”‚   β”œβ”€β”€ shared/                    # Shared utilities
β”‚   β”œβ”€β”€ scripts/                   # Build scripts
β”‚   └── README.md
β”‚
β”œβ”€β”€ specs/                         # Specifications
β”‚   β”œβ”€β”€ README.md
β”‚   β”œβ”€β”€ 1-python-pypi-monorepo-plan.md
β”‚   β”œβ”€β”€ 2-python-vs-npm-comparison.md
β”‚   └── 3-python-quick-start-guide.md
β”‚
└── .github/
    └── workflows/
        └── python-ci.yml          # CI/CD workflow

πŸ› οΈ Development

Setup

# Clone the repository
git clone https://github.com/dr5hn/countrystatecity-pypi.git
cd countrystatecity-pypi/python/packages/countries

# Install dependencies
pip install -e ".[dev]"

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=countrystatecity_countries --cov-report=html

# Type checking
mypy countrystatecity_countries/ --strict

# Linting
ruff check countrystatecity_countries/ tests/

# Formatting
black countrystatecity_countries/ tests/
isort countrystatecity_countries/ tests/

πŸ“Š Technology Stack

Component Technology Purpose
Package Manager pip/setuptools Dependency management
Type System Pydantic Data validation, immutable models
Testing pytest Unit and integration tests
Type Checking mypy Static type checking
Formatting black + isort Code formatting
Linting ruff Fast Python linter
CI/CD GitHub Actions Automated testing

🎯 Design Principles

  1. Type Safety - Full type hints with Pydantic models
  2. Performance - Lazy loading with LRU cache
  3. Minimal Dependencies - Only essential dependencies
  4. Python Best Practices - PEP 8 compliant, well-tested
  5. Developer Experience - Clear APIs, comprehensive docs

πŸ“ License

All packages are licensed under the Open Database License (ODbL-1.0).

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Run tests (pytest)
  4. Commit your changes (git commit -m 'Add amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

πŸ“ž Support

πŸ”— Related Projects


Made with ❀️ by dr5hn

About

CountryStateCity - Python Packages

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages