Skip to content
Discussion options

You must be logged in to vote

Install the official SDK:

npm install @exchangerateapi/sdk

Then 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.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by cahthuranag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant