Skip to main content

pixbr

pixbr logo

CI PyPI version Python versions License: MIT Docs DOI

Python client for the Brazilian Central Bank (BCB) PIX Open Data API (Olinda / OData service). It hides the BCB's unusual OData URL syntax and returns pandas DataFrames.

📖 Documentation: https://strategicprojects.github.io/pixbr/

This is the Python counterpart of the R package pixr.

Installation

pip install pixbr        # once published
# or, from source:
pip install -e ".[dev]"

Quick start

Reusable client (recommended for multiple requests):

from pixbr import PixClient

client = PixClient()

# PIX keys stock by participant (date in YYYY-MM-DD)
keys = client.keys("2025-12-01", filter="TipoChave eq 'CPF'", top=100)

# Transaction statistics (database in YYYYMM)
stats = client.transaction_stats("202509", filter="NATUREZA eq 'P2P'")

# Transactions by municipality
muni = client.transactions_by_municipality("202512", filter="Sigla_Regiao eq 'NE'")

# Fraud statistics (MED)
fraud = client.fraud_stats("202509", top=100)

Module-level convenience functions mirror the pixr names:

from pixbr import get_pix_transaction_stats, get_pix_summary, format_brl

df = get_pix_transaction_stats("202509")
summary = get_pix_summary("202509", group_by="PAG_REGIAO")
format_brl(1234567.89)   # 'R$ 1.234.567,89'

Worked example

A small end-to-end analysis: which Brazilian regions paid the most via PIX in September 2025, and what was the average ticket per person-to-person transfer?

from pixbr import PixClient, format_brl

client = PixClient()

# 1. Pull person-to-person transaction statistics for the month.
stats = client.transaction_stats(
    "202509",
    filter="NATUREZA eq 'P2P'",
    columns=["PAG_REGIAO", "VALOR", "QUANTIDADE"],
)

# 2. Aggregate by payer region (the data comes pre-broken-down, so we sum it).
by_region = (
    stats.groupby("PAG_REGIAO", as_index=False)
    .agg(total_value=("VALOR", "sum"), total_count=("QUANTIDADE", "sum"))
    .assign(avg_ticket=lambda d: d["total_value"] / d["total_count"])
    .sort_values("total_value", ascending=False)
)

# 3. Present it with Brazilian currency formatting.
by_region["total_value"] = by_region["total_value"].map(format_brl)
by_region["avg_ticket"] = by_region["avg_ticket"].map(format_brl)
print(by_region.to_string(index=False))

The same aggregation is available as a one-liner via the convenience helper:

from pixbr import get_pix_summary

summary = get_pix_summary("202509", group_by="PAG_REGIAO")
# columns: PAG_REGIAO, total_value, total_count, avg_value, n_records

Fetching several months at once and combining into a single DataFrame:

from pixbr import get_pix_transaction_stats_multi

q3 = get_pix_transaction_stats_multi(["202507", "202508", "202509"])
monthly = q3.groupby("AnoMes")["VALOR"].sum()

Debugging a request without sending it (useful to inspect the OData URL):

client.build_url("EstatisticasTransacoesPix", {"Database": "202509"},
                 filter="NATUREZA eq 'P2P'", top=10)
# https://olinda.bcb.gov.br/.../EstatisticasTransacoesPix(Database=@Database)
#   ?$format=json&@Database='202509'&$filter=NATUREZA%20eq%20'P2P'&$top=10

Endpoints

Endpoint Parameter PixClient method Convenience function
ChavesPix Data (YYYY-MM-DD) .keys() get_pix_keys()
TransacoesPixPorMunicipio DataBase (YYYYMM) .transactions_by_municipality() get_pix_transactions_by_municipality()
EstatisticasTransacoesPix Database (YYYYMM) .transaction_stats() get_pix_transaction_stats()
EstatisticasFraudesPix Database (YYYYMM) .fraud_stats() get_pix_fraud_stats()
CnaePorteRecebedor Database (YYYYMM) .cnae_stats() get_pix_cnae_stats()
PixUsuariosCadastradosDICT (none) .dict_users() get_pix_dict_users()

Use pix_endpoints() and pix_columns("keys"|"municipality"|"stats"|"fraud"|"cnae"|"dict_users") to inspect available endpoints and columns.

OData query parameters

All endpoint methods accept the common OData parameters:

  • filter — OData filter expression, e.g. "NATUREZA eq 'P2P' and PAG_REGIAO eq 'SUDESTE'"
  • columns — list of columns to select (unknown columns are dropped with a warning)
  • orderby — "Column" (asc) or "Column desc"
  • top — maximum number of records

Note: skip is not supported by the BCB PIX API; passing it emits a warning and is ignored. Use top to limit results.

Notes

  • PixClient(timeout=..., max_retries=..., verbose=...) configures the HTTP session. The default timeout is 120s — the BCB API can be slow for large queries.
  • client.build_url(...) / pix_url(...) return the request URL without sending it (handy for debugging).
  • client.ping() / pix_ping() test connectivity to all six endpoints.

License

MIT

Metadata

Release files for pixbr 0.2.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 pixbr 0.2.0
File Size Uploaded Provenance Actions
pixbr-0.2.0.tar.gz 59.5 kB With provenance Details for pixbr-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 76.4 kB

Release files / pixbr-0.2.0.tar.gz

Download URL pixbr-0.2.0.tar.gz
Size 59.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b9129154a6c9e017a908e9b921e12a6517c5da3265c34e0ce6c430237e542af0
BLAKE2b-256 checksum
How to use checksums
d7b2243c54a7c7e2ba601e74b861d4e8cfcd592d1d02e26300be0e7a2dea6e79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / pixbr-0.2.0-py3-none-any.whl

Download URL pixbr-0.2.0-py3-none-any.whl
Size 16.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c631a9777291e42f7db55d6cd538236dc491aafe811d75829dc42bd773852bab
BLAKE2b-256 checksum
How to use checksums
5738dfb9ba76bd5d2e71807255deac6f642f50e9cd1a711d1580474b9bb749b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Security for pixbr 0.2.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pixbr-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

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.

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