A Python library for fetching and processing data from the CIA World Factbook.
Project description
WorldFactbook
WorldFactbook is a Python library that provides easy access to country-related data from the CIA World Factbook. It supports retrieving information about populations, languages, ISO codes, and more, with built-in caching for efficiency.
Data Source
This project sources data from the CIA World Factbook, which is in the public domain. Please note that this project and its author are not endorsed by or affiliated with the authors of the Factbook.
The World Factbook 2024. Washington, DC: Central Intelligence Agency, 2024. https://www.cia.gov/
Features
- Fetch country data from the CIA World Factbook API
- Retrieve language distribution, population, and ISO country codes
- Supports caching to reduce redundant API calls
- Processes and formats percentage-based data
- Provides lower level functions to access additonal fields
Installation
pip install worldfactbook
Usage
from worldfactbook import WorldFactbook
factbook = WorldFactbook(cache_folder="cache", use_cache=True)
# Get population data
populations = factbook.get_populations()
print(populations)
# Get language distribution
languages = factbook.get_languages()
print(languages)
# Get country ISO codes
country_codes = factbook.get_country_codes()
print(country_codes)
# Lower-level API calls
country_comparison_data = factbook.get_field_country_comparison_data("population") # Get population comparison data
field_data = factbook.get_field_data("languages") # Get field data like languages
reference_data = factbook.get_reference_data("country-data-codes") # Get reference data for country codes
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file worldfactbook-0.1.3.tar.gz.
File metadata
- Download URL: worldfactbook-0.1.3.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dea7a8c651e25189ed64c71f1f2f3e508bc6d478f853aaa17ceffb52e9560dd
|
|
| MD5 |
646bb01b90fa9e5c66ccaec6e9b2165b
|
|
| BLAKE2b-256 |
a751386647a8935a9f9816852cc239147be0921323614a143215f7ad5ea7291a
|
File details
Details for the file worldfactbook-0.1.3-py3-none-any.whl.
File metadata
- Download URL: worldfactbook-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
818d67434e45ef3df405657ad1e1272f7aba967a34b19e36dcf45c8ea270e1af
|
|
| MD5 |
20619d05eafabd1efaa80dc064a044fe
|
|
| BLAKE2b-256 |
0b84e0667b194874b471092759a97f2a428be1f9e65bd5728c2bbcc62ae95030
|