Learn R Programming

BacenAPI (version 0.1.1)

bacen_api: Connection to the Central Bank API

Description

This function establishes a connection with the Central Bank of Brazil (BACEN) API, using the `httr` or `httr2` packages to retrieve data in JSON format and convert it into a readable format such as data frames.

Usage

bacen_api(url, httr = TRUE)

Value

Returns the data retrieved from the BACEN API.

Arguments

url

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

httr

A logical value. If `TRUE`, the function uses the `httr` package for the connection. Otherwise, it uses the `httr2` package. The default value is `TRUE`.

Examples

Run this code
# Example using the `httr` package:
url <- bacen_url(433, "01/01/2020", "31/12/2023") # in the format "dd/mm/yyyy"
data <- bacen_api(url, httr = TRUE)



Run the code above in your browser using DataLab