| Title: | Imports Datasets from BCB (Central Bank of Brazil) using Its Official API |
|---|---|
| Description: | Downloads and organizes datasets using BCB's API <https://www.bcb.gov.br/>. Offers options for caching with the 'memoise' package and , multicore/multisession with 'furrr' and format of output data (long/wide). |
| Authors: | Marcelo Perlin [aut, cre] |
| Maintainer: | Marcelo Perlin <[email protected]> |
| License: | GPL-2 |
| Version: | 0.9.5 |
| Built: | 2026-10-05 16:54:37 UTC |
| Source: | https://github.com/msperlin/getbcbdata |
Using BCB's oficial API at <https://www.bcb.gov.br/>, this function will download data for a specific set of ids and dates. The main advantage is the use of caching and parallel computing for fast operations. You can search for available series at <https://www.bcb.gov.br/?sgs>
gbcbd_get_series( id, first_date = Sys.Date() - 5 * 365, last_date = Sys.Date(), format_data = "long", be_quiet = FALSE, use_memoise = TRUE, cache_path = gbcbd_get_default_cache_folder(), do_parallel = FALSE, first.date = NULL, last.date = NULL, format.data = NULL, be.quiet = NULL, use.memoise = NULL, cache.path = NULL, do.parallel = NULL )gbcbd_get_series( id, first_date = Sys.Date() - 5 * 365, last_date = Sys.Date(), format_data = "long", be_quiet = FALSE, use_memoise = TRUE, cache_path = gbcbd_get_default_cache_folder(), do_parallel = FALSE, first.date = NULL, last.date = NULL, format.data = NULL, be.quiet = NULL, use.memoise = NULL, cache.path = NULL, do.parallel = NULL )
id |
Id of time series. The name of the vector sets the name of the series in the output (e.g i_d <- c('SELIC' = 11)). You can search for ids in the official BCB-SGS webpage <https://www.bcb.gov.br/?sgs> |
first_date |
First date of time series |
last_date |
Last date of time series |
format_data |
The format of the datasets - long (default, series incremented by rows) or wide (series incremented by columns) |
be_quiet |
Logical. Should functions output messages to screen? - FALSE (default) or TRUE |
use_memoise |
Logical. Sets the use of caching system - TRUE (default) or FALSE |
cache_path |
Path to save cache files - 'gbcbd_cache' (default) |
do_parallel |
Logical for parallel data importation - FALSE (default) |
first.date |
Deprecated. Use |
last.date |
Deprecated. Use |
format.data |
Deprecated. Use |
be.quiet |
Deprecated. Use |
use.memoise |
Deprecated. Use |
cache.path |
Deprecated. Use |
do.parallel |
Deprecated. Use |
A dataframe with requested datasets
## Not run: my_id <- c('Selic Rate' = 11) df <- gbcbd_get_series(my_id, cache_path = tempdir()) ## End(Not run)## Not run: my_id <- c('Selic Rate' = 11) df <- gbcbd_get_series(my_id, cache_path = tempdir()) ## End(Not run)
Searches the BCB-SGS catalog (sistema gerenciador de series temporais) for
series whose name or metadata match a given text. The search is performed
against the official BCB-SGS search service at
<https://www3.bcb.gov.br/sgspub/>. The returned id column can be
passed directly to gbcbd_get_series.
gbcbd_search_series( search_text, max_results = 100, be_quiet = FALSE, use_memoise = TRUE, cache_path = gbcbd_get_default_cache_folder() )gbcbd_search_series( search_text, max_results = 100, be_quiet = FALSE, use_memoise = TRUE, cache_path = gbcbd_get_default_cache_folder() )
search_text |
A single string with the text to search for (e.g. 'selic'). |
max_results |
Maximum number of series to return. Use |
be_quiet |
Logical. Should functions output messages to screen? - FALSE (default) or TRUE |
use_memoise |
Logical. Sets the use of caching system - TRUE (default) or FALSE |
cache_path |
Path to save cache files - 'gbcbd_cache' (default) |
A tibble with the columns id, series_name,
unit, frequency, first_date, last_date and
source. Returns zero rows when nothing matches.
## Not run: df_search <- gbcbd_search_series('selic') print(df_search) # fetch the first matching series my_id <- df_search$id[1] names(my_id) <- df_search$series_name[1] df_series <- gbcbd_get_series(my_id) ## End(Not run)## Not run: df_search <- gbcbd_search_series('selic') print(df_search) # fetch the first matching series my_id <- df_search$id[1] names(my_id) <- df_search$series_name[1] df_series <- gbcbd_get_series(my_id) ## End(Not run)