The IMF serves many different databases through its API, and the API needs to know which of these many databases you’re requesting data from. Before you can fetch any data, you’ll need to:
Get a list of available databases
Find the database ID for the data you want
Then you can use that database ID to fetch the data.
Fetching the Database List
Fetching an Index of Databases with the imf_databases Function
To obtain the list of available databases and their corresponding IDs, use imf_databases:
import imfp#Fetch the list of databases available through the IMF APIdatabases = imfp.imf_databases()databases.head()
database_id
description
0
GDD
Global Debt Database (GDD)
1
ITG_WCA
International Trade in Goods, World and Countr...
2
SRD
Structural Reform Database (SRD)
3
PPI
Producer Price Index (PPI)
4
EER
Effective Exchange Rate (EER)
This function returns the IMF’s listing of 71 databases available through the API.
Exploring the Database List
To view and explore the database list, it’s possible to explore subsets of the data frame by row number with databases.loc:
# View a subset consisting of rows 5 through 9databases.loc[5:9]
database_id
description
5
PSBS
Public Sector Balance Sheet (PSBS)
6
MFS_OFC
Monetary and Financial Statistics (MFS), Other...
7
EQ
Export Quality (EQ)
8
ISORA_2016_DATA_PUB
ISORA 2016 Data
9
FA
Fund Accounts (FA)
Or, if you already know which database you want, you can fetch the corresponding code by searching for a string match using str.contains and subsetting the data frame for matching rows. For instance, here’s how to search for commodities data:
See also Working with Large Data Frames for sample code showing how to view the full contents of the data frame in a browser window.
Best Practices
Cache the Database List: The database list rarely changes. Consider saving it locally if you’ll be making multiple queries. See Caching Strategy for sample code.
Search Strategically: Use specific search terms to find relevant databases. For example:
“Price” for price indices
“Trade” for trade statistics
“Financial” for financial data
Use a Browser Viewer: See Working with Large Data Frames for sample code showing how to view the full contents of the data frame in a browser window.
Note Database IDs: Once you find a database you’ll use frequently, note its database ID for future reference.
Next Steps
Once you’ve identified the database you want to use, you’ll need to:
Get the list of parameters for that database (see Parameters)
Use those parameters to fetch your data (see Datasets)