Skip to main content

python-countries

Build Status Coverage Status Code style: black PyPI

Wraps REST Countries

Installation

From Build:

$ pip install python-countries

From Source:

$ git clone https://github.com/leonkozlowski/python-countries.git
$ cd python-countries
$ pip install -e .

Usage

Create the client

>>> client = CountriesApi()

Show available endpoints

>>> client.endpoints()
>>> ['country_name', 'full_name', 'iso_code', 'currency', 'language', 'capital_city', 'calling_code', 'region']

Request for country data by full name

>>> client.full_name('Colombia')

Response for full_name endpoint

{
    "name": "Colombia",
    "topLevelDomain": [".co"],
    "alpha2Code": "CO",
    "alpha3Code": "COL",
    "callingCodes": ["57"],
    "capital": "Bogotá",
    "altSpellings": ["CO", "Republic of Colombia", "República de Colombia"],
    "region": "Americas",
    "subregion": "South America",
    "population": 48759958,
    "latlng": [4.0, -72.0],
    "demonym": "Colombian",
    "area": 1141748.0,
    "gini": 55.9,
    "timezones": ["UTC-05:00"],
    "borders": ["BRA", "ECU", "PAN", "PER", "VEN"],
    "nativeName": "Colombia",
    "numericCode": "170",
    "currencies": [{
        "code": "COP",
        "name": "Colombian peso",
        "symbol": "$"
    }],
    "languages": [{
        "iso639_1": "es",
        "iso639_2": "spa",
        "name": "Spanish",
        "nativeName": "Español"
    }],
    "translations": {
        "de": "Kolumbien",
        "es": "Colombia",
        "fr": "Colombie",
        "ja": "コロンビア",
        "it": "Colombia",
        "br": "Colômbia",
        "pt": "Colômbia"
    },
    "flag": "https://restcountries.eu/data/col.svg",
    "regionalBlocs": [{
        "acronym": "PA",
        "name": "Pacific Alliance",
        "otherAcronyms": [],
        "otherNames": ["Alianza del Pacífico"]
    }, {
        "acronym": "USAN",
        "name": "Union of South American Nations",
        "otherAcronyms": ["UNASUR", "UNASUL", "UZAN"],
        "otherNames": ["Unión de Naciones Suramericanas"..."]
    }],
    "cioc": "COL"
}

CountryResponse facade for easy attribute access

>>> colombia = client.full_name('Colombia')

>>> colombia.name
>>> "Colombia"

>>> colombia.flag
>>> "https://restcountries.eu/data/col.svg"

Metadata

Release files for python-countries 1.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 python-countries 1.0.1
File Size Uploaded Provenance Actions
python-countries-1.0.1.tar.gz 4.9 kB Without provenance Details for python-countries-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for python-countries 1.0.1
File Interpreter ABI Platform Actions
python_countries-1.0.1-py3-none-any.whl Python 3 none any Details for python_countries-1.0.1-py3-none-any.whl

Total release size: 11.1 kB

Release files / python-countries-1.0.1.tar.gz

Download URL python-countries-1.0.1.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e65d548662348549d972011c70491b1c727106d6817a087d15564d373d8a1b9d
BLAKE2b-256 checksum
How to use checksums
020b127544f9740dc5bc9293dfc81d981410dc4fe6e712b4589e91abfb0058e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.6.2rc1

Release files / python_countries-1.0.1-py3-none-any.whl

Download URL python_countries-1.0.1-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
25377f119edc6afa1a52e1e0498b47cc726e3b90c83b712b431bc1e78ed04bb4
BLAKE2b-256 checksum
How to use checksums
4738544082e45037cd2a2ed48448d38cd6c0b6ab52e57175980a241b40be604a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.6.2rc1

Security for python-countries 1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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