bacen_series: Retrieve Data from BACEN API

View source: R/bacen_series.R

bacen_seriesR Documentation

Retrieve Data from BACEN API

Description

This function establishes a connection with the Central Bank of Brazil (BACEN) API to retrieve data in JSON format and convert it into a readable format such as a data frame or list. The connection is attempted up to 3 times in case of failure.

Usage

bacen_series(urls, httr = TRUE)

Arguments

urls

A string containing the BACEN API URL for the desired series.

httr

A logical value. If 'TRUE', the function uses the 'httr' package to connect. If 'FALSE', the function uses the 'httr2' package. Default is 'TRUE'.

Value

Returns the content of the API response converted into an R object (usually a list or data frame), or 'NULL' if the connection fails after 3 attempts.

Examples

# Example using the httr package
url <- bacen_url(c('433', '13005'), "01/01/2023", "31/12/2023")  # Date format: "dd/mm/yyyy"
bacen_series(url, httr = TRUE)


BacenAPI documentation built on June 8, 2025, 10:51 a.m.