1.0.9 • Published 10 months ago

@openexchangeapi/sdk v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

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

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago