Skip to main content

countrystatecity-phonecodes

PyPI Python Version License Type Checked phonecodes phonecodes

Official Python package for international phone/dialing codes — 250 entries with country associations. Part of the countrystatecity ecosystem.

From offline prototype to production

This package provides a versioned offline snapshot. For regularly updated data, server-side search and filtering, field-selected responses, or managed availability and support, use the Country State City API through its official Python client:

pip install countrystatecity-api
from countrystatecity import CountryStateCity

csc = CountryStateCity()          # reads CSC_API_KEY

Get a free API key · API docs · Pricing · Migration guide

Keep API keys in server-side environment variables, never in client-side code or source control.

Installation

pip install countrystatecity-phonecodes

Usage

from countrystatecity_phonecodes import (
    get_all_phonecodes,
    get_phonecode_by_country,
    get_countries_by_phonecode,
    search_phonecodes,
)

# Get phone code for a country
us = get_phonecode_by_country("US")
print(f"+{us.phoneCode} — {us.countryName}")  # +1 — United States

# Get all countries sharing a dialing code
plus1 = get_countries_by_phonecode("1")
print(f"{len(plus1)} countries use +1")  # 25 countries use +1

# Works with or without + prefix
plus44 = get_countries_by_phonecode("+44")

# Search by country name, code, or phone code
results = search_phonecodes("united")
results = search_phonecodes("44")

# All phone codes
all_codes = get_all_phonecodes()
print(f"Total entries: {len(all_codes)}")

API Reference

get_all_phonecodes() -> List[PhoneCode]

Returns all phone code entries (one per country).

get_phonecode_by_country(country_code: str) -> Optional[PhoneCode]

Returns the phone code for a country by ISO2 code (e.g., "US").

get_countries_by_phonecode(phone_code: str) -> List[PhoneCode]

Returns all countries sharing a dialing code (e.g., "1" or "+1").

search_phonecodes(query: str) -> List[PhoneCode]

Search by country name, ISO2 code, or phone code (case-insensitive).

PhoneCode Model

class PhoneCode:
    phoneCode: str      # e.g. "1", "44", "91"
    countryCode: str    # ISO2 e.g. "US", "GB", "IN"
    countryName: str    # e.g. "United States"

License

ODbL-1.0 — see LICENSE.

Other Packages in this Ecosystem

Package Description
countrystatecity-api Official API client — live data, sync + async, typed
countrystatecity-countries 250 countries, 5,327 states, 156,169 cities
countrystatecity-timezones 432 country/timezone associations with country associations and time conversion
countrystatecity-currencies 249 country/currency associations
countrystatecity-translations 4,724 translations in 19 languages
countrystatecity-regions Region and subregion associations for 250 countries
countrystatecity-postal-codes Postal/ZIP records for 117 countries

Data sourced from countries-states-cities-database.


Made with ❤️ by dr5hn

Metadata

Release files for countrystatecity-phonecodes 3.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for countrystatecity-phonecodes 3.0.1
File Size Uploaded Provenance Actions
countrystatecity_phonecodes-3.0.1.tar.gz 61.0 kB With provenance Details for countrystatecity_phonecodes-3.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for countrystatecity-phonecodes 3.0.1
File Interpreter ABI Platform Actions
countrystatecity_phonecodes-3.0.1-py3-none-any.whl Python 3 none any Details for countrystatecity_phonecodes-3.0.1-py3-none-any.whl

Total release size: 121.0 kB

Release files / countrystatecity_phonecodes-3.0.1.tar.gz

Download URL countrystatecity_phonecodes-3.0.1.tar.gz
Size 61.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3c19ec8cde383dc5de0d3bc3e4016ab5ac11318b5839b5d85dd7057eaa9f9614
BLAKE2b-256 checksum
How to use checksums
8e80873987e5b5cccfb340cd0dc841d05d7fabfd20d7237312bb2db6d5422688
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / countrystatecity_phonecodes-3.0.1-py3-none-any.whl

Download URL countrystatecity_phonecodes-3.0.1-py3-none-any.whl
Size 60.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c0d03ee48ba63a561f6bdf471a54e2c15c18e3d15fc5f945b1e5e94d5c490753
BLAKE2b-256 checksum
How to use checksums
a58eff7e1af4eae66146d605a2b5e36d7b774730f131797d109c14e193ecbb63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for countrystatecity-phonecodes 3.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for countrystatecity_phonecodes-3.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page