Skip to content

Official JavaScript SDK for OpenExchangeAPI — easy access to FX rates and currency info in browser and Node.js apps.

License

Notifications You must be signed in to change notification settings

OpenExchangeAPI/sdk-javascript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenExchangeAPI JavaScript SDK

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

📦 Installation

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>

🚀 Usage

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);

🧩 API Reference

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.


❗ Error Handling

try {
  const result = await client.getLatest();
} catch (err) {
  console.error('OpenExchangeAPI error:', err.message);
}

🔗 CDN Access

  • 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


📄 License

See: https://openexchangeapi.com/api-license

About

Official JavaScript SDK for OpenExchangeAPI — easy access to FX rates and currency info in browser and Node.js apps.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published