bacenR

The {bacenR} package provides tools to download and process data from the Brazilian Central Bank (Banco Central do Brasil — Bacen) in a simple and efficient way. Currently, the package includes the following functions:

get_balance_sheets(
  institution = c("BANCOS", "COOPERATIVAS"),
  months = c(6, 12),
  first_year = 2022,
  final_year = 2023,
  out_dir = tempdir(),
  overwrite = FALSE
)
# First, download balance sheets
get_balance_sheets(
  institution = c("BANCOS", "COOPERATIVAS"),
  months = 12,
  first_year = 2022,
  final_year = 2023,
  out_dir = tempdir(),
  overwrite = FALSE
)

# Now, tidy the files
tidy_balance_sheets(
  path_raw = tempdir(),
  out_dir = tempdir(),
  doc_filter = 4010,
  save = FALSE
)
normas <- get_normative_data(
 terms = c("Cooperativas", "Cooperativa"), 
 ini_date = "2025-01-01",
 end_date = "2025-12-12"
 )
# First, download normative data
normative_data <- get_normative_data(
   terms = "Cooperativa",
   ini_date = "2023-08-01",
   end_date = "2023-12-10"
)

# Then, download the full texts for the retrieved normatives
normative_txt <- get_normative_txt(normative_data)
# Download multiple institution types
get_institutions(
  institution = c("BANCOS", "COOPERATIVAS"),
  start_date = "202201",
  end_date = "202212",
  out_dir = tempdir()
)
# First, download institution data
 get_institutions(
  institution = "COOPERATIVAS",
  start_date = "202311",
  end_date = "202312",
  out_dir = tempdir()
)

# Process institution files from a directory
institutions <- tidy_institutions(
  path_dir = tempdir(),
  out_dir = tempdir(),
  verbose = TRUE
)
# Multiple periods
cc_ativa_pj_modalidade_20142024 <- bacenR::get_ifdata_reports(
  year = c(2014:2024),
  month = 12,
  report = 13,
  type_institution = 2
)
# Multiple years and months
data <- get_ifdata_registry(
  year = c(2023, 2024), 
  month = c(6, 12)
)

For more details and examples, see the project on GitHub: https://github.com/rtheodoro/bacenR