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

currency-rate-fetcher

v0.1.0

Published

Fetch currency rates from ECB, FloatRates, or Open Exchange Rates

Readme

currency-rate-fetcher

Fetch up-to-date foreign exchange rates from one of three providers:

  • ECB – the European Central Bank daily XML feed (default).
  • FloatRates (FRC) – daily XML feed from floatrates.com, available per base currency.
  • Open Exchange Rates (OXR) – JSON API; free tier provides USD base data (requires an app id).

Installation

npm install currency-rate-fetcher

Usage

const { fetchCurrencies, fetchCurrency } = require("currency-rate-fetcher");

// Full table for the default (ECB) provider
const snapshot = await fetchCurrencies(); // provider defaults to "ecb", base defaults to "EUR"

// Switch provider and base currency
const usdRates = await fetchCurrencies("oxr", "USD", { appId: process.env.OXR_TOKEN });

// Ask for a single currency value (throws if missing)
const nokFromEcb = await fetchCurrency("ecb", "NOK"); // -> { currency: "NOK", value: <number> }

fetchCurrencies(provider = "ecb", baseCurrency = "EUR", options = {})

Returns a Promise resolving to:

{
  "status": "OK",
  "fetchedAt": "2025-10-18T14:21:19.298Z",
  "source": "<provider URL>",
  "date": "2025-10-17",
  "base": "EUR",
  "rates": {
    "EUR": 1,
    "USD": 1.1,
    "...": "..."
  }
}

Provider-specific notes:

  • ecb – accepts options.currencyUrl to override the XML endpoint, or options.fetcher to supply a custom HTTP getter.
  • frc – accepts options.url or options.fetcher; base currency determines the FloatRates URL (https://www.floatrates.com/daily/<base>.xml).
  • oxr – requires options.appId (or environment variable OXR_APP_ID / OPEN_EXCHANGE_RATES_APP_ID). Always requests USD data and cross-converts if another base is requested. You can override the API endpoint via options.baseUrl. The example script also honours OXR_TOKEN for convenience.

fetchCurrency(provider = "ecb", currency = "NOK", baseCurrency = "EUR", options = {})

Resolves to { currency: "NOK", value: <number> }. The helper simply calls fetchCurrencies under the hood, so the same options apply.

CLI test helper

A simple example script is included at examples/test-currency.js:

node examples/test-currency.js ecb NOK
node examples/test-currency.js frc USD
OXR_TOKEN=your_app_id node examples/test-currency.js oxr NOK

It prints both the full snapshot and the single currency lookup for quick verification.

License

MIT