Python API Wrapper for restcountries.eu
Project description
python-restcountries
This is a simple python wrapper for the API of http://restcountries.eu. If there are any issues, please use this repository to contact me about it.
Installation
pip install python-restcountries
Usage
Just import the API Wrapper and start using it!::
# v1 from restcountries import RestCountryApi as rapi
from restcountries import RestCountryApiV2 as rapi
def foo(name):
country_list = rapi.get_countries_by_name('France')
Response filtering
Pass filters as a keyword argument to any of RestCountryApiV2 or RestCountryApi methods, this filters the response returned by the api. Thus the Country Object will only contain the attributes in the filters list.
# v1 from restcountries import RestCountryApi as rapi
from restcountries import RestCountryApiV2 as rapi
def foo(name):
country_list = rapi.get_countries_by_name("France" ,filters=["name","currencies","capital"])
Attributes that can be passed in the filters list.
- topLevelDomain
- alpha2Code
- alpha3Code
- currencies
- capital
- callingCodes
- altSpellings
- relevance
- region
- subregion
- translations
- population
- latlng
- demonym
- area
- gini
- timezones
- borders
- nativeName
- name
- numericCode
- languages
- flag
- regionalBlocs
- cioc
The Country object
The API returns Country objects or a list of Country objects. Through the country objects one is able to access following attributes.
country = country_list[0]
print(country.name)
France
- top_level_domain
- alpha2_code
- alpha3_code
- currencies
- capital
- calling_codes
- alt_spellings
- relevance
- region
- subregion
- translations
- population
- latlng
- demonym
- area
- gini
- timezones
- borders
- native_name
- name
- numeric_code
- languages
- flag
- regional_blocs
- cioc
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for python-restcountries-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a68b1dc0690fb6261aaa0f4ae68dbdbc070d78899a4e55ccc8be3ef8c528ef0f |
|
MD5 | a24a685a06b477ab629a7cf9c75d9972 |
|
BLAKE2b-256 | 583c629cc019149e13ccdf65d552d6c4ff3d8dd2d5f2bb26f391195703b40545 |
Close
Hashes for python_restcountries-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c5dc2c86f88834e6e1f51ad0b26ca30e2117af9f9676748f12365076757b5d0 |
|
MD5 | d2b1b8acb380556d8e60a01d12515aba |
|
BLAKE2b-256 | 3e21f9bc0a4e3f38e84cce3a2934d3fff20cde8085ea4ab97cb2ec54b9c7b46e |