Version: | 0.3.1 |
Title: | Data Collection from the Central Bank of Brazil |
Description: | Provides tools to facilitate the access and processing of data from the Central Bank of Brazil API. The package allows users to retrieve economic and financial data, transforming them into usable tabular formats for further analysis. The data is obtained from the Central Bank of Brazil API: https://api.bcb.gov.br/dados/serie/bcdata.sgs.{series_code}/dados?formato=json&dataInicial={start_date}&dataFinal={end_date}. |
License: | MIT + file LICENSE |
URL: | https://github.com/LissandroSousa/BacenAPI.r |
BugReports: | https://github.com/LissandroSousa/BacenAPI.r/issues |
Imports: | httr, httr2, jsonlite, magrittr |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Depends: | R (≥ 3.5) |
Packaged: | 2025-04-22 12:08:41 UTC; lisan |
Author: | Paulo Icaro [aut], Lissandro Sousa [cre, aut], Francisco Gildemir Ferreira da Silva [ths, aut] |
Maintainer: | Lissandro Sousa <lisandrosousa54@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-04-22 12:20:02 UTC |
Search for Financial Indicators Series Number
Description
Performs a search for financial indicator series based on a keyword.
Usage
bacen_search(keyword)
Arguments
keyword |
A string containing the search term in Portuguese - BR (e.g., "câmbio", "juros", "Bovespa"). |
Value
A data frame with the columns 'Code', 'Full_Name', 'Unit', 'Periodicity', and 'Start_Date' corresponding to the search results.
A data frame with the columns 'Code', 'Full_Name', 'Unit', 'Periodicity', and 'Start_Date' corresponding to the search results.
Examples
# Search for indices related to Fortaleza
bacen_search("fortaleza")
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)
Creation of URLs to Access the Central Bank API
Description
This function generates URLs to access specific time series data provided by the Central Bank of Brazil API.
Usage
bacen_url(series, start_date, end_date)
Arguments
series |
Desired series code(s). Must be a number or a vector of numbers. |
start_date |
Start date of the period of interest, in the format "dd/mm/yyyy". |
end_date |
End date of the period of interest, in the format "dd/mm/yyyy". |
Value
Returns a vector containing the generated URLs for each provided series.
Examples
# Generate a URL for series 433 (IPCA) from 01/01/2003 to 31/12/2023.
bacen_url(433, "01/01/2020", "31/12/2023") # in the format "dd/mm/yyyy"
Financial Indicators Dataset
Description
This dataset contains information on financial indicator series available from BacenAPI.
Usage
dataset
Format
A data frame with multiple rows and 5 columns:
- Code
(character) The unique series number.
- Full_Name
(character) The name of the financial series.
- Unit
(character) The unit of measurement for the data.
- Periodicity
(character) The frequency of data collection (e.g., daily, monthly, yearly).
- Start_Date
(Date) The starting date of the series.
Source
Central Bank of Brazil (Bacen)
Examples
data("dataset")
head(dataset)