bcrpy
Python client for accessing and analyzing macroeconomic data from the Banco Central de Reserva del Perú (BCRP).
📊 What is BCRP Data?
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/
⚡ Overview
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
🚀 Installation (UV recommended)
git clone https://github.com/andrewrgarcia/bcrpy
cd bcrpy
uv sync
⚡ Quick Start
from bcrpy import get
df = get(
codes=["PN01288PM"], # inflation
start="2020-01",
end="2023-01"
)
print(df.head())
🔥 Large Requests (Parallel)
from bcrpy import large_get
df = large_get(
codes=["PN01288PM", "PN01289PM", "PN00015MM"],
start="2010-01",
end="2023-01",
chunk_size=2,
workers=4
)
🧠 Metadata Tools
from bcrpy import Marco
m = Marco()
m.get_metadata()
tools = m.tools()
tools.query("PN01288PM")
tools.wordsearch("inflacion")
📁 Cache System
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
⚙️ Configuration
get(..., forget=True) # ignore cache
large_get(..., workers=2) # control parallelism
🧪 Testing
Run all tests:
uv run pytest -v
🧱 Architecture
bcrpy/
├── _fetcher.py # core data retrieval
├── _http.py # HTTP + retry logic
├── _metadata.py # metadata handling
├── tools.py # search / query tools
├── utils.py # IO + helpers
🎯 Design Principles
- Minimal dependencies
- Explicit behavior (no hidden magic)
- Reproducibility via caching
- Separation of concerns (data vs tools)
📌 Notes
- No API key required (public BCRP API)
- Network-dependent (uses official endpoint)
- Designed for research and modeling workflows
📄 License
MIT
Metadata
Release files for bcrpy 3.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bcrpy-3.4.0.tar.gz | 11.7 kB | Without provenance | Details for bcrpy-3.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bcrpy-3.4.0-py3-none-any.whl | Python 3 | none | any | Details for bcrpy-3.4.0-py3-none-any.whl |
Total release size: 22.6 kB
Release files / bcrpy-3.4.0.tar.gz
| Download URL | bcrpy-3.4.0.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6e717b21d4f717b599f58cc097dfcff68d9b1d191e1774040054f60c5d762d5d
|
|
BLAKE2b-256 checksum How to use checksums |
eb5bc2c671fe408ade9066cd1cc85444f6ce70170d2ea3de9f1efbf7da165d5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / bcrpy-3.4.0-py3-none-any.whl
| Download URL | bcrpy-3.4.0-py3-none-any.whl |
|---|---|
| Size | 11.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fbe7dfcef2648003c191d17bc9f32b30bc667324611dcc7502649a15df6333fd
|
|
BLAKE2b-256 checksum How to use checksums |
bbaf8fdb17ef90a794bdd172a937f3b25c579e4597cf23e590e8b0a20ec4907f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for bcrpy 3.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.