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

@exchangerateapi/sdk

v1.0.0

Published

Exchange Rate API — Real-time mid-market currency exchange rates for Node.js and browsers. 160+ currencies from Reuters/Refinitiv, zero dependencies, free tier.

Readme

@exchangerateapi/sdk

Official JavaScript/TypeScript SDK for Exchange Rate API. Access real-time and historical mid-market exchange rates for 160+ currencies. Zero dependencies.

Installation

npm install @exchangerateapi/sdk

Quick Start

import { ExchangeRateAPI } from '@exchangerateapi/sdk';

const client = new ExchangeRateAPI({ apiKey: 'era_live_...' });

// Get latest rates
const { rates } = await client.latest({ base: 'USD', symbols: ['EUR', 'GBP', 'JPY'] });
console.log(rates); // { EUR: 0.92, GBP: 0.78, JPY: 149.5 }

// Convert currencies
const result = await client.convert('USD', 'EUR', 1000);
console.log(`$1,000 = EUR ${result.result}`);

Authentication

All API requests require a Bearer token. Get your free API key at exchange-rateapi.com/register.

const client = new ExchangeRateAPI({ apiKey: 'era_live_your_key_here' });

The SDK sends the key as a Bearer token in the Authorization header automatically.

You can also override the API key on a per-request basis:

const data = await client.latest({ apiKey: 'era_live_other_key' });

Configuration

const client = new ExchangeRateAPI({
  apiKey: 'era_live_...',       // Required. Your API key.
  baseUrl: 'https://exchange-rateapi.com', // Optional. Default shown.
  timeout: 10000,               // Optional. Request timeout in ms. Default: 10000.
});

API Methods

latest(options?)

Get the latest exchange rates.

// All rates from USD
const data = await client.latest();

// Specific symbols with EUR base
const data = await client.latest({ base: 'EUR', symbols: ['USD', 'GBP', 'JPY'] });

console.log(data.base);  // 'EUR'
console.log(data.date);  // '2026-05-10T12:00:00Z'
console.log(data.rates); // { USD: 1.08, GBP: 0.85, JPY: 162.3 }

forDate(date, options?)

Get exchange rates for a specific historical date.

// Using a string
const data = await client.forDate('2026-01-15');

// Using a Date object
const data = await client.forDate(new Date('2026-01-15'));

// With options
const data = await client.forDate('2026-01-15', {
  base: 'EUR',
  symbols: ['USD', 'GBP'],
});

timeSeries(startDate, endDate, options?)

Get exchange rate time series between two dates.

const data = await client.timeSeries('2026-01-01', '2026-03-31', {
  base: 'USD',
  symbols: ['EUR', 'GBP'],
});

// Access rates by date
console.log(data.rates['2026-01-15']); // { EUR: 0.92, GBP: 0.78 }

convert(from, to, amount, options?)

Convert an amount between two currencies.

// Current rate
const result = await client.convert('USD', 'EUR', 1000);
console.log(`$1,000 = EUR ${result.result}`);

// Historical conversion
const result = await client.convert('USD', 'EUR', 1000, {
  date: '2026-01-15',
});
console.log(`Rate on Jan 15: ${result.rate}`);

getRate(from, to, amount?)

Get exchange rate between two currencies.

const rate = await client.getRate('USD', 'EUR');
console.log(`1 USD = ${rate.rate} EUR`);

// With amount
const rate = await client.getRate('USD', 'EUR', 1000);
console.log(`$1,000 = EUR ${rate.to.amount}`);

getRates(source, target)

Get authenticated exchange rates with metadata.

const rates = await client.getRates('USD', 'EUR');
rates.forEach(r => console.log(`${r.source}/${r.target}: ${r.rate} at ${r.time}`));

getHistoricalRates(source, target, period?)

Get historical rates by period. Supported periods: 1d, 7d, 30d, 1y.

const history = await client.getHistoricalRates('USD', 'EUR', '30d');
history.rates.forEach(point => {
  console.log(`${point.time}: ${point.rate}`);
});

symbols()

Get all supported currency symbols.

const { symbols } = await client.symbols();
console.log(symbols);
// { USD: 'United States Dollar', EUR: 'Euro', GBP: 'British Pound', ... }

// Build a currency dropdown
const options = Object.entries(symbols).map(([code, name]) => ({ code, name }));

Error Handling

import { ExchangeRateAPI, ExchangeRateAPIError } from '@exchangerateapi/sdk';

const client = new ExchangeRateAPI({ apiKey: 'era_live_...' });

try {
  const data = await client.latest();
} catch (err) {
  if (err instanceof ExchangeRateAPIError) {
    console.error(`API error: ${err.message} (status: ${err.status})`);
  }
}

CommonJS Usage

const { ExchangeRateAPI } = require('@exchangerateapi/sdk');

const client = new ExchangeRateAPI({ apiKey: 'era_live_...' });

License

MIT - see LICENSE for details.