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

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:

(4.6)

From 8,147 users

400+

Applications using this API

API Status

Online - All Systems Operational

API Response Times

Average
P50
P75
P90
P95
250ms277ms326ms529ms949ms

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.

List of Supported countries

Parameters

  • type  optional

    Inflation indicator type. Can be either CPI (Consumer Price Index) or HICP (Harmonized Index of Consumer Prices). If not provided, the CPI will be used by default.

  • country  optional

    2-letter country code (ISO-3166-1 alpha-2) or name of country (case-insensitive).

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 name of the country.

  • country_code

    The 2-letter country code (ISO-3166-1 alpha-2).

  • type

    The type of inflation indicator (CPI or HICP).

  • period

    The period for the inflation data.

  • monthly_rate_pct

    The monthly inflation rate as a percentage.

  • yearly_rate_pct

    The yearly inflation rate as a percentage.

Sample Request Live Demo!

Country
type

Try this API endpoint with all available parameters in our API playground

https://api.api-ninjas.com/v1/inflation?country=CA

Headers

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

Sample Response

JSON
[
    {
      country:"Canada",
      country_code:"CA",
      type:"CPI",
      period:"Oct 2023",
      monthly_rate_pct:0.06,
      yearly_rate_pct:3.12
    }
]

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

  • country  required

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

  • type  optional

    Inflation indicator type. Can be either CPI (Consumer Price Index) or HICP (Harmonized Index of Consumer Prices). If not provided, the CPI will be used by default.

  • start_time  optional

    Start time for the data range, specified as a UNIX timestamp in seconds.

  • end_time  optional

    End time for the data range, specified as a UNIX timestamp in seconds.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response

A JSON object with the following fields or an error if the request is unsuccessful.

  • type

    The type of inflation indicator (CPI or HICP).

  • country

    The name of the country.

  • country_code

    The 2-letter country code (ISO-3166-1 alpha-2).

  • data

    Array of historical inflation data points, each containing:

    • timestamp

      UNIX timestamp in seconds for the data point.

    • rate_pct

      The inflation rate as a percentage for the given timestamp.

Sample Request Live Demo!

Country
type
start_time
end_time

Try this API endpoint with all available parameters in our API playground

https://api.api-ninjas.com/v1/inflationhistorical?country=CA

Headers

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

Sample Response

JSON
{
    type:"cpi",
    country:"Canada",
    country_code:"CA",
    data:[
      {
        timestamp:1659312000,
        rate_pct:8.26
      },
      {
        timestamp:1661990400,
        rate_pct:8.2
      },
      {
        timestamp:1664582400,
        rate_pct:7.75
      },
      {
        timestamp:1667260800,
        rate_pct:7.11
      },
      "..."
    ]
}

Frequently Asked Questions

  • 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.
  • 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.
  • 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 the type parameter: CPI (Consumer Price Index, available for all countries) and HICP (Harmonized Index of Consumer Prices, available for many European countries). To compare other macroeconomic indicators, see our GDP API and Unemployment API.
  • Call the /v1/inflation endpoint with the country parameter, 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 a type of CPI or HICP (defaults to CPI). Both endpoints are Premium only, so you will need a paid plan from our pricing page.
  • It returns a JSON array of objects, each with country, country_code, type (CPI or HICP), period, monthly_rate_pct, and yearly_rate_pct fields. The stats are usually updated monthly, though some countries may lag behind; if a request is unsuccessful you will receive an error instead.
  • Use the /v1/inflationhistorical endpoint with the required country parameter and optional type, start_time, and end_time parameters (the latter two as UNIX timestamps in seconds). It returns a JSON object whose data array holds up to 100 points, each with a timestamp and rate_pct; explore all our finance endpoints on the APIs page.