bazg-exchange-rate
v1.0.2
Published
Official Swiss Federal Office for Customs and Border Security (Switzerland) daily exchange rates — ~72 currencies vs CHF, history since 2000. Zero-dependency Node.js/TypeScript client.
Downloads
137
Maintainers
Readme
Swiss Federal Office for Customs and Border Security Exchange Rate API client
Official Swiss Federal Office for Customs and Border Security (Switzerland) daily exchange rates in Node.js / TypeScript — ~72 currencies against the CHF, with history back to 2000. Zero dependencies, works in Node 18+, Bun, Deno, and edge runtimes (uses global fetch).
These are the published tax authority 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 bazg-exchange-rateQuick start
import { getRate, getLatestRates } from 'bazg-exchange-rate';
// One pair at the official Swiss Federal Office for Customs and Border Security rate
const pair = await getRate('EUR', 'CHF', { apiKey: 'art_live_...' });
console.log(pair.rate, pair.rate_date); // e.g. EUR -> CHF 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 'bazg-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: 'EUR', target: 'CHF', from: '2026-01-01' },
{ apiKey: 'art_live_...' }
);Published vs derived rates
If Swiss Federal Office for Customs and Border Security does not print a pair directly, the API resolves it from the bank's table (inverse, or a cross rate via CHF) 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: tax authority rates API
License
MIT
