Welcome to the currapi documentation. Learn how to integrate with our API to access historical currency exchange rates.
Install the @appaka/currapi package using npm, yarn, or pnpm:
npm install @appaka/currapiThe @appaka/currapi package provides a simple and intuitive API for accessing currency exchange rates.
First, initialize the client with your API key:
import { CurrAPIClient } from '@appaka/currapi'
// Initialize the client with your API key
const currapi = new CurrAPIClient(process.env.CURRAPI_API_KEY!)Optionally, implement caching functions to reduce the number of requests to currapi.com:
import Redis from 'ioredis'
import { CurrAPIClient } from '@appaka/currapi'
const redis = new Redis(process.env.REDIS_URL!)
const currapi = 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),
})
Fetch the exchange rate between two currencies for a specific date:
// Get exchange rate
const rate = await currapi.getRate('USD', 'EUR', '2023-01-15')
console.log(rate) // 0.92385671Convert an amount from one currency to another:
// Convert currency
const result = await currapi.convert(100, 'USD', 'EUR', '2023-01-15')
// Date is optional, defaults to current date
console.log(result) // 92.39 EURCurrAPI provides exchange rate data for 60 different assets across three categories: fiat currencies, cryptocurrencies, and precious metals.
You can access the list of supported currencies and their codes programmatically using the CURRENCIES constant from the npm package:
import { CURRENCIES } from '@appaka/currapi'
// CURRENCIES contains all supported currency codes
console.log(CURRENCIES)
// ['EUR', 'USD', 'JPY', 'BTC', 'ETH', 'XAU', ...]Below is the full list of all supported currencies, organized by category:
31 major world currencies from the European Central Bank
| Code | Name |
|---|---|
| AUD | Australian Dollar |
| BGN | Bulgarian Lev |
| BRL | Brazilian Real |
| CAD | Canadian Dollar |
| CHF | Swiss Franc |
| CNY | Chinese Yuan |
| CZK | Czech Koruna |
| DKK | Danish Krone |
| EUR | Euro |
| GBP | British Pound |
| HKD | Hong Kong Dollar |
| HUF | Hungarian Forint |
| IDR | Indonesian Rupiah |
| ILS | Israeli Shekel |
| INR | Indian Rupee |
| ISK | Icelandic Krona |
| JPY | Japanese Yen |
| KRW | South Korean Won |
| MXN | Mexican Peso |
| MYR | Malaysian Ringgit |
| NOK | Norwegian Krone |
| NZD | New Zealand Dollar |
| PHP | Philippine Peso |
| PLN | Polish Zloty |
| RON | Romanian Leu |
| SEK | Swedish Krona |
| SGD | Singapore Dollar |
| THB | Thai Baht |
| TRY | Turkish Lira |
| USD | US Dollar |
| ZAR | South African Rand |
25 major cryptocurrencies via Kraken API
| Code | Name |
|---|---|
| AAVE | Aave |
| ADA | Cardano |
| ALGO | Algorand |
| ATOM | Cosmos |
| AXS | Axie Infinity |
| BCH | Bitcoin Cash |
| BTC | Bitcoin |
| DOGE | Dogecoin |
| DOT | Polkadot |
| ETH | Ethereum |
| FIL | Filecoin |
| FLOW | Flow |
| HBAR | Hedera |
| LINK | Chainlink |
| LTC | Litecoin |
| MANA | Decentraland |
| SAND | The Sandbox |
| SOL | Solana |
| TRX | TRON |
| UNI | Uniswap |
| WBTC | Wrapped Bitcoin |
| XLM | Stellar |
| XMR | Monero |
| XRP | XRP |
| XTZ | Tezos |
4 precious metals with daily pricing
| Code | Name |
|---|---|
| XAG | Silver (Troy Ounce) |
| XAU | Gold (Troy Ounce) |
| XPD | Palladium (Troy Ounce) |
| XPT | Platinum (Troy Ounce) |