SDKs overview

The Brazil Central Bank (Banco Central do Brasil - BCB) provides access to its extensive collection of economic and financial data primarily through a RESTful API. This API allows developers and researchers to programmatically retrieve time series data, economic indicators, and financial statistics directly from the source for integration into applications, analytical models, and research projects. While the BCB itself does not publish official Software Development Kits (SDKs) to interact with its API, the developer community has created and maintains several libraries that facilitate this process. These community-driven SDKs abstract away the complexities of HTTP requests, data parsing, and API endpoint management, offering a more streamlined experience for users, particularly those working in data-intensive fields such as economic research, financial analysis, and academic studies.

The availability of community-contributed libraries in popular data science languages like Python and R is a significant asset for developers. These libraries are designed to align with common data manipulation and analysis workflows, making it easier to fetch, clean, and analyze BCB data. They typically handle tasks such as constructing API requests, managing different data formats (e.g., JSON), and converting responses into structured data types (e.g., pandas DataFrames in Python or data frames in R). This approach reduces the boilerplate code required to interact with the API, allowing users to focus more on data analysis and less on API integration challenges. The BCB's official API documentation, available in Portuguese, serves as the authoritative source for endpoint definitions, request parameters, and data structures. Developers are encouraged to consult this documentation for the most up-to-date information regarding the API's capabilities and data offerings, even when using community-developed SDKs.

Official SDKs by language

As of 2026, the Brazil Central Bank does not officially provide or maintain any Software Development Kits (SDKs) for its Open Data API. Developers wishing to interact with the API directly can do so by making HTTP requests based on the specifications detailed in the Brazil Central Bank API documentation. This documentation outlines the available endpoints, required parameters, and expected response formats, enabling developers to build custom integrations in any programming language capable of making web requests.

The absence of official SDKs means that any existing libraries are community-contributed. These unofficial libraries aim to simplify access to BCB data by wrapping the API's functionality in language-specific constructs. While convenient, users should be aware that these libraries are maintained independently of the Brazil Central Bank and their support, updates, and adherence to API changes may vary. Nevertheless, they represent a significant resource for the developer community, particularly for those working with Python and R, which are widely used in data science and economic analysis.

Installation

Since the Brazil Central Bank does not offer official SDKs, installation instructions pertain to community-developed libraries. The most prominent unofficial SDKs are available for Python and R, leveraging their respective package managers.

Python (Unofficial)

For Python, a popular community library for accessing BCB data is often found on package repositories like PyPI. Installation is typically performed using pip, Python's package installer. This method fetches the package and its dependencies from the Python Package Index and makes them available in your Python environment. Developers can consult the developer.mozilla.org for general information on HTTP status codes when troubleshooting API interactions.

pip install bcb

This command installs the bcb library, which is designed to provide a convenient interface for querying various datasets from the Brazil Central Bank. After installation, the library can be imported into Python scripts or interactive sessions to begin retrieving data.

R (Unofficial)

In the R ecosystem, a similar community-driven effort provides libraries to interface with the BCB API. These libraries are typically distributed via CRAN (The Comprehensive R Archive Network), R's primary package repository. The install.packages() function is used to download and install packages from CRAN.

install.packages("GetBCBData")

The GetBCBData package is a common choice for R users looking to access BCB data. Once installed, the package can be loaded into an R session using library(), making its functions available for use. Both Python and R environments will require an internet connection to download and install these packages.

Quickstart example

