Skip to main content

A restcountries API wrapper for Flask Applications.

Project description

Requirements Status Codacy Badge Coverage Status

Flask-RestCountries

Flask-RestCountries provides a simple intergration for restcountries.eu API with Flask Applications.

Installation

Use the package managerpip to install flask-restcountries.

pip install Flask-RestCountries

Usage

from flask import Flask
from flask_restcountries import CountriesAPI

app = Flask(__name__)


rc = CountriesAPI(app)

if you are using blueprints

from flask_restcountries import CountriesAPI
rc = CountriesAPI()

rc.init_app(app)

Usage in App

@app.route('/get-all')
def get_all_countries():
    """all_countries is a list of Country Objects"""
    all_countries = rc.get_all()
    return render_template("example.html", all_countries=all_countries)

Other Useful Methods

Get Countries By Calling Code string of a country. E.g. '254'.

countries=rc.get_countries_by_calling_code("+254")

Get a Country By Alpha code string of a country. E.g. 'ke'.

countries=rc.get_country_by_country_code("ke")

Get Countries By Capital string of a country. E.g. 'Nairobi'

countries=rc.get_countries_by_capital("Nairobi")

Get Countries By Currency string of a country. E.g. 'KES'.

countries=rc.get_countries_by_currency("KES")

Get Countries By Language string of a country. E.g. 'sw'.

countries=rc.get_countries_by_language("sw")

Get Countries By Name string of a country. E.g. 'Kenya'.

countries=rc.get_countries_by_name("Kenya")

Get Countries By Region string of a country. E.g. 'Africa'.

countries=rc.get_countries_by_region("Africa")

Get Countries By Subregion string of a country. E.g. 'Eastern Africa'

countries=rc.get_countries_by_subregion("Eastern Africa")

Attributes of the Country object returned per each request

- 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

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Tests and Examples

Examples are comming soon!.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Flask-RestCountries-1.1.3.tar.gz (3.3 kB view details)

Uploaded Source

File details

Details for the file Flask-RestCountries-1.1.3.tar.gz.

File metadata

  • Download URL: Flask-RestCountries-1.1.3.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5

File hashes

Hashes for Flask-RestCountries-1.1.3.tar.gz
Algorithm Hash digest
SHA256 6387d952e99707d525bf05e684ac34e8be55472dc23e539b80c48529d45c05e1
MD5 0dca4913ad0ddc74d005f3b98359f1b1
BLAKE2b-256 18532118394b1f09c09fc5929445905280bb4e569dabec31bf913b62eb03b94c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page