Skip to contents

Low-level function to fetch data from any PIX API endpoint with custom parameters.

Usage

pix_query(
  endpoint,
  params = NULL,
  filter = NULL,
  select = NULL,
  orderby = NULL,
  top = NULL,
  skip = NULL,
  format = "json",
  verbose = TRUE
)

Arguments

endpoint

Character string specifying the endpoint name.

params

Named list of endpoint parameters. Each endpoint requires different parameters:

  • ChavesPix: list(Data = "YYYY-MM-DD")

  • TransacoesPixPorMunicipio: list(DataBase = "YYYYMM")

  • EstatisticasTransacoesPix: list(Database = "YYYYMM")

  • EstatisticasFraudesPix: list(Database = "YYYYMM")

  • CnaePorteRecebedor: list(Database = "YYYYMM")

  • PixUsuariosCadastradosDICT: no parameters (pass NULL)

filter

OData filter expression as a character string.

select

Character vector of columns to select.

orderby

OData orderby expression as a character string.

top

Integer; maximum number of records to return.

skip

Integer; number of records to skip.

format

Response format: "json" (default), "xml", "csv", or "html".

verbose

Logical; if TRUE, prints progress messages.

Value

A tibble::tibble with the raw API response data.

Examples

if (FALSE) # It usually takes much longer than 5 seconds.
# Custom query for keys
pix_query(
  endpoint = "ChavesPix",
  params = list(Data = "2025-12-01"),
  top = 10
)

# Custom query for transaction stats
pix_query(
  endpoint = "EstatisticasTransacoesPix",
  params = list(Database = "202509"),
  top = 10
)
#> 
#> ── Custom PIX API Query ──
#> 
#> ℹ Endpoint: EstatisticasTransacoesPix
#> ℹ URL: https://olinda.bcb.gov.br/olinda/servico/Pix_DadosAbertos/versao/v1/odata/EstatisticasTransacoesPix(Database=@Database)?$format=json&@Database='202509'&$top=10
#> ✔ Retrieved 10 records
#> # A tibble: 10 × 12
#>    AnoMes PAG_PFPJ REC_PFPJ PAG_REGIAO    REC_REGIAO    PAG_IDADE      REC_IDADE
#>     <int> <chr>    <chr>    <chr>         <chr>         <chr>          <chr>    
#>  1 202608 PF       PF       NORDESTE      SUL           mais de 60 an… entre 20…
#>  2 202509 PF       PF       SUDESTE       CENTRO-OESTE  entre 50 e 59… NA       
#>  3 202608 PF       PF       NORTE         NORTE         entre 50 e 59… entre 20…
#>  4 202603 PF       PF       NORTE         SUL           entre 30 e 39… entre 30…
#>  5 202510 PF       PJ       SUL           Nao informado mais de 60 an… Nao se a…
#>  6 202603 PF       PF       NORTE         NORDESTE      entre 30 e 39… entre 50…
#>  7 202511 PF       PF       Nao informado CENTRO-OESTE  entre 30 e 39… entre 30…
#>  8 202511 PF       PF       NORTE         Nao informado até 19 anos    mais de …
#>  9 202510 PF       PF       SUL           NORDESTE      entre 30 e 39… entre 20…
#> 10 202512 PJ       PF       CENTRO-OESTE  NORTE         Nao se aplica  mais de …
#> # ℹ 5 more variables: FORMAINICIACAO <chr>, NATUREZA <chr>, FINALIDADE <chr>,
#> #   VALOR <dbl>, QUANTIDADE <int>
 # \dontrun{}