These quickstart examples demonstrate how to retrieve a specific time series from the Brazil Central Bank Open Data API using community-developed libraries in Python and R. The examples focus on fetching the Selic rate (Brazil's benchmark interest rate), which is identified by a specific series code.

Python Quickstart

This Python example uses the bcb library to fetch the Selic rate. The library simplifies the process of querying time series data by providing a dedicated function for this purpose.

import bcb
from datetime import datetime

# Define the series code for the Selic rate (e.g., 4390 for Selic daily rate)
selic_series_code = 4390

# Define the start and end dates for the data request
start_date = datetime(2023, 1, 1)
end_date = datetime(2023, 12, 31)

# Fetch the data using the bcb library
# The get_series function retrieves time series data from the BCB API
# It returns a pandas DataFrame by default
selic_data = bcb.sgs.get({"Selic": selic_series_code}, start=start_date, end=end_date)

# Print the first few rows of the retrieved data
print("Selic Rate Data (first 5 rows):")
print(selic_data.head())

# Basic descriptive statistics
print("\nDescriptive Statistics:")
print(selic_data.describe())

This code snippet first imports necessary modules. It then specifies the Selic series code (4390) and a date range. The bcb.sgs.get function is called with a dictionary mapping a user-friendly name to the series code, along with the start and end dates. The result is a pandas DataFrame, which is then printed to show the retrieved data and basic statistics. This demonstrates how the bcb library abstracts the underlying API calls and presents the data in a ready-to-use format for analysis.

R Quickstart

This R example utilizes the GetBCBData package to retrieve the same Selic rate time series. The package provides functions tailored for easy data retrieval and manipulation within the R environment.

# Install and load the GetBCBData package if not already installed
# install.packages("GetBCBData")
library(GetBCBData)

# Define the series code for the Selic rate (e.g., 4390 for Selic daily rate)
selic_series_code <- 4390

# Define the start and end dates for the data request
start_date <- as.Date("2023-01-01")
end_date <- as.Date("2023-12-31")

# Fetch the data using the GetBCBData package
# The gbcbd_get_series function retrieves data and returns a data.frame
selic_data <- gbcbd_get_series(
  id = selic_series_code,
  first.date = start_date,
  last.date = end_date
)

# Print the first few rows of the retrieved data
cat("Selic Rate Data (first 5 rows):\n")
print(head(selic_data))

# Basic descriptive statistics
cat("\nDescriptive Statistics:\n")
print(summary(selic_data))

Similarly, this R example loads the GetBCBData package. It then sets the Selic series code and the date range using R's as.Date function. The gbcbd_get_series function is invoked with the series ID and date boundaries. The function returns an R data frame, which is then displayed using head() and summarized with summary(). Both examples illustrate how these community libraries simplify the process of interacting with the Brazil Central Bank's data API, providing structured data directly into the user's analytical environment.

Community libraries

Given the absence of official SDKs from the Brazil Central Bank, community-developed libraries play a crucial role in facilitating access to its open data. These libraries are typically created and maintained by volunteers, researchers, and developers who are active within the data science and economic communities. Their primary goal is to abstract the complexities of direct API interaction, making BCB data more accessible to a broader audience, including economists, financial analysts, students, and journalists.

The development of such libraries often stems from a need to integrate BCB data efficiently into common analytical workflows. For instance, in Python, libraries commonly leverage the requests module for HTTP communication and pandas for data structuring, allowing for seamless integration with other data analysis tools. In R, similar patterns are observed, with libraries often returning data frames that are immediately usable with R's extensive statistical and visualization packages.

Here's a summary of prominent community libraries for accessing Brazil Central Bank Open Data:

Language Package Name Primary Installation Command Maturity / Status
Python bcb pip install bcb Actively maintained, widely used
R GetBCBData install.packages("GetBCBData") Actively maintained, widely used
R rbcb install.packages("rbcb") Actively maintained, alternative R package

These packages often provide functions to search for available series codes, retrieve metadata about time series, and fetch the actual data for specified periods. They handle common issues such as date formatting, error handling for API rate limits or invalid requests, and converting raw JSON responses into user-friendly data structures. For example, the IETF RFC 7231 provides the standard definitions for HTTP status codes, which these libraries interpret and handle.

Users of community libraries should be aware of a few considerations:

  • Maintenance: The level of ongoing support and updates can vary. It's advisable to check the project's repository (e.g., GitHub) for recent commits, issue activity, and documentation.
  • API Changes: If the Brazil Central Bank introduces changes to its API, community libraries may require updates. There might be a delay between an API change and the library being updated to reflect it.
  • Documentation: While many community libraries have good documentation, it might not always be as comprehensive as official vendor SDK documentation.
  • Functionality: Some libraries might focus on specific subsets of the BCB API, while others aim for broader coverage. Users should verify that a chosen library supports the specific data or functionality they require.

Despite these considerations, community libraries significantly lower the barrier to entry for interacting with the Brazil Central Bank Open Data API, making its rich datasets more accessible for a wide range of analytical and research purposes.