Effortlessly converts currency values between different denominations, utilizing the latest pricing data available from the frankfurter.app API.
npm install -D @m00nbyte/currency-converter
yarn add -D @m00nbyte/currency-converter
Type: string | number
Default: undefined
Specifies the amount to convert. If only this parameter is provided, it is considered as the base currency.
Type: string | null
Default: null
Specifies the currency code for the base currency. Defaults to null for automatic detection.
Type: string | null
Default: null
Specifies the currency code for the target currency. Defaults to null for automatic detection.
import fx from '@m00nbyte/currency-converter';
const usdRates = await fx();
console.log(usdRates);
import fx from '@m00nbyte/currency-converter';
const eurRates = await fx('eur');
console.log(eurRates);
import fx from '@m00nbyte/currency-converter';
const conversionResult = await fx(100, 'eur');
console.log('Converted 100 EUR to all available currencies:', conversionResult);
import fx from '@m00nbyte/currency-converter';
const conversionResult = await fx(100, 'eur', 'usd');
console.log(`Converted 100 EUR to USD: ${conversionResult}`);
Type: Number
Default: undefined
Specifies the amount for the conversion.
Type: String
Default: undefined
Sets the base currency for the conversion.
Type: String
Default: undefined
Sets the target currency for the conversion and returns the converted amount.
import fx from '@m00nbyte/currency-converter';
const conversionResult = await fx(100).from('eur').to('usd');
console.log(`Converted 100 EUR to USD: ${conversionResult}`);
Feel free to submit issues or pull requests.
This project needs a ⭐ from you. Don't forget to leave a star.