npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@financica/ecb-client

v0.1.0

Published

Tiny, zero-dependency client for the European Central Bank euro foreign-exchange reference rates, with historical single-day lookups and last-business-day fallback.

Downloads

98

Readme

@financica/ecb-client

Tiny, zero-dependency TypeScript client for the European Central Bank's euro foreign-exchange reference rates, with first-class support for historical single-day lookups and last-business-day fallback.

  • Authoritative source. Reads the ECB data API directly (dataflow EXR). No third-party middleman, no API key, no SLA in front of your numbers. ECB reference rates are the rates EU tax authorities accept for currency conversion (VAT Directive art. 91).
  • Point-in-time. Ask for a rate "on or before" any date; the ECB only publishes on TARGET business days, so weekends and holidays transparently resolve to the most recent prior business day. The effective date is reported back on every rate.
  • Cross rates. Every ECB rate is quoted against the euro; the client crosses two foreign currencies through EUR for you.
  • Tiny & typed. Zero runtime dependencies, ESM + CJS, strict types, an injectable fetch, and an in-process snapshot cache.

Install

npm install @financica/ecb-client

Requires Node 18+ (uses the global fetch).

Usage

import { EcbClient } from "@financica/ecb-client";

const ecb = new EcbClient();

// A single rate (units of the currency per 1 EUR) on a given day.
await ecb.getRate("USD", "2024-01-15");
// → { currency: "USD", rate: 1.0945, date: "2024-01-15" }

// Weekends/holidays fall back to the last business day; the effective
// date comes back on the result.
await ecb.getRate("USD", "2024-01-13"); // a Saturday
// → { currency: "USD", rate: 1.0942, date: "2024-01-12" }

// Convert an amount. Non-euro pairs cross through EUR.
await ecb.convert({ amount: 100, from: "USD", to: "EUR", date: "2024-01-15" });
// → { amount: 91.36…, rate: 0.9136…, from: "USD", to: "EUR",
//     requestedDate: "2024-01-15", rateDate: "2024-01-15" }

// Several currencies for one date, in a single request.
const snapshot = await ecb.getRates("2024-01-15", ["USD", "GBP", "CHF"]);
// → { requestedDate: "2024-01-15", rates: [ { currency, rate, date }, … ] }

API

new EcbClient(options?)

| option | default | description | | ----------- | -------------------------------------------- | -------------------------------------------------------- | | baseUrl | https://data-api.ecb.europa.eu/service | ECB data API base URL. | | fetch | global fetch | Custom fetch (testing, proxying). | | cache | unbounded in-process Map | Snapshot cache keyed by request. Pass null to disable. | | timeoutMs | 15000 | Per-request timeout. 0 disables it. |

getRate(currency, date) → Promise<ReferenceRate>

The rate for one currency on (or before) date. date is a YYYY-MM-DD string or a Date. EUR returns a unit rate without a network call. Throws NoRateError when no observation exists on or before the date.

getRates(date, currencies?) → Promise<RateSnapshot>

Rates for several currencies on (or before) date. Omit currencies to fetch every series the ECB publishes — note that discontinued series resolve to their own last-published date, so check each rate's date rather than assuming the requested one.

convert({ amount, from, to, date }) → Promise<ConvertResult>

Convert amount from one currency to another. Identical currencies are a no-op (no request). The result reports the applied rate and the rateDate actually used.

How rates are quoted

Every value is units of the quoted currency per 1 EUR (the ECB convention). So getRate("USD", …).rate === 1.0945 means 1 EUR = 1.0945 USD. To go from USD to EUR, divide; from EUR to USD, multiply; convert() handles both and the cross-currency case.

Caveats

  • Business days only. No observation on weekends or TARGET holidays; the client resolves to the last prior business day for you.
  • ~30 active currencies, all against EUR. Cross rates are computed through EUR. Discontinued series (e.g. ARS) still return, at a stale date.
  • Be a good citizen. The ECB data API is a public good with no SLA. The built-in cache deduplicates repeated lookups; cache aggressively in your app.

License

MIT © Financica