Skip to main content

Python client for BCRP macroeconomic data

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bcrpy-3.4.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bcrpy-3.4.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file bcrpy-3.4.0.tar.gz.

File metadata

  • Download URL: bcrpy-3.4.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for bcrpy-3.4.0.tar.gz
Algorithm Hash digest
SHA256 6e717b21d4f717b599f58cc097dfcff68d9b1d191e1774040054f60c5d762d5d
MD5 d73ed36fe92dfd2a0fa59c7aed74457d
BLAKE2b-256 eb5bc2c671fe408ade9066cd1cc85444f6ce70170d2ea3de9f1efbf7da165d5a

See more details on using hashes here.

File details

Details for the file bcrpy-3.4.0-py3-none-any.whl.

File metadata

  • Download URL: bcrpy-3.4.0-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for bcrpy-3.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fbe7dfcef2648003c191d17bc9f32b30bc667324611dcc7502649a15df6333fd
MD5 51e4465960bfb270745efc8fd95f660f
BLAKE2b-256 bbaf8fdb17ef90a794bdd172a937f3b25c579e4597cf23e590e8b0a20ec4907f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page