argy-usd
A simple and efficient library for fetching Argentine dollar exchange rates and performing currency conversions.
Installation
npm install argy-usdUsage
import { getDollarRates, convertUsdToArs, convertArsToUsd, pollDollarRates } from 'argy-usd';
// Get dollar rates
const rates = await getDollarRates({
source: "dolarapi",
cache: true,
dollarType: "cripto"
});
// Convert USD to ARS
const arsAmount = await convertUsdToArs(100, 'cripto', 'sell', "dolarapi");
// Convert ARS to USD
const usdAmount = await convertArsToUsd(10000, 'oficial', 'buy', "bluelytics");
// Poll dollar rates
const stopPolling = pollDollarRates({
interval: 1000,
onUpdate: (rates) => console.log(rates),
onError: (error) => console.error(error)
});
// Stop polling
stopPolling();Sources
License
This project is licensed under the MIT License. See the LICENSE file for details.