GDP API
The GDP API provides current and historical GDP (Gross Domestic Product) data for countries around the world.
From 6,519 users
Applications using this API
API Status
API Response Times
Average | P50 | P75 | P90 | P95 |
|---|---|---|---|---|
| 286ms | 298ms | 326ms | 624ms | 1078ms |
Similar APIs
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
countryoptionalCountry name (case-insensitive) or 2-letter ISO-3166 alpha-2 code of the country. E.g.
CanadaorCA.yearoptionalYear for which to retrieve GDP data.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
A JSON array of objects, each containing the following fields, or an error if the request is unsuccessful.
countryThe 3-letter ISO 3166 alpha-3 country code.
yearThe year for which the GDP data is recorded.
gdp_growthGDP growth rate as a percentage.
gdp_nominalNominal GDP in billions of US dollars.
gdp_per_capita_nominalNominal GDP per capita in US dollars.
gdp_pppGDP at purchasing power parity (PPP) in billions of US dollars.
gdp_per_capita_pppGDP per capita at PPP in US dollars.
gdp_ppp_shareCountry's share of world GDP at PPP as a percentage.
Sample Request Live Demo!
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=CanadaHeaders
X-Api-KeyLog in or sign up to get your API KeySample Response
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
Can I use the GDP API for commercial purposes?
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.How do I get an API key and start using the GDP API?
Sign up for a free account to instantly get your API key, then pass it in theX-Api-Keyheader on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.What happens if I exceed my quota for the month?
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.What happens if a request to the GDP API fails?
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.How do I look up GDP data for a specific country or year?
Pass thecountryparameter as either a country name or 2-letter ISO-3166 alpha-2 code (e.g.CanadaorCA), and optionally narrow results with theyearparameter; at least one of the two must be set. To resolve country names and codes you can cross-reference the Country API.What fields does the GDP API response include?
Each object in the returned JSON array includescountry(3-letter ISO 3166 alpha-3 code),year,gdp_growth(percentage),gdp_nominalandgdp_per_capita_nominalin US dollars,gdp_pppandgdp_per_capita_pppat purchasing power parity, andgdp_ppp_share(the country's share of world GDP at PPP). If a request fails, an error is returned instead.What are some use cases for the GDP API?
The API is useful for building economic dashboards, comparing nominal versus PPP output across countries, and powering research tools that trackgdp_growthover time. It pairs well with other macroeconomic data such as the Inflation API, Unemployment API, and Population API.Does the GDP API provide historical data?
Yes, it returns both current and historical GDP statistics going back decades (sample data starts in 1980), so omitting theyearparameter returns the full time series for a country. See pricing for usage limits across plans.