This is a unofficial API for Flagpedia
requests, you can install it withpip install requestspycountry, you can install it withpip install pycountryBeautifulSoup, you can install it withpip install bs4- Install all required modules with
pip install requests pycountry bs4- Clone the repository:
git clone https://github.com/codeuriii/flagpedia-api.git- Go to the repository
cd flagpedia-api- Demo code
# Importing the module
from flagpedia import FlagpediaAPI
flagAPI = FlagpediaAPI()
# Get the country code iso
country_name = "France"
country_code = flagAPI.get_iso(country_name)
# Get bytes of waving flag png image # Custom resolutions, always in 4:3
country_flag_bytes = flagAPI.get_flag(country_code, (256, 192))
# Write in a image
with open("french_flag.png", "wb") as f:
f.write(country_flag_bytes)If you have any questions or ideas for the project, please send it in issues page