Configuration

Configure HTTP pricing clients and providers

Bitfinex HTTP Client

Create Client
import { BitfinexPricingClient } from '@tetherto/wdk-pricing-bitfinex-http'

// Create the client (no options needed)
const client = new BitfinexPricingClient()

Current Price

Get Current Price
const price = await client.getCurrentPrice('BTC', 'USD')

Historical Series

Downscales long histories to ≤ 100 points.

Get Historical Prices
const series = await client.getHistoricalPrice({
  from: 'BTC',
  to: 'USD',
  start: 1709906400000, // optional (ms)
  end:   1709913600000  // optional (ms)
})

Provider Integration

Works with @tetherto/wdk-pricing-provider as a PricingClient implementation.

Wrap with PricingProvider
import { PricingProvider } from '@tetherto/wdk-pricing-provider'

const provider = new PricingProvider({
  client,
  priceCacheDurationMs: 60 * 60 * 1000 // optional, defaults to 1h
})

const last = await provider.getLastPrice('BTC', 'USD')
const hist = await provider.getHistoricalPrice({ from: 'BTC', to: 'USD' })

Need Help?

Last updated

Was this helpful?