Official Node.js client for currapi.com — a simple API for historical currency exchange rates.
npm install @appaka/currapi
or with Yarn:
yarn add @appaka/currapi
This client provides a modern and extensible way to interact with currapi.com, including automatic caching and validation.
We recommend using environment variables to store your API key:
CURRAPI_API_KEY=your_api_key_here
import { CurrAPIClient } from '@appaka/currapi'
const client = new CurrAPIClient(process.env.CURRAPI_API_KEY!)
const rate = await client.getRate('USD', 'EUR', '2024-03-15')
const amount = await client.convert(100, 'USD', 'EUR', '2024-03-15')
import Redis from 'ioredis'
import { CurrAPIClient } from '@appaka/currapi'
const redis = new Redis(process.env.REDIS_URL!)
const client = new CurrAPIClient(process.env.CURRAPI_API_KEY!, {
verboseMode: true,
cacheGet: (base, target, date) => redis.get(`${date}:${base}${target}`),
cacheSet: (base, target, date, rate) =>
redis.set(`${date}:${base}${target}`, rate),
})
Fetches the exchange rate for a given date. Defaults to today if not provided.
Converts an amount from one currency to another using the rate for a given date.
You can access the full list via:
import { CURRENCIES } from '@appaka/currapi'
console.log(CURRENCIES)
// ['EUR', 'USD', 'JPY', 'GBP', 'CHF', ...]
All methods are fully typed. You can also use:
import type { Currency } from '@appaka/currapi'
- Developed by javierperez.com | @javierperez_com
- Powered by currapi.com | @CurrAPI_com