Python client for accessing and analyzing macroeconomic data from the Banco Central de Reserva del Perú (BCRP).
The BCRP provides a public API with hundreds of economic time series, including:
- Inflation (IPC)
- GDP and economic activity
- Interest rates
- Monetary aggregates
- External sector indicators
Official API: 👉 https://estadisticas.bcrp.gob.pe/estadisticas/series/ayuda/api
Explore data: 👉 https://estadisticas.bcrp.gob.pe/estadisticas/series/
bcrpy is a lightweight data access layer for BCRP macroeconomic data.
It provides:
- Simple Python interface (
get,large_get) - Parallel data fetching
- Built-in caching (disk + SQLite)
- Metadata exploration tools
- Clean pandas output
git clone https://github.com/andrewrgarcia/bcrpy
cd bcrpy
uv syncfrom bcrpy import get
df = get(
codes=["PN01288PM"], # inflation
start="2020-01",
end="2023-01"
)
print(df.head())from bcrpy import large_get
df = large_get(
codes=["PN01288PM", "PN01289PM", "PN00015MM"],
start="2010-01",
end="2023-01",
chunk_size=2,
workers=4
)from bcrpy import Marco
m = Marco()
m.get_metadata()
tools = m.tools()
tools.query("PN01288PM")
tools.wordsearch("inflacion")Data is cached automatically:
.bcrpy_cache/
├── cache_<hash>.bcrfile
├── cache_<hash>.meta
├── large_cache_<hash>.bcrfile
Features:
- Automatic reuse
- Hash-based isolation (no collisions)
- Optional SQLite backend
get(..., forget=True) # ignore cache
large_get(..., workers=2) # control parallelismRun all tests:
uv run pytest -vbcrpy/
├── _fetcher.py # core data retrieval
├── _http.py # HTTP + retry logic
├── _metadata.py # metadata handling
├── tools.py # search / query tools
├── utils.py # IO + helpers
- Minimal dependencies
- Explicit behavior (no hidden magic)
- Reproducibility via caching
- Separation of concerns (data vs tools)
- No API key required (public BCRP API)
- Network-dependent (uses official endpoint)
- Designed for research and modeling workflows
MIT