01 / Python
Fetch the latest Brazilian inflation rate
This example uses the 12-month IPCA change. The response preserves the period, unit, and official-source links.
import requests
url = "https://open-economics-data.knbf982hkn.chatgpt.site/api/v1/indicators/br-ipca-12m/latest"
response = requests.get(url, timeout=30)
response.raise_for_status()
payload = response.json()
latest = payload["data"][0]
print(f"IPCA 12 months: {latest['value']}% ({latest['period']})")pip install requests
02 / JavaScript
Get the current Selic target
Works in modern Node.js and in the browser. CORS is enabled on every public endpoint.
const url = "https://open-economics-data.knbf982hkn.chatgpt.site/api/v1/indicators/br-selic-target/latest";
const response = await fetch(url);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const { data, meta } = await response.json();
console.log({
value: data[0].value,
period: data[0].period,
unit: meta.indicator.unit_symbol,
source: meta.provenance.source_url,
});03 / CSV
Download IPCA for Excel, Sheets, or R
Add format=csv to an observations request. Every row repeats source IDs and URLs, preserving provenance outside JSON.
https://open-economics-data.knbf982hkn.chatgpt.site/api/v1/indicators/br-ipca-monthly/observations?start=2024-01-01&format=csvDownload example CSV↓04 / pandas
Compare Selic and inflation by month
Selic is daily while 12-month IPCA is monthly. This example selects the final Selic target in each month before joining the series—an explicit choice, not a hidden transformation.
import requests
import pandas as pd
API = "https://open-economics-data.knbf982hkn.chatgpt.site/api/v1"
def series(indicator):
response = requests.get(
f"{API}/indicators/{indicator}/observations",
params={"start": "2020-01-01", "order": "asc", "limit": 5000},
timeout=30,
)
response.raise_for_status()
return pd.DataFrame(response.json()["data"])
inflation = series("br-ipca-12m").assign(month=lambda x: x["date"].str[:7])
selic = series("br-selic-target").assign(month=lambda x: x["date"].str[:7])
selic_monthly = selic.groupby("month", as_index=False).last()
comparison = inflation[["month", "value"]].merge(
selic_monthly[["month", "value"]], on="month", suffixes=("_ipca", "_selic")
)
print(comparison.tail(12).to_string(index=False))pip install requests pandas
Need another series?Search the catalog by concept, source, or official code, then replace the stable ID in any example.
Search indicators→