An IMF World Economic Outlook (WEO) API Client
Project description
World Economic Outlook
Easily fetch IMF World Economic Outlook (WEO) data.
world-economic-outlook is a Python library and CLI tool for downloading, saving, and processing World Economic Outlook (WEO) data from the International Monetary Fund (IMF). It provides a convenient interface for managing WEO data, saving it locally, and pushing it to a database.
Features
- Download WEO data for a specific vintage (e.g., "2025 April").
- Save the downloaded data as an
.xlsfile. - Push data to a SQLite database.
- Command-line interface (CLI) for all major actions.
- Programmatic API for automation and scripting.
- Wrapper class for flexible workflows.
Installation
Requires Python 3.9+.
Install the published package:
pip install world-economic-outlook
Or install the library and its dependencies using pip:
pip install -r requirements.txt
Quick Start
Programmatic Usage
Using the WEO Wrapper
This example demonstrates how to use the WEO wrapper class to download, push to a database, and save WEO data:
from world_economic_outlook import WEO
weo = WEO()
weo.download("2025 April") # Download the data for the specified vintage
weo.push("database.db", "weo") # Push the data to a SQLite database table
weo.save("weo.xls") # Save the data as an .xls file
Using the download Function
This example demonstrates how to use the download function to download WEO data and either save it to a file, push it to a database, or both in a single call:
from world_economic_outlook import download
download("2025 April", save_path="weo.xls", database="database.db", table="weo")
vintage: The vintage string (e.g., '2025 April').save_path: (Optional) Path to save the WEO data as a file.databaseandtable: (Optional) Push the data to a SQLite database.
Command-Line Interface (CLI)
The CLI provides a convenient way to interact with the WEO Downloader and is installed with the package.
Download and Save Data
This example downloads WEO data for a specific vintage and saves it as an .xls file:
weo download "2025 April" -s "2025_April.xls"
Push Data to a Database
This example downloads WEO data and pushes it directly to a SQLite database table:
weo download "2025 April" -d "database.db" -t "weo"
Perform All Actions
This example downloads WEO data, saves it as an .xls file, and pushes it to a database in one command:
weo download "2025 April" -d "database.db" -t "weo" -s "2025_April.xls"
Help
For more details, run:
weo --help
Useful Tools
simple-sqlite3
The simple-sqlite3 library is used in this project to interact with SQLite databases. Make sure you have already created the database and table by running the weo CLI to download the data:
weo download "2025 April" -d "database.db" -t "weo"
Below are some useful commands for exporting data from your SQLite database to different file formats such as CSV and JSON.
Export to CSV
db export -d "database.db" -t "weo" -f "weo.csv"
Export to JSON
db export -d "database.db" -t "weo" -f "weo.json"
Fetching Data
This example shows how to fetch all database records for Brazil.
from simple_sqlite3 import Database
db = Database("database.db")
table = db.table("weo")
sql = """SELECT * WHERE iso = 'BRA'"""
results = table.query(sql)
print(results)
Example Output (from print(results)):
[ ...
{
"units": "National currency",
"estimate": 0,
"scale": "Billions",
"weo_subject_code": "NGDP_R",
"value": "522.938",
"iso": "BRA",
"subject_descriptor": "Gross domestic product, constant prices",
"country": "Brazil",
"vintage": "2025 April",
"estimates_start_after": 2024,
"year": 1980
},
{
"units": "National currency",
"estimate": 0,
"scale": "Billions",
"weo_subject_code": "NGDP_R",
"value": "499.93",
"iso": "BRA",
"subject_descriptor": "Gross domestic product, constant prices",
"country": "Brazil",
"vintage": "2025 April",
"estimates_start_after": 2024,
"year": 1981
},
...
]
More Fetch Conditions
This example shows how to fetch database records for Real GDP Growth for Brazil and Mexico in 2020 and 2021 from the 2025 April WEO.
from simple_sqlite3 import Database
db = Database("database.db")
table = db.table("weo")
sql = """
SELECT year, value, country, weo_subject_code
WHERE iso IN ('MEX', 'BRA')
AND year BETWEEN 2020 AND 2021
AND vintage='2025 April'
AND weo_subject_code = 'NGDP_RPCH'
"""
results = table.query(sql)
print(results)
Example Output (from print(results)):
[
{
"year": 2020,
"value": "-3.277",
"country": "Brazil",
"weo_subject_code": "NGDP_RPCH"
},
{
"year": 2021,
"value": "4.763",
"country": "Brazil",
"weo_subject_code": "NGDP_RPCH"
},
{
"year": 2020,
"value": "-8.354",
"country": "Mexico",
"weo_subject_code": "NGDP_RPCH"
},
{
"year": 2021,
"value": "6.048",
"country": "Mexico",
"weo_subject_code": "NGDP_RPCH"
}
]
License
This project is developed by Rob Suomi and licensed under the MIT License.
See the LICENSE file for details.
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
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 world_economic_outlook-0.0.6.tar.gz.
File metadata
- Download URL: world_economic_outlook-0.0.6.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d541dc7b30589a9a05f8c0a8e53d247c5f7a2bbca84454b248fe308170ec02e2
|
|
| MD5 |
883216a5ab98b8928952bce8e916b88c
|
|
| BLAKE2b-256 |
5e99dca0aee98f66b1f2e46bee2f211c3717f5cdabcefaf137efaf6edf1bed78
|
File details
Details for the file world_economic_outlook-0.0.6-py3-none-any.whl.
File metadata
- Download URL: world_economic_outlook-0.0.6-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55ed69b86dc8237cd6d97294c787c49a28fb3b0835dfda9b92d6522f4f1889ec
|
|
| MD5 |
91c9144e990cf6b8e90f0be8c2344e78
|
|
| BLAKE2b-256 |
d4cd34f6efb9ca20cc1c27be7a3a0b2f65078e6ff4f72c9dcdad97ded6901f3c
|