bcb-exchange-rate
v1.0.3
Published
Official Banco Central do Brasil (Brazil) daily exchange rates — ~155 currencies vs BRL, history since 2016. Zero-dependency Node.js/TypeScript client.
Downloads
263
Maintainers
Readme
Banco Central do Brasil Exchange Rate API client
Official Banco Central do Brasil (Brazil) daily exchange rates in Node.js / TypeScript — ~155 currencies against the BRL, with history back to 2016. Zero dependencies, works in Node 18+, Bun, Deno, and edge runtimes (uses global fetch).
These are the published central bank rates required for tax filings, customs valuations, audits, and compliant invoicing — not moving market rates. Every response carries the publisher's own publication date.
Powered by AllRatesToday. Get a free API key at allratestoday.com/register — 300 requests/month, no credit card.
Install
npm install bcb-exchange-rateQuick start
import { getRate, getLatestRates } from 'bcb-exchange-rate';
// One pair at the official Banco Central do Brasil rate
const pair = await getRate('USD', 'BRL', { apiKey: 'art_live_...' });
console.log(pair.rate, pair.rate_date); // e.g. USD -> BRL on the bank's own date
// The bank's full published table
const table = await getLatestRates({ apiKey: 'art_live_...' });
console.log(table.rate_date, table.rates.length);Historical data (paid plans)
import { getRatesForDate, getHistory } from 'bcb-exchange-rate';
// The official table for an invoice date — weekends/holidays return the
// most recent published date, flagged via published_on_requested_date.
const day = await getRatesForDate('2026-06-30', { apiKey: 'art_live_...' });
// Daily series for one pair
const series = await getHistory(
{ source: 'USD', target: 'BRL', from: '2026-01-01' },
{ apiKey: 'art_live_...' }
);Published vs derived rates
If Banco Central do Brasil does not print a pair directly, the API resolves it from the bank's table (inverse, or a cross rate via BRL) and flags it derived: true with the method — so official and computed values are never confused.
Notes
- Every request counts toward your AllRatesToday monthly quota. Rates change once per business day — cache a day's table locally and a small quota goes a long way.
- Latest rates are on every plan (including free); historical dates and time series need a paid plan.
- Full API reference: allratestoday.com/docs#central-bank · All covered sources: central bank rates API
License
MIT
