How do I get real-time exchange rates in JavaScript / Node.js? #1
Answered
by
cahthuranag
cahthuranag
asked this question in
Q&A
-
|
I need to fetch live exchange rates in my Node.js backend. What's the simplest way to do it? AnswerInstall the official SDK: npm install @exchangerateapi/sdkThen use it: import { ExchangeRateAPI } from '@exchangerateapi/sdk';
const client = new ExchangeRateAPI({ apiKey: 'era_live_YOUR_KEY' });
// 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}`);The SDK is zero-dependency, supports both ESM and CommonJS, and has full TypeScript types. Get your free API key at exchange-rateapi.com/register. |
Beta Was this translation helpful? Give feedback.
Answered by
cahthuranag
Jun 21, 2026
Replies: 1 comment
-
|
Install the official SDK: npm install @exchangerateapi/sdkThen use it: import { ExchangeRateAPI } from '@exchangerateapi/sdk';
const client = new ExchangeRateAPI({ apiKey: 'era_live_YOUR_KEY' });
// 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}`);The SDK is zero-dependency, supports both ESM and CommonJS, and has full TypeScript types. Get your free API key at exchange-rateapi.com/register. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
cahthuranag
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install the official SDK:
Then use it:
The SDK is zero-dependency, supports both ESM and CommonJS, and has full TypeScript types.
Get your free API key at exchange-rateapi.com/register.