argy-usd
Version:
A simple and efficient library for fetching Argentine dollar exchange rates and performing currency conversions.
53 lines (35 loc) • 1.12 kB
Plain Text
A simple and efficient library for fetching Argentine dollar exchange rates and performing currency conversions.
```bash
npm install argy-usd
```
```ts
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();
```
- [Bluelytics](https://bluelytics.com.ar/)
- [DolarAPI](https://dolarapi.com/)
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
alestivanello99@hotmail.com