
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
@exodus/price-api
Advanced tools
Util to fetch, validate and cache prices from server
yarn add @exodus/price-api
Module contains following useful utils:
fetchHistoricalPricesBased on provided arguments prepares params for request to exodus pricing server. Depending on runtime cache and client long-term cache decides how much data needs to be fetched. Validates data and prepares result to defined data structure.
prices cache example: [1502496000000, {close: 44}], [1502582400000, {close: 12}] ]
| Name | Type | Description | Optional | Returns |
|---|---|---|---|---|
| api | Function | Function to make request to pricing server | Promise | |
| assetTickers | Array | Array of asset tickers to fetch | ||
| fiatTicker | String | fiat currency supported by Exodus, as well as BTC | ||
| granularity | String | Granularity of the historical data, values must be day or hour | ||
| getCacheFromStorage | Function | accepts tickerSymbol and returns array historical prices | prices cache | |
| hourlyLimit | Number | limits historical hourly prices to fetch. default=168 | true | |
| timestamp | Number | milliseconds since Unix Epoch to fetch price exact on this date | true | |
| getCurrentTime | Function | returns milliseconds since Unix Epoch | true | milliseconds |
| ignoreInvalidSymbols | Bool | ignore error when fetch prices for unsupported assets. Empty Map will be returned for this asset | true | |
| ignoreCache | Bool | refetch the entire price history, ignoring existent cached values | true | |
| runtimeCache | Map | storage for runtime cache | true | |
| getRuntimeCacheKey | Function | get key to access runtime cache | true |
Object with Maps with prices Maps by asset ticker. prices Map keyed by timestamp in milliseconds. historicalPricesMap includes prices from cache fetchedPricesMap includes only assets fetched from server. If asset had cache but new prices fetched from server this Map includes combined data
{
historicalPricesMap: new Map([
['ZRX', new Map([ [1502496000000, {close: 44}], [1502582400000, {close: 12}] ])],
['BTC', new Map([ [1502496000000, {close: 10000}], [1502582400000, {close: 50000}] ])],
]),
fetchedPricesMap: new Map([
['ZRX', new Map([ [1502496000000, {close: 44}], [1502582400000, {close: 12}] ])],
['BTC', new Map([ [1502496000000, {close: 10000}], [1502582400000, {close: 50000}] ])],
])
}
fetchPricesIntervalSetup interval to fetch prices. Daily prices updated on UTC day start, hourly every UTC and local hour start.
| Name | Type | Description | Optional |
|---|---|---|---|
| func | Function | Function to make fetch prices | |
| granularity | Array | Granularity of the historical data, values must be day or hour | |
| getJitter | Function | Function that returns jitter (ms) to create delay in [0, jitter] range | true |
| delay | Number | delay in milliseconds | true |
| getCurrentTime | Function | returns milliseconds since Unix Epoch | true |
FAQs
Util to fetch, validate and cache prices from server
The npm package @exodus/price-api receives a total of 212 weekly downloads. As such, @exodus/price-api popularity was classified as not popular.
We found that @exodus/price-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 105 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.