Inflation API
The Inflation API provides current economic inflation data for 38 major countries. The stats are usually updated monthly - although certain countries may lag behind or update more infrequently.
Available endpoints:
- /v1/inflation - Get current monthly and annual inflation percentages
- /v1/inflationhistorical - Get historical inflation rates for a given country and time range
From 8,147 users
Applications using this API
API Status
API Response Times
Average | P50 | P75 | P90 | P95 |
|---|---|---|---|---|
| 250ms | 277ms | 326ms | 529ms | 949ms |
Similar APIs
Didn't find what you were looking for? Suggest an improvement
/v1/inflation GETPremium only
https://api.api-ninjas.com/v1/inflation
Returns current monthly and annual inflation percentages.
Parameters
typeoptionalInflation indicator type. Can be either
CPI(Consumer Price Index) orHICP(Harmonized Index of Consumer Prices). If not provided, theCPIwill be used by default.countryoptional2-letter country code (ISO-3166-1 alpha-2) or name of country (case-insensitive).
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 name of the country.
country_codeThe 2-letter country code (ISO-3166-1 alpha-2).
typeThe type of inflation indicator (CPI or HICP).
periodThe period for the inflation data.
monthly_rate_pctThe monthly inflation rate as a percentage.
yearly_rate_pctThe yearly inflation rate as a percentage.
Sample Request Live Demo!
Try this API endpoint with all available parameters in our API playground
https://api.api-ninjas.com/v1/inflation?country=CAHeaders
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/inflation?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.
/v1/inflationhistorical GETPremium only
https://api.api-ninjas.com/v1/inflationhistorical
Returns historical inflation rates for a given country and (optionally) time range. The maximum number of data points returned per API call is 100.
Parameters
countryrequiredEither the 2-letter country code (ISO-3166-1 alpha-2) or the country name (case-insensitive). See the list of supported countries in the /v1/inflation endpoint above.
typeoptionalInflation indicator type. Can be either
CPI(Consumer Price Index) orHICP(Harmonized Index of Consumer Prices). If not provided, theCPIwill be used by default.start_timeoptionalStart time for the data range, specified as a UNIX timestamp in seconds.
end_timeoptionalEnd time for the data range, specified as a UNIX timestamp in seconds.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
A JSON object with the following fields or an error if the request is unsuccessful.
typeThe type of inflation indicator (CPI or HICP).
countryThe name of the country.
country_codeThe 2-letter country code (ISO-3166-1 alpha-2).
dataArray of historical inflation data points, each containing:
timestampUNIX timestamp in seconds for the data point.
rate_pctThe inflation rate as a percentage for the given timestamp.
Sample Request Live Demo!
Try this API endpoint with all available parameters in our API playground
https://api.api-ninjas.com/v1/inflationhistorical?country=CAHeaders
X-Api-KeyLog in or sign up to get your API KeySample Response
Frequently Asked Questions
Can I use the Inflation API for commercial purposes?
Yes, but you must have a premium subscription. Commercial use of the Inflation 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 Inflation 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 Inflation 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.What countries and inflation indicators does the Inflation API cover?
The API provides inflation data for 38 major countries, including the United States, Canada, Japan, Germany, the United Kingdom and many others, identified by their 2-letter ISO-3166-1 alpha-2 code. It supports two indicator types via thetypeparameter:CPI(Consumer Price Index, available for all countries) andHICP(Harmonized Index of Consumer Prices, available for many European countries). To compare other macroeconomic indicators, see our GDP API and Unemployment API.How do I query inflation for a specific country?
Call the/v1/inflationendpoint with thecountryparameter, which accepts either a 2-letter ISO-3166-1 alpha-2 code (e.g.US) or the case-insensitive country name (e.g. United States), and optionally atypeofCPIorHICP(defaults toCPI). Both endpoints are Premium only, so you will need a paid plan from our pricing page.What does the /v1/inflation response include?
It returns a JSON array of objects, each withcountry,country_code,type(CPI or HICP),period,monthly_rate_pct, andyearly_rate_pctfields. The stats are usually updated monthly, though some countries may lag behind; if a request is unsuccessful you will receive an error instead.How do I retrieve historical inflation rates?
Use the/v1/inflationhistoricalendpoint with the requiredcountryparameter and optionaltype,start_time, andend_timeparameters (the latter two as UNIX timestamps in seconds). It returns a JSON object whosedataarray holds up to 100 points, each with atimestampandrate_pct; explore all our finance endpoints on the APIs page.