UNPKG

@abskmj/exchangeratesapi

Version:
176 lines (113 loc) 3.84 kB
<!-- Generated by documentation.js. Update this documentation by updating the source code. --> ### Table of Contents * [exchange][1] * [symbols][2] * [Parameters][3] * [Examples][4] * [rates][5] * [Parameters][6] * [Examples][7] * [convert][8] * [Parameters][9] * [Examples][10] * [timeseries][11] * [Parameters][12] * [Examples][13] * [fluctuation][14] * [Parameters][15] * [Examples][16] ## exchange Javascript client for exchangeratesapi.io Import the client const exchange = require('@abskmj/exchangeratesapi') ### symbols Get exchange symbols #### Parameters * `access_key` **[string][17]** API Key #### Examples ```javascript exchange.symbols({ access_key: '<API_KEY>' }) ``` Returns **Axios.Response** [Response][18] from Axios module ### rates Get exchange rates #### Parameters * `access_key` **[string][17]** API Key * `date` **[string][17]** Date in YYYY-MM-DD format (optional, default `latest`) * `base` **[string][17]** Currency against which rates are quoted (optional, default `EUR`) * `symbols` **[string][17]?** Comma separated currencies for which rates are needed #### Examples ```javascript // get latest rates exchange.rates({ access_key: '<API_KEY>' }) ``` ```javascript // get latest rates for a base symbol exchange.rates({ access_key: '<API_KEY>', base: 'USD' }) ``` ```javascript // get latest rates in specific symbols exchange.rates({ access_key: '<API_KEY>', symbols: 'USD,GBP' }) ``` ```javascript // get rates on a specific date exchange.rates({ access_key: '<API_KEY>', date: '2010-01-12' }) ``` Returns **Axios.Response** [Response][18] from Axios module ### convert Get converted amount #### Parameters * `access_key` **[string][17]** API Key * `from` **[string][17]** Symbol converted from * `to` **[string][17]** Symbol converted to * `amount` **[string][17]** Amount to be converted * `date` **[string][17]?** Date in YYYY-MM-DD format #### Examples ```javascript exchange.convert({ access_key, from: 'USD', to: 'EUR', amount: 1 }) ``` Returns **Axios.Response** [Response][18] from Axios module ### timeseries Get historical exchange rates #### Parameters * `access_key` **[string][17]** API Key * `start_at` **[string][17]** State date in YYYY-MM-DD format * `end_at` **[string][17]** End date in YYYY-MM-DD format * `base` **[string][17]** Currency against which rates are quoted (optional, default `EUR`) * `symbols` **[string][17]?** Comma separated currencies for which rates are needed #### Examples ```javascript exchange.timeseries({ access_key: '<API_KEY>', start_at: '2020-01-01', end_at: '2020-03-31' }) ``` Returns **Axios.Response** [Response][18] from Axios module ### fluctuation Get fluctuations #### Parameters * `access_key` **[string][17]** API Key * `start_at` **[string][17]** State date in YYYY-MM-DD format * `end_at` **[string][17]** End date in YYYY-MM-DD format * `base` **[string][17]** Currency against which rates are quoted (optional, default `EUR`) * `symbols` **[string][17]?** Comma separated currencies for which rates are needed #### Examples ```javascript exchange.fluctuation({ access_key: '<API_KEY>', start_at: '2020-01-01', end_at: '2020-03-31' }) ``` Returns **Axios.Response** [Response][18] from Axios module [1]: #exchange [2]: #symbols [3]: #parameters [4]: #examples [5]: #rates [6]: #parameters-1 [7]: #examples-1 [8]: #convert [9]: #parameters-2 [10]: #examples-2 [11]: #timeseries [12]: #parameters-3 [13]: #examples-3 [14]: #fluctuation [15]: #parameters-4 [16]: #examples-4 [17]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String [18]: https://github.com/axios/axios#response-schema