API Reference
API for @tetherto/wdk-pricing-bitfinex-http
Package: @tetherto/wdk-pricing-bitfinex-http
@tetherto/wdk-pricing-bitfinex-httpClass: BitfinexPricingClient
BitfinexPricingClientSimple HTTP pricing client for Bitfinex Public REST API.
Constructor
new BitfinexPricingClient(options?)options(optional): reserved for future use
Methods
getCurrentPrice(base, quote)
Fetch latest price for base/quote pair
Promise<number>
getHistoricalPrice({ from, to, start?, end? })
Fetch historical series (downscaled to ≤ 100 points if needed)
Promise<any[]>
getCurrentPrice(base, quote)
const price = await client.getCurrentPrice('BTC', 'USD')getHistoricalPrice({ from, to, start?, end? })
If the returned series exceeds 100 points, it is downscaled by powers of two until ≤ 100.
const series = await client.getHistoricalPrice({
from: 'BTC',
to: 'USD',
start: 1709906400000, // optional
end: 1709913600000 // optional
})Package: @tetherto/wdk-pricing-provider
@tetherto/wdk-pricing-providerClass: PricingProvider
PricingProviderCache-aware wrapper providing a unified API over a PricingClient implementation.
Constructor
new PricingProvider({
client, // required: implements PricingClient
priceCacheDurationMs // optional: defaults to 1h
})client: instance implementing thePricingClientcontractpriceCacheDurationMs(number, optional): cache TTL for last price in ms (default 3,600,000)
Methods
getLastPrice(base, quote)
Returns cached last price; refreshes when TTL expires
Promise<number>
getHistoricalPrice({ from, to, start?, end? })
Delegates to client for historical data
Promise<any[]>
getLastPrice(base, quote)
const provider = new PricingProvider({ client })
const last = await provider.getLastPrice('BTC', 'USD')getHistoricalPrice({ from, to, start?, end? })
const hist = await provider.getHistoricalPrice({ from: 'BTC', to: 'USD' })Interface: PricingClient (abstract)
PricingClient (abstract)Implement this interface to plug your data source into PricingProvider.
getCurrentPrice
(from: string, to: string) => Promise<number>
Should return spot price
getHistoricalPrice
(opts: { from: string, to: string, start?: number, end?: number }) => Promise<any[]>
Return series for charting
Notes
Uses Bitfinex Public HTTP API (
/v2/tickerand/v2/candles) under the hood for the Bitfinex clientProvider caches last price per pair using in-memory store and TTL
Need Help?
Last updated
Was this helpful?

