{"id":15294035,"url":"https://github.com/allansifuna/flask-restcountries","last_synced_at":"2026-02-03T03:05:11.190Z","repository":{"id":57430653,"uuid":"351466051","full_name":"allansifuna/Flask-RestCountries","owner":"allansifuna","description":"A restcountries.eu API package for Flask Applications","archived":false,"fork":false,"pushed_at":"2021-10-12T08:41:56.000Z","size":31,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T15:47:55.264Z","etag":null,"topics":["allansifuna","flask","flask-restcountries","github-actions","pypi","python"],"latest_commit_sha":null,"homepage":"https://restcountries.com/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/allansifuna.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-25T14:29:06.000Z","updated_at":"2021-10-12T08:34:55.000Z","dependencies_parsed_at":"2022-09-13T15:23:46.147Z","dependency_job_id":null,"html_url":"https://github.com/allansifuna/Flask-RestCountries","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/allansifuna/Flask-RestCountries","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allansifuna%2FFlask-RestCountries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allansifuna%2FFlask-RestCountries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allansifuna%2FFlask-RestCountries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allansifuna%2FFlask-RestCountries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allansifuna","download_url":"https://codeload.github.com/allansifuna/Flask-RestCountries/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allansifuna%2FFlask-RestCountries/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262647524,"owners_count":23342665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["allansifuna","flask","flask-restcountries","github-actions","pypi","python"],"created_at":"2024-09-30T16:56:02.747Z","updated_at":"2026-02-03T03:05:11.155Z","avatar_url":"https://github.com/allansifuna.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Codacy Badge](https://api.codacy.com/project/badge/Grade/95668732c0014077abf06e7826c1becf)](https://www.codacy.com/manual/allansifuna/Flask-RestCountries?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=allansifuna/Flask-RestCountries\u0026amp;utm_campaign=Badge_Grade)\n[![Coverage Status](https://coveralls.io/repos/github/allansifuna/Flask-RestCountries/badge.svg?branch=main)](https://coveralls.io/github/allansifuna/Flask-RestCountries?branch=main)\n![Top language](https://img.shields.io/github/languages/top/allansifuna/Flask-RestCountries)\n![Code size](https://img.shields.io/github/languages/code-size/allansifuna/Flask-RestCountries?color=dark-green)\n![GitHub](https://img.shields.io/github/license/allansifuna/Flask-RestCountries?color=dark-green)\n![PyPI](https://img.shields.io/pypi/v/Flask-RestCountries)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/Flask-RestCountries?color=dark-green)\n![PyPI - Implementation](https://img.shields.io/pypi/implementation/Flask-RestCountries?color=blue)\n![PyPI - Status](https://img.shields.io/pypi/status/Flask-RestCountries)\n# Flask-RestCountries\n[Flask-RestCountries](https://pypi.org/project/Flask-RestCountries/) provides a simple intergration for [restcountries.com](https://restcountries.com) API with Flask Applications.\n\n# Installation\n\nUse the package manager [pip](https://pip.pypa.io/en/stable/) to install flask-restcountries.\n\n```bash\npip install Flask-RestCountries\n```\n\n# Usage\n\n```python\nfrom flask import Flask\nfrom flask_restcountries import CountriesAPI\n\napp = Flask(__name__)\n\n\nrapi = CountriesAPI(app)\n```\n\n\n# if you are using blueprints\n```python\nfrom flask_restcountries import CountriesAPI\nrapi = CountriesAPI()\n\nrapi.init_app(app)\n```\n\n## Usage in App\n```python\n\n\n@app.route('/get-all')\ndef get_all_countries():\n    \"\"\"all_countries is a list of Country Objects\"\"\"\n    all_countries = rapi.get_all()\n    return render_template(\"example.html\", all_countries=all_countries)\n\n\n```\n\n## Other Useful Methods\n\n### Get Countries By Calling Code string of a country. E.g. '254'.\n```python\ncountries=rapi.get_countries_by_calling_code(\"+254\")\n```\n\n### Get a Country By Alpha code string of a country. E.g. 'ke'.\n```python\ncountries=rapi.get_country_by_country_code(\"ke\")\n```\n\n### Get Countries By Capital string of a country. E.g. 'Nairobi'\n```python\ncountries=rapi.get_countries_by_capital(\"Nairobi\")\n```\n\n### Get Countries By Currency string of a country. E.g. 'KES'.\n```python\ncountries=rapi.get_countries_by_currency(\"KES\")\n```\n\n### Get Countries By Language string of a country. E.g. 'sw'.\n```python\ncountries=rapi.get_countries_by_language(\"sw\")\n```\n\n### Get Countries By Name string of a country. E.g. 'Kenya'.\n```python\ncountries=rapi.get_countries_by_name(\"Kenya\")\n```\n\n### Get Countries By Region string of a country. E.g. 'Africa'.\n```python\ncountries=rapi.get_countries_by_region(\"Africa\")\n```\n\n### Get Countries By Subregion string of a country. E.g. 'Eastern Africa'\n```python\ncountries=rapi.get_countries_by_subregion(\"Eastern Africa\")\n```\n\n## Response Filtering\nTo make the response return only afew selected fields, you can filter the response by passing a list\nof field to be returned in the filters keyword as a kwarg to the methods above. ie:-\n\n```python\ncountries=rapi.get_countries_by_calling_code(\"+254\",filters=[\"name\",\"currencies\",\"capital\"])\n```\n\n## Attributes that can be passed to the filters keyword\n    - topLevelDomain\n    - alpha2Code\n    - alpha3Code\n    - currencies\n    - capital\n    - callingCodes\n    - altSpellings\n    - relevance\n    - region\n    - subregion\n    - translations\n    - population\n    - latlng\n    - demonym\n    - area\n    - gini\n    - timezones\n    - borders\n    - nativeName\n    - name\n    - numericCode\n    - languages\n    - flag\n    - regionalBlocs\n    - cioc\n\n\n## Attributes of the Country object returned per each request\n    - top_level_domain\n    - alpha2_code\n    - alpha3_code\n    - currencies\n    - capital\n    - calling_codes\n    - alt_spellings\n    - relevance\n    - region\n    - subregion\n    - translations\n    - population\n    - latlng\n    - demonym\n    - area\n    - gini\n    - timezones\n    - borders\n    - native_name\n    - name\n    - numeric_code\n    - languages\n    - flag\n    - regional_blocs\n    - cioc\n\n## Contributing\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\n\n# License\n[MIT](https://github.com/allansifuna/Flask-RestCountries/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallansifuna%2Fflask-restcountries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallansifuna%2Fflask-restcountries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallansifuna%2Fflask-restcountries/lists"}