Government — entry 004 of 90
Brazil Central Bank Open Data
A CKAN-based open-data catalogue from Banco Central do Brasil covering 4,200+ datasets — exchange rates, interest rates, public debt, and other monetary time series. Dataset metadata is browsable via the standard CKAN Action API, and most series resolve to the Central Bank's SGS (Sistema Gerenciador de Séries Temporais) endpoints, which return JSON or CSV for a specified date range with no key required.
Banco Central do Brasil publishes economic time series through its SGS (Sistema Gerenciador de Séries Temporais) API at api.bcb.gov.br/dados — a separate host from the CKAN open-data catalogue at dadosabertos.bcb.gov.br that the stored url points to (a live keyless package_search against that catalogue this run returned 200 with count: 4231 real datasets). A live GET this run against /serie/bcdata.sgs.1/dados/ultimos/2?formato=json (USD/BRL PTAX, series 1) returned a genuine 200, 79 B two-point series with access-control-allow-origin: * — unlike the CKAN catalogue host, which sent no CORS header at all on the same kind of request. Don't rely on the content type of that response, though: it varies over time for the identical request. On 2026-08-02 it answered application/json; charset=utf-8 on 16 probes at 01:07 UTC (12 of them one second apart, plus four Accept-header variations) — but the same URL, serving the very same valid-JSON body, had answered text/html; charset=utf-8 on 5 consecutive probes just 27 minutes earlier at 00:40. It flipped and flipped back inside a single hour, so see the gotchas below: it changes how you have to detect failures.
GreatAPIs Score
Auth quickstart
- No API key, signup, or credit card required on either host — a live GET this run against
/serie/bcdata.sgs.1/dados/ultimos/2?formato=jsonreturned full JSON on the first anonymous try. Series are addressed by a numeric SGS code (1is the USD/BRL PTAX sale rate); a catalogue of codes lives on the separatedadosabertos.bcb.gov.brCKAN host, not on the SGS API itself.
Your key is stored only in this browser (localStorage) and sent directly to the API — never to greatapis.
Fetch the two most recent values of a time series
GEThttps://api.bcb.gov.br/dados/serie/bcdata.sgs.1/dados/ultimos/2?formato=json
[
{
"data": "30/07/2026",
"valor": "5.0739"
},
{
"data": "31/07/2026",
"valor": "5.0773"
}
]A live GET this run against the CKAN catalogue's package_search?rows=0 on dadosabertos.bcb.gov.br returned 200 with "result":{"count":4231,...} — confirming the two-host split: browse datasets on the CKAN host, then pull the actual numbers from the SGS API above.
Try it
Developer reference
https://api.bcb.gov.br/dados- GET/serie/bcdata.sgs.{codigo}/dados/ultimos/{n}
- GET/serie/bcdata.sgs.{codigo}/dados
Gotchas & limits
- Both fields in every row are strings, not native JSON types — confirmed live above:
datais"30/07/2026"indd/MM/yyyyorder (not ISOyyyy-MM-dd), andvaloris the quoted string"5.0739", not a JSON number. Code that runsnew Date(row.data)or arithmetic onrow.valordirectly will get garbage without an explicit parse step first. - A daily-periodicity series requested over a window longer than 10 years is rejected with HTTP 406 (not 400 or a truncated response) — confirmed live this run against
/serie/bcdata.sgs.1/dados?dataInicial=01/01/2000&dataFinal=01/01/2026&formato=json, a 26-year span, which returned an 802 B JSON body:{"error":"O sistema aceita uma janela de consulta de, no máximo, 10 anos em séries de periodicidade diária",...}— entirely in Portuguese, with no English fallback. - An unknown series code returns a slow HTTP 200, so neither the status nor the
content-typeheader is a reliable failure signal — confirmed live this run against/serie/bcdata.sgs.999999/dados/ultimos/2?formato=json, which took ~31 seconds to answer and then returned 200 (not 404), 6,254 B, a legacy Portuguese error page (<title>Requisição inválida!</title>, "Bad request!" in its English half) atcontent-type: text/html; charset=utf-8. Don't reach for header-sniffing to catch it: this API's successcontent-typeis not stable over time. On 2026-08-02 the hero request above returnedapplication/json; charset=utf-8on 16 probes at 01:07 UTC, but had returnedtext/html; charset=utf-8— the same type as this error page, which would have defeated the check entirely — on 5 consecutive probes 27 minutes earlier at 00:40, for a byte-identical request and a byte-identical JSON body. What is stable across both observations is the body: real data starts with[or{, the error page starts with<. Set a generous timeout and branch on the first non-whitespace byte, or just wrapJSON.parsein a try/catch and treat a parse failure as the error case. - The stored
cors: "no"for this entry was measured against the CKAN catalogue host and is wrong for the actual data API: a live GET this run againstapi.bcb.gov.brwith an explicitOrigin: https://greatapis.comheader returnedaccess-control-allow-origin: *, while the same probe againstdadosabertos.bcb.gov.brreturned no CORS header at all. This entry'scorsis corrected to"yes"to match the host it actually documents (api.bcb.gov.br, this quickstart'sbaseUrl).