GDP API

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

/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.

Sample Request Live Demo!

country
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 [ { "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 3 4 5 6 7 8 import requests api_url = 'https://api.api-ninjas.com/v1/gdp?country=Canada' response = requests.get(api_url, headers={'X-Api-Key': 'YOUR_API_KEY'}) if response.status_code == requests.codes.ok: print(response.text) else: print("Error:", response.status_code, response.text)

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.