MyNixOS website logo
Description

Data Collection from the Central Bank of Brazil.

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}>.

Accessing Brazil Central Bank Data via API

Overview

This simple library allows users to access Brazil Central Bank (BACEN) data by interacting with its API. The library consists of three main R scripts that work together:

  1. bacen_URL: Generates the URL where the data is available.
  2. bacen_series: Retrieves data from multiple Central Bank series, given a vector of series IDs and corresponding names.
  3. bacen_search: Searches for financial indicator series by keyword.

This README provides a detailed guide on how to use each function.


Bacen_URL

Description

This function generates the URL for accessing BACEN data by specifying three arguments:

  • series: The series code.
  • star_date: The start date.
  • end_date: The end date.

Important Notes

  • Use the Brazilian date format: dd/mm/yyyy.
  • Ensure dates are provided as strings/characters.
  • The function accepts either a single series or a vector of series.

Example

# Generate URL for IPCA series from 01/01/2003 to 31/12/2023
ipca_br_url <- bacen_url(433, '01/01/2003', '31/12/2023')

# Output
print(ipca_br_url)

Result:

[1] "https://api.bcb.gov.br/dados/serie/bcdata.sgs.433/dados?formato=json&dataInicial=01/01/2003&dataFinal=31/12/2023"

Bacen_series

Description

This function retrieves data from multiple Central Bank series, given a vector of series IDs and corresponding names:

Arguments

  • url: Variable containing a vector of URLs.
  • httr: A logical value indicating whether to use httr (TRUE) or httr2 (FALSE). Default is TRUE.

Example

# Retrieve data for multiple series
url <- bacen_url(c('433', '13005'), "01/01/2023", "31/12/2023")  # Date format: "dd/mm/yyyy"
data <- bacen_series(url, httr = TRUE)

# Display results
print(head(data))

Sample Output:

         date series_1 series_2
1  01/01/2013    0.79     0.74
2  01/02/2013    0.60     0.53
3  01/03/2013    0.47     0.40
4  01/04/2013    0.55     0.50
5  01/05/2013    0.37     0.32
6  01/06/2013    0.26     0.21

Footnotes

  • Customize series codes and date ranges as per your needs.
Metadata

Version

0.3.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows