@miekassu/js-oxr
v1.0.1
Published
Open Exchange Rates API module for nodejs
Downloads
3
Readme
Open Exchange Rates
Simplifyied Node.js client for the Open Exchange Rates API. Project.
Client is designed to return Promises.
Install
npm install --save @miekassu/js-bkkbank
Usage
OPENEXCHANGE_APP_ID is needed. You can find one from here.
To pass needed key to client, please use OPENEXCHANGE_APP_ID
ENV variable.
After that require mode:
const oxr = require('@miekassu/js-oxr');
oxr.getLatestRates('USD')
.then(resp =>{
console.log(resp)
})
Service API
getLatestRates
getHistoricalRates
getLatestRates()
@params currencybase (required) - Currency base string: USD
.
@params symbols (optional) - String array, ['EUR', 'THB', 'GBP']
. If passed, only given curencypairs will be returned.
@returns - A promise with the list all latest rates.
Example:
getLatestRates('USD')
.then(resp => {
console.log(resp)
})
getHistoricalRates()
@params currencybase (required) - Currency base string: USD
.
@params date (required) - Date string in form: YYYY-MM-DD
: 2019-10-20
. If Date paramater is not passed. Rates from current date are returned.
@params symbols (optional) - String array, ['EUR', 'THB', 'GBP']
. If passed, only given curencypairs will be returned.
@returns - A promise with the list of rates at the requested date.
Example:
getHistoricalRates('USD', '2019-10-20', ['EUR', 'THB', 'GBP'])
.then(resp => {
console.log(resp)
})