Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chamini2/cached-open-exchange-rates-sdk
Open Exchange Rates SDK that caches results to avoid hitting the usage limit
https://github.com/chamini2/cached-open-exchange-rates-sdk
cache currency disk-cache exchange-rates node open-exchange-rates
Last synced: about 4 hours ago
JSON representation
Open Exchange Rates SDK that caches results to avoid hitting the usage limit
- Host: GitHub
- URL: https://github.com/chamini2/cached-open-exchange-rates-sdk
- Owner: chamini2
- License: bsd-3-clause
- Created: 2018-03-20T20:36:12.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-03-22T16:28:48.000Z (over 6 years ago)
- Last Synced: 2024-10-13T22:35:59.405Z (about 1 month ago)
- Topics: cache, currency, disk-cache, exchange-rates, node, open-exchange-rates
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cached-open-exchange-rates-sdk
Open Exchange Rates SDK that caches results to avoid hitting the usage limit# Usage
```js
const coxr = require('cached-open-exchange-rates');
const oxr = coxr(
// Cache configurations
{
path: '.open-exchange-rates-cache.json', // cache file, for persistance even on restarts
duration: 'PT12H' // 12 hour cache, must be an ISO duration -- https://en.wikipedia.org/wiki/ISO_8601#Durations
},
// Open Exchange Rate configurations
// This object is passed to the OXR SDK -- https://github.com/openexchangerates/npm-exchange-rates
{
app_id: '1234...' // Open Exchange Rate App ID
}
);await oxr.request(); // Directly requests from OXR
await oxr.cached(); // Tries the cache, throws an error if there is no cached value
await oxr.cachedOrRequest(); // Tries the cache and requests from OXR if is not present
```