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

frankfurter-api-client-v2

v1.0.0

Published

A lightweight, dependency-minimal TypeScript client for the Frankfurter API-V2, providing easy access to latest, historical, and time-series currency exchange rates.

Readme

Banner api_version npm downloads license NPM Unpacked Size

frankfurter-api-client: v2

A lightweight, type-safe JavaScript/TypeScript client for the Frankfurter Currency Exchange Rates API (Version 2), designed for developers who want clean abstractions, strong date validation, and a minimal API surface. This package wraps the Frankfurter API with strict input validation, predictable error handling, and zero runtime configuration.

This is the V2 version of the client, powered by the official Frankfurter API V2. No API Keys are required.

📦 Installation

npm install frankfurter-api-client-v2

📘 Features

  1. TypeScript-first with full type definitions
  2. Strict date validation (including leap years & future dates)
  3. Supports historical rates, time-series queries, currency info, and provider data
  4. Minimal dependencies: dayjs only
  5. Clean, promise-based API - Works in both Node.js and modern browsers

📕 Error Handling

All functions in this package are async and may throw errors due to network issues, invalid input, or API errors. Always wrap your calls in try-catch blocks to handle errors gracefully:

try {
  const data = await getLatestRates({ base: 'EUR' });
  console.log(data);
} catch (error) {
  console.error('Failed to get rates:', error.message);
}

🔤 Example Usage

  1. 📁 Get Latest Exchange Rates
import { getLatestRates } from 'frankfurter-api-client-v2';

async function myFunc() {
  try {
    const response = await getLatestRates({
      base: 'EUR',
      quotes: ['USD', 'INR'] /* optional input. for specific currency codes. */,
    });
    console.log(response);
  } catch (error) {
    console.error('Failed to get latest rates:', error.message);
  }
}
/* call */
await myFunc();

/* Sample Response Schema: 200-OK
[
  {
    "date": "2026-04-29",
    "base": "EUR",
    "quote": "AED",
    "rate": 4.2989
  },
  ...
  ...
]
*/
  1. 📁 Get Historical Rates For Specific Date
import { getHistoricalRatesForDate } from 'frankfurter-api-client-v2';

async function myFunc() {
  try {
    const data = await getHistoricalRatesForDate({
      base: 'USD',
      period: { date: 1, month: 5, year: 2015 },
      quotes: ['EUR', 'GBP'] /* optional input. for specific currency codes. */,
    });
    console.log(data);
  } catch (error) {
    console.error('Failed to get historical rates:', error.message);
  }
}
/* call */
await myFunc();

/* Sample Response Schema: 200-OK
[
  {
    "date": "1999-01-04",
    "base": "EUR",
    "quote": "AED",
    "rate": 4.3151
  },
  ...
  ...
]
*/
  1. 📁 Get Time Series Rates Between Two Dates
import { getTimeSeriesRates } from 'frankfurter-api-client-v2';

async function myFunc() {
  try {
    const data = await getTimeSeriesRates({
      base: 'EUR',
      from: { date: 1, month: 1, year: 2025 },
      to: { date: 5, month: 1, year: 2025 },
      quotes: ['USD', 'THB'] /* optional input. for specific currency codes. */,
    });
    console.log(data);
  } catch (error) {
    console.error('Failed to get time series rates:', error.message);
  }
}
/* call */
await myFunc();

/* Sample Response Scheme: 200-OK
[
  {
    "date": "2026-01-01",
    "base": "EUR",
    "quote": "USD",
    "rate": 1.1751
  },
  ...
  ...
]
*/
  1. 📁 Get Supported Currencies
import { getSupportedCurrencies } from 'frankfurter-api-client-v2';

async function myFunc() {
  try {
    const data = await getSupportedCurrencies({
      legacy: false,
    }); /* if true, then gives legacy as well */
    console.log(data);
  } catch (error) {
    console.error('Failed to get supported currencies:', error.message);
  }
}
/* call */
await myFunc();

/* Sample Response Schema: 200-OK
[
  {
    "iso_code": "IMP",
    "iso_numeric": "",
    "name": "Isle of Man Pound",
    "symbol": "£",
    "start_date": "1949-12-21",
    "end_date": "2026-04-29"
  },
  ...
  ...
]
*/
  1. 📁 Get Currency Info
import { getCurrencyInfo } from 'frankfurter-api-client-v2';

async function myFunc() {
  try {
    const data = await getCurrencyInfo({
      code: 'EUR' /* required - currency code */,
    });
    console.log(data);
  } catch (error) {
    console.error('Failed to get currency info:', error.message);
  }
}
/* call */
await myFunc();

/* Sample Response Schema: 200-OK
{
  "iso_code": "EUR",
  "iso_numeric": "978",
  "name": "Euro",
  "symbol": "€",
  "start_date": "1993-01-04",
  "end_date": "2026-04-29",
  "providers": ["BAM", "BANXICO", "BCB"..., ..., ...]
}
*/
  1. 📁 Get All Providers
import { getAllProviders } from 'frankfurter-api-client-v2';

async function myFunc() {
  try {
    const data = await getAllProviders();
    console.log(data);
  } catch (error) {
    console.error('Failed to get all providers:', error.message);
  }
}
/* call */
await myFunc();

