The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Introduction to pixr

Overview

The pixr package provides a tidyverse-style interface to the Brazilian Central Bank (BCB) PIX Open Data API. PIX is Brazil’s instant payment system, launched in November 2020, which has become the country’s primary payment method with over 150 million active users.

This package allows you to retrieve:

Installation

You can install pixr from GitHub:

# install.packages("remotes")
remotes::install_github("StrategicProjects/pixr")

Getting Started

Load the package:

library(pixr)

API Endpoints

Each endpoint requires a specific date parameter:

Endpoint Parameter Format R Function
ChavesPix date YYYY-MM-DD get_pix_keys()
TransacoesPixPorMunicipio database YYYYMM get_pix_transactions_by_municipality()
EstatisticasTransacoesPix database YYYYMM get_pix_transaction_stats()
EstatisticasFraudesPix database YYYYMM get_pix_fraud_stats()
# List all available endpoints
pix_endpoints()

# Get column information for each endpoint
pix_columns("keys")
pix_columns("municipality")
pix_columns("stats")

Quick Examples

Retrieve PIX Keys Data

PIX keys are identifiers used to simplify instant payments. Users can register up to 5 keys (individuals) or 20 keys (companies) per account. Key types include:

# Get all PIX keys data for December 2025
# Note: date uses YYYY-MM-DD format
keys <- get_pix_keys(date = "2025-12-01")

# Filter by key type
cpf_keys <- get_pix_keys(
  date = "2025-12-01",
  filter = "TipoChave eq 'CPF'",
  orderby = "qtdChaves desc",
  top = 100
)

# Get summary by institution
get_pix_keys_summary(date = "2025-12-01", n_top = 20)

Retrieve Transaction Data by Municipality

# Get transactions for December 2025
# Note: database uses YYYYMM format
muni <- get_pix_transactions_by_municipality(database = "202512")

# Filter by state using OData filter
maranhao <- get_pix_transactions_by_municipality(
  database = "202512",
  filter = "Estado eq 'MARANHÃO'",
  orderby = "Municipio desc",
  top = 10
)

# Aggregate by state
state_summary <- get_pix_transactions_by_state(database = "202512")

# Aggregate by region
region_summary <- get_pix_transactions_by_region(database = "202512")

Retrieve Transaction Statistics

# Get detailed transaction statistics for September 2025
stats <- get_pix_transaction_stats(database = "202509")

# Filter by transaction nature (P2P, P2B, etc.)
p2p <- get_pix_transaction_stats(
  database = "202509",
  filter = "NATUREZA eq 'P2P'"
)

# Get summary by transaction nature
get_pix_summary(database = "202509", group_by = "NATUREZA")

# Get summary by region
get_pix_summary(database = "202509", group_by = "PAG_REGIAO")

# Get data for multiple months
q3_data <- get_pix_transaction_stats_multi(
  databases = c("202507", "202508", "202509")
)

Retrieve Fraud Statistics

# Get fraud statistics (MED - Mecanismo Especial de Devolução)
fraud <- get_pix_fraud_stats(database = "202509")

OData Filter and OrderBy

All functions support OData query parameters for filtering and ordering:

# Filter by state
get_pix_transactions_by_municipality(
  database = "202512",
  filter = "Estado eq 'SÃO PAULO'"
)

# Multiple filters with 'and'
get_pix_transaction_stats(
  database = "202509",
  filter = "NATUREZA eq 'P2P' and PAG_REGIAO eq 'SUDESTE'"
)

# Order by value descending
get_pix_transaction_stats(
  database = "202509",
  orderby = "VALOR desc",
  top = 100
)

Common Filter Examples

Goal Filter
Filter by state "Estado eq 'SÃO PAULO'"
Filter by region "Sigla_Regiao eq 'NE'"
Filter by transaction type "NATUREZA eq 'P2P'"
Filter by key type "TipoChave eq 'CPF'"
Numeric comparison "VALOR gt 10000"
Multiple conditions "NATUREZA eq 'P2P' and PAG_REGIAO eq 'SUDESTE'"

See the Working with OData Queries article for complete documentation.

Working with the Data

All functions return tibbles that integrate seamlessly with the tidyverse:

library(dplyr)
library(ggplot2)

# Analyze transactions by region
get_pix_transactions_by_region(database = "202512") |>
  mutate(
    total_value_billions = (vl_pagador_pf + vl_pagador_pj) / 1e9
  ) |>
  ggplot(aes(x = reorder(Regiao, total_value_billions), y = total_value_billions)) +
  geom_col(fill = "#008060") +
  coord_flip() +
  labs(
    title = "PIX Transaction Volume by Region",
    x = "Region",
    y = "Transaction Value (R$ Billions)"
  ) +
  theme_minimal()

Configuration

Timeout

The default timeout is 120 seconds. Change it for slow connections:

# Set timeout to 3 minutes
pix_timeout(180)

# Check current timeout
pix_timeout()

# Or use options
options(pixr.timeout = 180)

Verbose Output

By default, all functions print progress messages. You can disable this:

# Suppress messages
data <- get_pix_keys(date = "2025-12-01", verbose = FALSE)

Debugging

Use pix_url() to see the URL that would be called:

# See the URL for a query
pix_url(
  "TransacoesPixPorMunicipio",
  params = list(DataBase = "202512"),
  filter = "Estado eq 'MARANHÃO'",
  orderby = "Municipio desc",
  top = 10
)

Next Steps

References

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.