DEV Community

Madhushan
Madhushan

Posted on

@allratestoday/sdk: The Official JavaScript SDK for Real-Time Exchange Rates

Wiring a currency API into a Node or browser app shouldn't take more than a few minutes. With the @allratestoday/sdk package, it doesn't.

It's the official JavaScript SDK for the AllRatesToday API — a real-time FX service backed by Reuters/Refinitiv and interbank feeds — and it covers everything the raw API does, with TypeScript types, zero runtime dependencies, and an ergonomic surface.

Why this SDK

  • Zero runtime dependencies — pure TypeScript, uses native fetch
  • 📡 Real-time data — rates refreshed every 60 seconds from Reuters (Refinitiv) and interbank feeds
  • 💹 Mid-market rates — the true interbank rate, no hidden spread
  • 🌍 160+ currencies — major, minor, and exotic pairs (plus precious metals)
  • 🔷 Type-safe — full TypeScript, intelligent autocomplete, strongly typed responses
  • 🌐 Universal — works in Node.js 18+ and modern browsers

Install

npm install @allratestoday/sdk
Enter fullscreen mode Exit fullscreen mode

Grab a free API key at allratestoday.com/register — no credit card required.

Quick start

import AllRatesToday from '@allratestoday/sdk';

const client = new AllRatesToday({ apiKey: 'YOUR_API_KEY' });

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

console.log(rates);
// { EUR: 0.92, GBP: 0.78, JPY: 149.5 }
Enter fullscreen mode Exit fullscreen mode

Latest rates

Get all rates against a base, or filter to the pairs you actually need:

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

// Just the ones you care about — cheaper payload, same response shape
const subset = await client.latest({
  base: 'USD',
  symbols: ['CHF', 'GBP', 'JPY'],
});
Enter fullscreen mode Exit fullscreen mode

Historical rates

Look up rates for a specific date — ideal for reporting, invoice re-calculation, or compliance workflows:

const historical = await client.historical({
  date: '2025-12-31',
  base: 'USD',
  symbols: ['EUR', 'GBP'],
});
Enter fullscreen mode Exit fullscreen mode

Currency conversion

Skip the math and ask for an amount:

const converted = await client.convert({
  from: 'USD',
  to: 'EUR',
  amount: 100,
});

console.log(converted);
// { from: "USD", to: "EUR", amount: 100, converted: 92.34, rate: 0.9234 }
Enter fullscreen mode Exit fullscreen mode

Time-series data

For charts and trend analysis, request a range:

const series = await client.timeseries({
  base: 'USD',
  symbols: ['EUR'],
  startDate: '2026-01-01',
  endDate: '2026-04-01',
});
Enter fullscreen mode Exit fullscreen mode

Chart that straight into Recharts / Chart.js / your tool of choice.

Preset period lookups

Sometimes you want "last 7 days" without calculating dates yourself:

const lastWeek = await client.historicalByPeriod({
  base: 'USD',
  symbols: ['EUR'],
  period: '7d', // '1d' | '7d' | '30d' | '1y'
});
Enter fullscreen mode Exit fullscreen mode

Node or browser — it doesn't care

The SDK uses native fetch, so it runs the same in:

  • Node.js 18+
  • Modern browsers
  • Cloudflare Workers, Vercel Edge, Deno, Bun

No polyfills, no adapter packages, no version-specific builds.

When to pick @allratestoday/sdk vs the smaller packages

The AllRatesToday ecosystem has a few Node packages, each with a different scope:

Package Scope
@allratestoday/sdk Full API surface — latest, historical, time-series, conversion
fx-rates Minimal rate() / convert() + a CLI
moneyify cashify-compatible conversion with optional auto-fetch
live-currency-rates Multi-provider wrapper (Frankfurter, fawaz, AllRatesToday)

If you need the full API (especially historical and time-series), use @allratestoday/sdk. If you just want to convert two currencies, start with fx-rates.

Next steps

Happy converting.

Top comments (0)