@appaka/currapi
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@appaka/currapi

Official Node.js client for currapi.com — a simple API for historical currency exchange rates.

📦 Install

npm install @appaka/currapi

or with Yarn:

yarn add @appaka/currapi

🚀 Usage

This client provides a modern and extensible way to interact with currapi.com, including automatic caching and validation.

🔐 Set your API key

We recommend using environment variables to store your API key:

CURRAPI_API_KEY=your_api_key_here

Get your API key.


CurrAPIClient class

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

🧰 With optional cache support

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),
})

🔁 API Reference

getRate(base, target, date?)

Fetches the exchange rate for a given date. Defaults to today if not provided.

convert(amount, base, target, date?)

Converts an amount from one currency to another using the rate for a given date.


💱 Supported Currencies

You can access the full list via:

import { CURRENCIES } from '@appaka/currapi'

console.log(CURRENCIES)
// ['EUR', 'USD', 'JPY', 'GBP', 'CHF', ...]

🧪 TypeScript Support

All methods are fully typed. You can also use:

import type { Currency } from '@appaka/currapi'

🧑‍💻 Author

Package Sidebar

Install

npm i @appaka/currapi

Weekly Downloads

14

Version

0.1.0

License

MIT

Unpacked Size

17 kB

Total Files

9

Last publish

Collaborators

  • javierperez