The GDP API provides current and historical GDP (Gross Domestic Product) data for countries around the world.
https://api.api-ninjas.com/v1/gdp
Get GDP data from given parameters. Returns GDP statistics that satisfy the parameters.
At least one of the following parameters must be set: country
, year
country
optionalCountry name (case-insensitive) or 2-letter ISO-3166 alpha-2 code of the country. E.g. Canada
or CA
.
year
optionalYear for which to retrieve GDP data.
X-Api-Key
requiredAPI Key associated with your account.
https://api.api-ninjas.com/v1/gdp?country=Canada
Headers
X-Api-Key
Log in or sign up to get your API Key
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
},
...
]
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.