IMF Data

Government API · Works globally · International Monetary Fund · Economic indicators

TL;DR

The IMF Data API (DataMapper) provides access to the International Monetary Fund's comprehensive economic and financial databases covering 190+ countries. Data includes GDP (nominal and PPP), GDP per capita, inflation rates (CPI, GDP deflator), unemployment, international reserves, balance of payments, government finance, general government debt, and exchange rates. The API uses REST JSON endpoints with SDMX standards. Data is available in current prices, constant prices, and as percentage of GDP. Historical data goes back to 1980 with projections 1-5 years ahead.

Quick start: https://www.imf.org/external/datamapper/api/v1/NGDPD

No API key needed — just make a request!

How to Use This API

1. Get GDP (Nominal) for All Countries

https://www.imf.org/external/datamapper/api/v1/NGDPD

Returns nominal GDP in current US dollars for every country with data.

2. Get GDP for Specific Countries

https://www.imf.org/external/datamapper/api/v1/NGDPD/USA,CHN,JPN,DEU,GBR

Specify comma-separated ISO 3-letter country codes. Use all for every country.

3. Get GDP Per Capita (PPP)

https://www.imf.org/external/datamapper/api/v1/NGDPDPC

NGDPDPC is GDP per capita, current prices, US dollars.

4. Get Inflation (CPI) Data

https://www.imf.org/external/datamapper/api/v1/PCPIEPCH

PCPIEPCH is inflation, average consumer prices, percent change. Use /USA,CHN for specific countries.

5. Get Government Debt as % of GDP

https://www.imf.org/external/datamapper/api/v1/GGXWDG_NGDP

General government gross debt as a percentage of GDP. Key indicator for fiscal health.

6. Response Format

{
  "values": {
    "NGDPD": {
      "USA": {
        "2023": 273609.0,
        "2024": 287810.0,
        "2025": 296420.0
      },
      "CHN": {
        "2023": 177010.0,
        "2024": 185340.0
      }
    }
  }
}

Values are organized by indicator, then country, then year. GDP values are in billions of US dollars.

7. JavaScript — Fetch Country GDP

fetch('https://www.imf.org/external/datamapper/api/v1/NGDPD/USA')
  .then(r => r.json())
  .then(d => {
    const values = d.values.NGDPD.USA;
    Object.entries(values)
      .sort(([a], [b]) => a - b)
      .forEach(([year, val]) => {
        console.log(`${year}: $${(val).toFixed(0)}B`);
      });
  });

8. Python — Compare GDP Across Countries

import requests

resp = requests.get(
    'https://www.imf.org/external/datamapper/api/v1/NGDPD/USA,CHN,JPN,DEU,IND'
)
data = resp.json()
indicator = 'NGDPD'
print("GDP Comparison (2024, billions USD):")
for country, years in data['values'][indicator].items():
    latest = list(years.keys())[0]
    print(f"  {country}: ${years[latest]:.0f}B")

9. Python — GDP Growth Comparison

import requests

resp = requests.get(
    'https://www.imf.org/external/datamapper/api/v1/NGDP_RPCH/USA,CHN,IND'
)
data = resp.json()
indicator = 'NGDP_RPCH'
print("Real GDP Growth (%):")
for country, years in data['values'][indicator].items():
    for year, val in sorted(years.items()):
        print(f"  {country} {year}: {val:.1f}%")
Try it: https://www.imf.org/external/datamapper/api/v1/NGDPD/USA,CHN

Frequently Asked Questions

What economic indicators are available?
NGDPD (nominal GDP), NGDPDPC (GDP per capita), NGDP_RPCH (real GDP growth, %), PCPIEPCH (inflation, avg consumer prices), LUR (unemployment rate), BCA (current account balance, $B), GGXWDG_NGDP (general government gross debt, %GDP), GGXONLB (net lending/borrowing), and hundreds more covering external sectors, trade, and fiscal data.
What country codes are used?
Standard ISO 3166-1 alpha-3 codes: USA, CHN, JPN, DEU, GBR, FRA, IND, BRA, CAN, AUS, ITA, ESP, KOR, MEX, IDN, NLD, SAU, and many more. Use all for the complete dataset, or /WEO for world aggregate.
How far back does the historical data go?
Most indicators provide data from 1980 to present, with some historical series going back to 1960 (e.g., USA GDP). Future projections are available for 1-5 years ahead, clearly labeled in the response.
What units are the values in?
GDP values (NGDPD) are in billions of current US dollars. GDP per capita (NGDPDPC) is in US dollars. Inflation (PCPIEPCH) is year-over-year percentage change. Government debt (GGXWDG_NGDP) is percentage of GDP.
How do I find the indicator code I need?
Browse the IMF DataMapper website (imf.org/external/datamapper) to find indicators visually, then check the URL for the API code. The codes are consistent between the web interface and the API.
Is this data free for commercial use?
Yes, the IMF provides this data freely for public use under the IMF Data Dissemination Standards. Attribution is appreciated but not required for most use cases.

What You Can Build