Is a wrapper of APIs to get currency and the exchange between two of them.
-
Instance source API to determinate where data come from.
import { Currencies, Source } from 'dolar-exchange-sdk'; const currency = new Currencies(Source.DOLAR_SI);
Note : Source enum has available sources, current list is:
- DOLAR_SI
- DOLAR_SI
-
initializing data is needed.
await currency.initiateData();
It will internally request for info and save data to be used, if you want to update the data then call this method whenever you need it.
- You can get Raw data parsed
response:
currency.getCurrency()
[ { label: 'oficial', ask: '123.39', bid: '117.39' }, { label: 'blue', ask: '207.5', bid: '204.5' } ]
- You can get exchange between two currencies.
amount, from and to parameters
response:
currency.getExchange({ amount : '300', from: CurrencySymbol.USD, to: CurrencySymbol.ARG })
[ {label: 'oficial', from: 'USD', to: 'ARG', ask: '37017', bid: '35217'}, {label: 'blue', from: 'USD', to: 'ARG', ask: '62250', bid: '61350' } ]
- Add configuration at factoryConfig.ts
- Add Strategy on /Strategy Folder, adding parseCurrencyData() is needed, use other strategies as reference.
See examples at examples folders, installing globally ts-node and do ts-node <filename.ts>
is recomended.