Currency exchange rate converter SDK powered by Frankfurter API and Pontx.
A TypeScript SDK for accessing foreign exchange rates and currency conversion data. The API is provided by Frankfurter, a free and open-source currency data API that tracks reference exchange rates published by the European Central Bank.
- Full TypeScript Support: Complete type definitions for all API methods and responses
- Auto-completion: IntelliSense support in your IDE for all available currencies and parameters
- Compile-time Safety: Catch errors during development, not at runtime
- Generated from OpenAPI: SDK is auto-generated from the official OpenAPI specification, ensuring accuracy and up-to-date types
- Interactive Commands: Access all API features directly from your terminal
- Shell Completion: Built-in completion support for bash, zsh, and fish shells
- No Code Required: Quickly check exchange rates without writing any code
- Scriptable: Perfect for shell scripts and automation workflows
- Help System: Comprehensive help documentation for every command
- Type-safe TypeScript SDK for accessing Frankfurter API
- Latest and historical exchange rates
- Time series data support
- Command-line interface (CLI)
- Full TypeScript type definitions
npm install currency-exchange-client
# or
pnpm add currency-exchange-client
# or
yarn add currency-exchange-clientimport currencyExchangeClient from "currency-exchange-client";
async function main() {
// Get latest exchange rates
const response = await currencyExchangeClient.exchangeRates.getLatestRates({
base: "USD",
symbols: "JPY,CNY",
});
console.log(response);
}
main();Output:
{
"amount": 1,
"base": "USD",
"date": "2024-01-15",
"rates": {
"JPY": 148.5,
"CNY": 7.18
}
}Retrieves the most recent exchange rates. Rates are updated daily around 16:00 CET.
const rates = await currencyExchangeClient.exchangeRates.getLatestRates({
amount: 100, // Optional: amount to convert (default: 1)
base: "USD", // Optional: base currency (default: EUR)
symbols: "JPY,CNY", // Optional: comma-separated currency codes
});Response:
{
amount: 100,
base: "USD",
date: "2024-01-15",
rates: {
JPY: 14850.5,
CNY: 718.2
}
}Retrieves exchange rates for a specific date. Historical data is available from 1999-01-04 onwards.
const historicalRates =
await currencyExchangeClient.exchangeRates.getHistoricalRates(
"2024-01-01", // Date in YYYY-MM-DD format
{
base: "USD",
symbols: "EUR,GBP",
}
);Response:
{
amount: 1,
base: "USD",
date: "2024-01-01",
rates: {
EUR: 0.91,
GBP: 0.79
}
}Retrieves exchange rates for a date range, returning daily rates between the start and end dates.
const timeSeries =
await currencyExchangeClient.exchangeRates.getTimeSeriesRates(
"2024-01-01", // Start date
"2024-01-31", // End date
{
base: "USD",
symbols: "EUR",
}
);Response:
{
amount: 1,
base: "USD",
start_date: "2024-01-01",
end_date: "2024-01-31",
rates: {
"2024-01-01": { EUR: 0.91 },
"2024-01-02": { EUR: 0.92 },
"2024-01-03": { EUR: 0.91 },
// ... daily rates for the entire date range
}
}Returns a list of all currency codes supported by the API along with their full names.
const currencies = await currencyExchangeClient.Currencies.getCurrencies();Response:
{
AUD: "Australian Dollar",
BRL: "Brazilian Real",
CAD: "Canadian Dollar",
CHF: "Swiss Franc",
CNY: "Chinese Renminbi Yuan",
// ... all supported currencies
USD: "United States Dollar",
ZAR: "South African Rand"
}The API supports the following currency codes: AUD, BRL, CAD, CHF, CNY, CZK, DKK, EUR, GBP, HKD, HUF, IDR, ILS, INR, ISK, JPY, KRW, MXN, MYR, NOK, NZD, PHP, PLN, RON, SEK, SGD, THB, TRY, USD, ZAR
This package provides a command-line interface for quick currency conversions and rate lookups.
After installation, you can use the currency command:
# Get latest exchange rates
currency exchangeRates getLatestRates --base USD --symbols JPY,CNY
# Get historical rates
currency exchangeRates getHistoricalRates 2024-01-01 --base USD --symbols EUR
# Get time series data
currency exchangeRates getTimeSeriesRates 2024-01-01 2024-01-31 --base USD
# List supported currencies
currency Currencies getCurrenciesTo see all available commands and options:
currency --help
# Get help for a specific module
currency exchangeRates --help
# Get help for a specific command
currency exchangeRates getLatestRates --helpThe CLI supports shell completion for bash, zsh, and fish.
Add to your ~/.bashrc:
eval "$(currency completion bash)"Or generate completion script to a file:
currency completion bash > /etc/bash_completion.d/currencyAdd to your ~/.zshrc:
eval "$(currency completion zsh)"Or generate completion script:
currency completion zsh > "${fpath[1]}/_currency"Generate completion script:
currency completion fish > ~/.config/fish/completions/currency.fishThis SDK is generated using Pontx, a powerful OpenAPI SDK generator. You can use the generic pontx CLI to access the same functionality.
First, install pontx globally or as a dev dependency:
npm install -g pontx
# or
npm install -D pontxThe pontx CLI provides the same capabilities as the currency CLI:
# Execute API calls using pontx
pontx execute currency exchangeRates getLatestRates --base USD --symbols JPY,CNY
# With custom configuration
pontx execute --config pontx.config.ts currency exchangeRates getLatestRates --base USD
# Generate SDK from OpenAPI spec
pontx generate
# Build CLI
pontx cli buildThe project includes a pontx.config.ts file that configures the SDK generation:
import { defineConfig } from "pontx";
export default defineConfig({
outDir: "src/apis",
origins: [
{
name: "currency",
localPath: "./openapi.json",
},
],
});# Generate TypeScript SDK from OpenAPI spec
pontx generate
# Build standalone CLI
pontx cli build
# Execute API directly via CLI
pontx execute [origin] [module] [method] [...args]
# Show available APIs
pontx list
# Validate OpenAPI specification
pontx validate# Install dependencies
pnpm install
# Generate SDK from OpenAPI spec
pnpm pontx
# Build the package
pnpm build
# Run example
pnpm example
# Type checking
pnpm type-check- Node.js >= 18.0.0
MIT
- Frankfurter API - Official Frankfurter API website
- Frankfurter API Documentation - API documentation