NewConnect Claude, Gemini, ChatGPT, and other AI agents to API Ninjas via our MCP server

GDP API

The GDP API provides current and historical GDP (Gross Domestic Product) data for countries around the world.

(4.6)

From 6,519 users

1,900+

Applications using this API

API Status

Online - All Systems Operational

API Response Times

Average
P50
P75
P90
P95
286ms298ms326ms624ms1078ms

Didn't find what you were looking for? Suggest an improvement


/v1/gdp GET

https://api.api-ninjas.com/v1/gdp

Get GDP data from given parameters. Returns GDP statistics that satisfy the parameters.

Parameters

At least one of the following parameters must be set: country, year

  • country  optional

    Country name (case-insensitive) or 2-letter ISO-3166 alpha-2 code of the country. E.g. Canada or CA.

  • year  optional

    Year for which to retrieve GDP data.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

A JSON array of objects, each containing the following fields, or an error if the request is unsuccessful.

  • country

    The 3-letter ISO 3166 alpha-3 country code.

  • year

    The year for which the GDP data is recorded.

  • gdp_growth

    GDP growth rate as a percentage.

  • gdp_nominal

    Nominal GDP in billions of US dollars.

  • gdp_per_capita_nominal

    Nominal GDP per capita in US dollars.

  • gdp_ppp

    GDP at purchasing power parity (PPP) in billions of US dollars.

  • gdp_per_capita_ppp

    GDP per capita at PPP in US dollars.

  • gdp_ppp_share

    Country's share of world GDP at PPP as a percentage.

Sample Request Live Demo!

country
year

Try our APIs in the API playground

Sign up for a free API key to get started — no credit card required.

https://api.api-ninjas.com/v1/gdp?country=Canada

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
[
    {
      country:"CAN",
      year:1980,
      gdp_growth:2.2,
      gdp_nominal:276.064,
      gdp_per_capita_nominal:11281.422,
      gdp_ppp:290.29,
      gdp_per_capita_ppp:11862.755,
      gdp_ppp_share:2.192
    },
    {
      country:"CAN",
      year:1981,
      gdp_growth:3.5,
      gdp_nominal:307.246,
      gdp_per_capita_nominal:12396.666,
      gdp_ppp:328.886,
      gdp_per_capita_ppp:13269.808,
      gdp_ppp_share:2.224
    },
    "..."
]

Code Examples

1 2 curl -X GET "https://api.api-ninjas.com/v1/gdp?country=United%20States" \ -H "X-Api-Key: YOUR_API_KEY"

If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.

Frequently Asked Questions

  • Yes, but you must have a premium subscription. Commercial use of the GDP API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.
  • Sign up for a free account to instantly get your API key, then pass it in the X-Api-Key header on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.
  • Your API requests will simply be denied once you hit your monthly quota — you will never be charged more than the plan you signed up for. To increase your quota, you can upgrade your plan any time on our pricing page.
  • The API responds with a standard HTTP status code and a JSON error message describing the problem. See our error codes reference for the full list of codes and how to resolve each one, or contact support if you need help.
  • Pass the country parameter as either a country name or 2-letter ISO-3166 alpha-2 code (e.g. Canada or CA), and optionally narrow results with the year parameter; at least one of the two must be set. To resolve country names and codes you can cross-reference the Country API.
  • Each object in the returned JSON array includes country (3-letter ISO 3166 alpha-3 code), year, gdp_growth (percentage), gdp_nominal and gdp_per_capita_nominal in US dollars, gdp_ppp and gdp_per_capita_ppp at purchasing power parity, and gdp_ppp_share (the country's share of world GDP at PPP). If a request fails, an error is returned instead.
  • The API is useful for building economic dashboards, comparing nominal versus PPP output across countries, and powering research tools that track gdp_growth over time. It pairs well with other macroeconomic data such as the Inflation API, Unemployment API, and Population API.
  • Yes, it returns both current and historical GDP statistics going back decades (sample data starts in 1980), so omitting the year parameter returns the full time series for a country. See pricing for usage limits across plans.