Inflation (CPI)
Consumer price index (IPC) from the National Statistics Institute (INE), whole country. The 12 most recent months.
Loading inflation…
What each column means
The column names are the ones in the INE file. That file has no definitions, so the explanations are mine, not word for word from the INE.
| Data | API field | INE column | Explanation (mine, unofficial) |
|---|---|---|---|
| Month | date | Mes y año | First day of the month the data refers to. |
| Index | index | Índice | Value of the index, base October 2022 = 100. |
| Monthly | monthly_change | Mensual | Percentage change from the previous month. |
| Year to date | year_to_date_change | Acum. año | Percentage change accumulated during the year up to that month. |
| 12 months | twelve_month_change | Acum.12 meses | Percentage change from the same month of the previous year. |
| Quarter | quarter_change | Trimestre | Percentage change of the quarter, as published by the INE. |
| Four months | four_month_change | Cuatrimestre | Percentage change of the four-month period, as published by the INE. |
Good to know
- Changes are percentages: 0.54 means 0.54 %. Cells that the INE leaves empty are returned as null (for example, the changes of the first months of the series).
- Index values of the first years are very small (1937 is about 0.00000016) because the series is expressed in the current base, after several currency changes.
- Every time the file is loaded, the monthly and 12-month changes are checked against the index (allowing a tiny difference that exists in the INE's own figures). If they do not match, the load is rejected.
- The INE publishes each month's figure at the beginning of the following month.
Source: INE CPI file (whole country, base October 2022 = 100). View the original file (Excel)
Use this data in your systems
The API is public and free: it returns the CPI in JSON format, with the whole history since 1937 and no sign-up.
import requests
URL = "https://apitool.techspot365.com/api/v1/inflation"
# Latest 2 months of the CPI
response = requests.get(URL, params={"limit": 2}, timeout=30)
response.raise_for_status()
result = response.json()
for row in result["data"]:
print(row["date"], row["index"], row["monthly_change"], row["twelve_month_change"])
# While result["meta"]["is_last_page"] is False, request the next page: page=2, 3, ...- Parameters: from and to (month, YYYY-MM), limit (up to 1000) and page. Without from, it returns the last 24 months.
- Results come from the most recent to the oldest. The meta object has the source, the base of the index and the last month available.
- Optional: format=csv returns the same data as a CSV file (comma-separated, dot as the decimal mark, UTF-8), with no conversion, to open in Excel or Google Sheets. In Excel with Spanish regional settings, open it from Data > Get Data > From Text/CSV. The totals are in the X-Total-Count and X-Is-Last-Page headers. For the whole history in one file, add all=true (up to 100,000 rows).
- Limit: 300 requests per hour per IP.
- Errors: 400 if a parameter is not valid and 429 if you go over the request limit.
- Power BI: in Get data > Blank query > Advanced editor, paste the code and choose Anonymous access.