🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@exodus/price-api

Package Overview
Dependencies
Maintainers
105
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@exodus/price-api

Util to fetch, validate and cache prices from server

latest
Source
npmnpm
Version
4.1.2
Version published
Weekly downloads
232
-53.04%
Maintainers
105
Weekly downloads
 
Created
Source

@exodus/price-api

Util to fetch, validate and cache prices from server

Table of Contents

  • Installation
  • Quick Start

Installation

yarn add @exodus/price-api

Quick start

Module contains following useful utils:

fetchHistoricalPrices

Based 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.

Arguments

prices cache example: [1502496000000, {close: 44}], [1502582400000, {close: 12}] ]

NameTypeDescriptionOptionalReturns
apiFunctionFunction to make request to pricing serverPromise
assetTickersArrayArray of asset tickers to fetch
fiatTickerStringfiat currency supported by Exodus, as well as BTC
granularityStringGranularity of the historical data, values must be day or hour
getCacheFromStorageFunctionaccepts tickerSymbol and returns array historical pricesprices cache
hourlyLimitNumberlimits historical hourly prices to fetch. default=168true
timestampNumbermilliseconds since Unix Epoch to fetch price exact on this datetrue
getCurrentTimeFunctionreturns milliseconds since Unix Epochtruemilliseconds
ignoreInvalidSymbolsBoolignore error when fetch prices for unsupported assets. Empty Map will be returned for this assettrue
ignoreCacheBoolrefetch the entire price history, ignoring existent cached valuestrue
runtimeCacheMapstorage for runtime cachetrue
getRuntimeCacheKeyFunctionget key to access runtime cachetrue

Returns

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}] ])],
])
}

fetchPricesInterval

Setup interval to fetch prices. Daily prices updated on UTC day start, hourly every UTC and local hour start.

Arguments

NameTypeDescriptionOptional
funcFunctionFunction to make fetch prices
granularityArrayGranularity of the historical data, values must be day or hour
getJitterFunctionFunction that returns jitter (ms) to create delay in [0, jitter] rangetrue
delayNumberdelay in millisecondstrue
getCurrentTimeFunctionreturns milliseconds since Unix Epochtrue

Keywords

utils

FAQs

Package last updated on 16 Jun 2025

Did you know?

Socket

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.

Install

Related posts