/*
[
  {
    "key": "FBIL",
    "name": "Financial Benchmarks India",
    "country_code": "IN",
    "rate_type": "reference rate",
    "pivot_currency": "INR",
    "data_url": "https://www.fbil.org.in/#/refrates",
    "terms_url": "https://www.fbil.org.in/#/termsandcondition",
    "start_date": "2018-07-10",
    "end_date": "2026-04-22",
    "publishes_missed": 4,
    "currencies": [
      "AED",
      "EUR",
      "GBP",
      "IDR",
      "INR",
      "JPY",
      "USD"
    ]
  },
  ...
  ...
]
*/

📗 Test Coverage

PASS src/get-supported-currencies/tests/get-supported-currencies.test.ts
  Get Supported Currencies
    ✓ returns ok response, legacy false
    ✓ returns ok response, legacy true
    ✓ throws fetch error, when there is no connectivity

PASS src/get-latest-rates/tests/get-latest-rates.test.ts
  Get Latest Rates
    ✓ returns ok response, with base currency code only
    ✓ throws fetch error, when there is no connectivity
    ✓ throws error when base currency is invalid
    ✓ returns ok response, with base currency code and quotes

PASS src/get-historical-rates/tests/get-historical-rates.test.ts
  Get Historical Rates
    ✓ returns ok response, with base currency code and period
    ✓ throws fetch error, when there is no connectivity
    ✓ throws error when base currency is invalid
    ✓ returns ok response, with base currency code, period and quotes

PASS src/get-all-providers/tests/get-all-providers.test.ts
  Get All Providers
    ✓ returns ok response, 200 status
    ✓ throws fetch error, when there is no connectivity

PASS src/get-currency-info/tests/get-currency-info.test.ts
  Get Currency Info
    ✓ returns ok response, 200 status
    ✓ throws error, 404 status
    ✓ throws fetch error, when there is no connectivity

PASS src/get-timeseries-rates/tests/get-timeseries-rates.test.ts
  Get TimeSeries Rates
    ✓ returns ok response, with base currency code, from and to
    ✓ throws fetch error, when there is no connectivity
    ✓ throws error when base currency is invalid
    ✓ returns ok response, with base currency code, from, to and quotes
    ✓ throws validation error when from date is after to date

Test Suites: 6 passed, 6 total
Tests:       21 passed, 21 total
Snapshots:   0 total
--------------------------------|---------|----------|---------|---------|-------------------
File                            | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------------------------|---------|----------|---------|---------|-------------------
All files                       |   98.72 |    90.41 |     100 |   98.72 |
 get-all-providers              |      96 |       75 |     100 |      96 |
  index.ts                      |      96 |       75 |     100 |      96 | 18
 get-all-providers/tests        |     100 |      100 |     100 |     100 |
  msw-handlers.ts               |     100 |      100 |     100 |     100 |
 get-currency-info              |     100 |      100 |     100 |     100 |
  index.ts                      |     100 |      100 |     100 |     100 |
 get-currency-info/tests        |     100 |      100 |     100 |     100 |
  msw-handlers.ts               |     100 |      100 |     100 |     100 |
 get-historical-rates           |     100 |      100 |     100 |     100 |
  index.ts                      |     100 |      100 |     100 |     100 |
 get-historical-rates/tests     |     100 |      100 |     100 |     100 |
  msw-handlers.ts               |     100 |      100 |     100 |     100 |
 get-latest-rates               |     100 |      100 |     100 |     100 |
  index.ts                      |     100 |      100 |     100 |     100 |
 get-latest-rates/tests         |     100 |      100 |     100 |     100 |
  msw-handlers.ts               |     100 |      100 |     100 |     100 |
 get-supported-currencies       |    90.9 |    83.33 |     100 |    90.9 |
  index.ts                      |    90.9 |    83.33 |     100 |    90.9 | 24-26
 get-supported-currencies/tests |     100 |      100 |     100 |     100 |
  data.ts                       |     100 |      100 |     100 |     100 |
  msw-handlers.ts               |     100 |      100 |     100 |     100 |
 get-timeseries-rates           |     100 |      100 |     100 |     100 |
  index.ts                      |     100 |      100 |     100 |     100 |
 get-timeseries-rates/tests     |     100 |      100 |     100 |     100 |
  msw-handler.ts                |     100 |      100 |     100 |     100 |
 shared                         |   91.07 |    28.57 |     100 |   91.07 |
  index.ts                      |     100 |      100 |     100 |     100 |
  msw-mock-server.ts            |     100 |      100 |     100 |     100 |
  validate-and-format-date.ts   |   87.17 |    16.66 |     100 |   87.17 | 17,19,21,29,31
--------------------------------|---------|----------|---------|---------|-------------------

🗂 Related NPM Packages

  1. Frankfurter API Client: V1: https://www.npmjs.com/package/frankfurter-api-client
  2. Frankfurter API Client: V2: https://www.npmjs.com/package/frankfurter-api-client-v2
  3. Frankfurter API Status Client: https://www.npmjs.com/package/frankfurter-api-status-client

📘 Contributing

Contributions, suggestions, and improvements are welcome. Feel free to open issues or pull requests.

❤️ Support

Like this project? Support it with a github star, it would mean a lot to me! Cheers and Happy Coding.