Skip to main content
BCRP Logo

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)

Source distribution for bcrpy 3.4.0
File Size Uploaded
bcrpy-3.4.0.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bcrpy 3.4.0
File Interpreter ABI Platform
bcrpy-3.4.0-py3-none-any.whl Python 3 none any Details

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}

Release history Release notifications | RSS feed

This release

3.4.0 This release

2 release files

3.3.1

2 release files

3.3.0

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.7.0

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page