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.

Looking for historical inflation data? Go to the Historical Inflation endpoint.

/v1/inflation GET

https://api.api-ninjas.com/v1/inflation

Returns current monthly and annual inflation percentages.

The following inflation measures are available:

CountryCPIHICP
AustriaYesYes
BelgiumYesYes
BrazilYes premium only-
CanadaYes-
ChileYes-
ChinaYes premium only-
Czech RepublicYes premium onlyYes premium only
DenmarkYes premium onlyYes premium only
EstoniaYesYes
FinlandYes premium onlyYes
FranceYes premium onlyYes premium only
GermanyYesYes
GreeceYes premium onlyYes premium only
HungaryYesYes
IcelandYesYes
IndiaYes premium only-
IndonesiaYes premium only-
IrelandYesYes
IsraelYes premium only-
ItalyYes premium onlyYes premium only
JapanYes premium only-
MexicoYes-
NorwayYes-
PolandYes premium onlyYes premium only
PortugalYesYes
RussiaYes-
SlovakiaYesYes
SloveniaYes premium onlyYes
South KoreaYes premium only-
South AfricaYes premium only-
SpainYes premium onlyYes premium only
SwedenYesYes
SwitzerlandYesYes
The NetherlandsYesYes premium only
TürkiyeYes premium onlyYes premium only
United KingdomYes premium onlyYes premium only
United StatesYes premium only-

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

    Name of country (case-insensitive).

Headers

  • X-Api-Key  required

    API Key associated with your account.

Response Fields

  • country

    The name of the country.

  • 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
https://api.api-ninjas.com/v1/inflation?country=Canada

Sample Response

JSON
1 2 3 4 5 6 7 8 9 [ { "country": "Canada", "type": "CPI", "period": "Oct 2023", "monthly_rate_pct": 0.06, "yearly_rate_pct": 3.12 } ]

Code Examples

1 2 3 4 5 6 7 8 9 import requests country = 'Canada' api_url = 'https://api.api-ninjas.com/v1/inflation?country={}'.format(country) 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.

/v1/inflationhistorical GET

Developer and Business tier 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

    Country name (case-insensitive). The following countries are supported:

    CountryCPIHICP
    AustriaYesYes
    BelgiumYesYes
    BrazilYes-
    CanadaYes-
    ChileYes-
    ChinaYes-
    Czech RepublicYesYes
    DenmarkYesYes
    EstoniaYesYes
    FinlandYesYes
    FranceYesYes
    GermanyYesYes
    GreeceYesYes
    HungaryYesYes
    IcelandYesYes
    IndiaYes-
    IndonesiaYes-
    IrelandYesYes
    IsraelYes-
    ItalyYesYes
    JapanYes-
    MexicoYes-
    NorwayYes-
    PolandYesYes
    PortugalYesYes
    RussiaYes-
    SlovakiaYesYes
    SloveniaYesYes
    South KoreaYes-
    South AfricaYes-
    SpainYesYes
    SwedenYesYes
    SwitzerlandYesYes
    The NetherlandsYesYes
    TürkiyeYesYes
    United KingdomYesYes
    United StatesYes-
  • 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.

Sample Request

https://api.api-ninjas.com/v1/inflationhistorical

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 { "type": "cpi", "country": "United States", "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 }, ... ] }