# Brazil Central Bank (BCB) — Selic, PTAX, Focus & Bank Rates (`brasil-api-lcm/apify-brazil-bcb-macro`) Actor

Extract official Banco Central do Brasil (BCB) macro series (Selic, CDI, IPCA, IGP-M), Focus Market Expectations, PTAX FX spreads, and bank credit interest rates via JSON/OData with MCP support.

- **URL**: https://apify.com/brasil-api-lcm/apify-brazil-bcb-macro.md
- **Developed by:** [Lucas Maia](https://apify.com/brasil-api-lcm) (community)
- **Features:** Limited permissions, Multi-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 record delivereds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Brazil Central Bank (BCB) — Selic, PTAX, Focus & Bank Rates (`apify-brazil-bcb-macro`)

Extract structured Brazilian macroeconomic indicators, consensus market expectations, FX reference rates, and commercial bank lending interest rates directly from the official **Banco Central do Brasil (BCB)** JSON and Olinda OData APIs — with zero residential proxies and zero external API keys.

### Why Use This Actor?

Designed for **quantitative funds, fintech credit desks, corporate treasuries, ERP/BI pipelines, and AI agents (Claude Code, Cursor, Codex CLI)** needing auditable official Brazilian monetary data:

- **`focus_expectations`:** Weekly BCB **Relatório Focus** market consensus expectations (`Mean`, `Median`, `StdDev`, `Min`, `Max`, `Respondents`) for IPCA, Selic, GDP (`PIB Total`), BRL/USD exchange rate (`Câmbio`), IGP-M, and Fiscal Balance across forecast years.
- **`sgs_series`:** Official **SGS Time Series** (`api.bcb.gov.br`), pre-mapped for **Selic Meta (`432`)**, **CDI (`12`)**, **IPCA (`433`)**, **IGP-M (`189`)**, **Unemployment (`24369`)**, and **Credit Delinquency (`21082`)** — including ISO date normalization and period-over-period delta calculation.
- **`bank_interest_rates`:** Monthly & annual lending interest rates charged by individual Brazilian banks (`Taxas de Juros - Olinda v2`) across modalities (Payroll Loans, Working Capital, Credit Card Revolving, Overdraft, Auto & Mortgage Financing).
- **`ptax_fx`:** Official **PTAX FX Rates** (`USD`, `EUR`, `GBP`, `JPY`, `CHF`, etc.) across intraday and closing bulletins (`Abertura`, `Intermediário`, `Fechamento`) with automated buy/sell spread calculation (`spreadAbs` and `spreadBps`).

### Example Input

```json
{
  "mode": "focus_expectations",
  "indicator": "IPCA",
  "maxResults": 20
}
```

```json
{
  "mode": "ptax_fx",
  "currency": "USD",
  "maxResults": 10
}
```

### MCP & Standby Ready

Connect directly via Apify Standby HTTP (`GET /`, `GET /health`, `POST /`) or **MCP JSON-RPC 2.0** (`POST /mcp`, tool name `query_brazil_central_bank`).

# Actor input Schema

## `mode` (type: `string`):

Choose SGS macroeconomic series (Selic, CDI, IPCA), Focus Market Expectations, Bank Credit Interest Rates, or PTAX FX rates.

## `sgsCode` (type: `integer`):

Official BCB SGS code for sgs_series mode (432=Selic Meta, 12=CDI, 433=IPCA, 189=IGP-M, 24369=Unemployment, 21082=Delinquency).

## `lastN` (type: `integer`):

Number of most recent observations to fetch in sgs_series mode.

## `indicator` (type: `string`):

Optional indicator filter in focus_expectations mode (e.g. IPCA, Selic, PIB Total, Câmbio, IGP-M).

## `currency` (type: `string`):

Currency symbol for ptax_fx mode (e.g. USD, EUR, GBP, JPY, CHF).

## `startDate` (type: `string`):

Optional start date for ptax_fx mode (defaults to 15 days ago).

## `endDate` (type: `string`):

Optional end date for ptax_fx mode (defaults to today).

## `query` (type: `string`):

Optional case-insensitive filter across bank name, credit modality, or indicator.

## `maxResults` (type: `integer`):

Maximum number of normalized rows returned.

## `timeoutSecs` (type: `integer`):

HTTP timeout in seconds when calling BCB endpoints.

## Actor input object example

```json
{
  "mode": "focus_expectations",
  "sgsCode": 432,
  "lastN": 20,
  "indicator": "",
  "currency": "USD",
  "startDate": "",
  "endDate": "",
  "query": "",
  "maxResults": 50,
  "timeoutSecs": 30
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "mode": "focus_expectations"
};

// Run the Actor and wait for it to finish
const run = await client.actor("brasil-api-lcm/apify-brazil-bcb-macro").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "mode": "focus_expectations" }

# Run the Actor and wait for it to finish
run = client.actor("brasil-api-lcm/apify-brazil-bcb-macro").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "mode": "focus_expectations"
}' |
apify call brasil-api-lcm/apify-brazil-bcb-macro --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,brasil-api-lcm/apify-brazil-bcb-macro"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/hOkpXG7M7AVVpQwEm/builds/jqHcMvVqaIOUjhP4W/openapi.json
