A lightweight, modern JavaScript/TypeScript client for OpenExchangeAPI — built for browsers and Node.js.
- ✅ Full API support
- 🔑 Optional API key
- 🌐 Works in browsers and Node.js
- 🧠 TypeScript types included
npm install @openexchangeapi/sdk
Or load directly in the browser via CDN:
<script type="module">
import { OpenExchangeApiClient } from 'https://unpkg.com/@openexchangeapi/sdk@latest/src/oex.js';
</script>
Also available via jsDelivr:
<script type="module">
import { OpenExchangeApiClient } from 'https://cdn.jsdelivr.net/npm/@openexchangeapi/sdk@latest/src/oex.js';
</script>
import { OpenExchangeApiClient } from '@openexchangeapi/sdk';
const client = new OpenExchangeApiClient(); // optional
const latest = await client.getLatest();
const converted = await client.convert({
from: 'USD',
to: 'EUR',
amount: 100,
});
const currencies = await client.listCurrencies();
const eur = await client.getCurrency({ code: 'EUR' });
console.log(latest);
console.log(converted);
console.log(currencies);
console.log(eur);
client.getLatest(base?: string)
client.getLatestPrecise(base?: string)
client.getHistorical(date: string, base?: string)
client.getHistoricalPrecise(date: string, base?: string)
client.convert(from: string, to: string, amount: number)
client.convertPrecise(from: string, to: string, amount: number)
client.listCurrencies(type?: 'fiat' | 'crypto' | 'virtual')
client.getCurrency(code: string)
All methods return Promise<T>
. Errors throw OpenExchangeApiError
.
try {
const result = await client.getLatest();
} catch (err) {
console.error('OpenExchangeAPI error:', err.message);
}
-
unpkg:
https://unpkg.com/@openexchangeapi/sdk@latest/src/oex.js
-
jsDelivr:
https://cdn.jsdelivr.net/npm/@openexchangeapi/sdk@latest/src/oex.js
-
GitHub CDN (via jsDelivr):
https://cdn.jsdelivr.net/gh/OpenExchangeAPI/sdk-javascript@vlatest/src/oex.js