Skip to main content
Fetch asset details, prices, OHLCV chart data, and orderbook snapshots.
The examples on this page use Hyperliquid (provider: 'hyperliquid'). Replace the provider value with any supported DEX from getProviders().

getAssets

Returns the token/asset registry for a specified DEX — the base entities referenced by markets (as base/quote legs) and by account balances. Static market metadata (leverage, margin) lives on Market via getMarkets; live data (mark price, funding) lives on MarketPrice via getPrices.
import { getAssets } from '@lifi/perps-sdk';

const { assets } = await getAssets(client, { provider: 'hyperliquid' });

for (const asset of assets) {
  console.log(asset.id, asset.displaySymbol);
}
// BTC BTC
// ETH ETH

Parameters

ParameterTypeRequiredDescription
clientPerpsSDKClientYesSDK client
params.providerstringYesProvider identifier
optionsSDKRequestOptionsNoRequest options

Returns

AssetsResponse{ assets: Asset[] }: Each Asset:
FieldTypeDescription
providerIdstringProvider that minted this asset
idstringProvider’s own asset id (Lighter’s numeric asset_id stringified; Hyperliquid coin symbol)
displaySymbolstringUI-friendly base symbol (e.g., "BTC", "PURR")
logoURIstringURL to asset logo
displayNamestring?Full asset name (e.g., "Bitcoin")
API Reference: GET /assets

getMarkets

Returns all tradeable markets for a specified DEX as static instrument metadata — ids, base/quote assets, decimals, leverage, and margin. Live data (mark price, funding, open interest, volume) comes from getPrices.
import { getMarkets } from '@lifi/perps-sdk';

const { markets } = await getMarkets(client, { provider: 'hyperliquid' });

for (const market of markets) {
  console.log(market.baseAsset.displaySymbol, market.maxLeverage);
}
// BTC 50
// ETH 50

Parameters

ParameterTypeRequiredDescription
clientPerpsSDKClientYesSDK client
params.providerstringYesProvider identifier
params.marketIdsstring[]NoFilter to specific markets by the canonical Market.id (not display symbols)
optionsSDKRequestOptionsNoRequest options

Returns

MarketsResponse{ markets: Market[] }. A Market is either a PerpsMarket or a SpotMarket; both extend BaseMarket:
FieldTypeDescription
providerIdstringProvider that owns this market
idstringProvider’s canonical, stringified market id that uniquely identifies the trading instrument; referenced elsewhere as marketId
categoryIdstringReferences a ProviderCategory by id
baseAssetAssetBase leg
quoteAssetAssetQuote leg
szDecimalsnumberSize decimal places
PerpsMarket adds:
FieldTypeDescription
maxLeveragenumberMaximum allowed leverage
onlyIsolatedbooleanWhether only isolated margin is supported
Live per-market data (mark price, previous-day price, 24h volume, open interest, funding) comes from getPrices. API Reference: GET /markets

getMarket

Returns a single market by its canonical marketId.
import { getMarket } from '@lifi/perps-sdk';

const btc = await getMarket(client, { provider: 'hyperliquid', marketId: 'BTC' });
console.log(btc.baseAsset.displaySymbol, btc.maxLeverage);
// BTC 50

Parameters

ParameterTypeRequiredDescription
clientPerpsSDKClientYesSDK client
params.providerstringYesProvider identifier
params.marketIdstringYesThe canonical Market.id (not the display symbol)
optionsSDKRequestOptionsNoRequest options

Returns

Market — single market object (same shape as above). API Reference: GET /markets

getPrices

Returns live per-market data for all markets: the mid price, markPrice, prevDayPrice, and volume24h for every market, plus openInterest and funding for perps. Intended for frequent polling; pair it with the static metadata from getMarkets.
import { getPrices } from '@lifi/perps-sdk';

const { prices } = await getPrices(client, { provider: 'hyperliquid' });
for (const p of prices) {
  console.log(p.marketId, p.price, p.markPrice);
}
// 0 95000.50 95000.50
// 1 3200.25 3200.25

Parameters

ParameterTypeRequiredDescription
clientPerpsSDKClientYesSDK client
params.providerstringYesProvider identifier
params.marketIdsstring[]NoFilter to specific markets by the canonical Market.id (not display symbols)
optionsSDKRequestOptionsNoRequest options

Returns

PricesResponse{ prices: MarketPrice[] }: Each MarketPrice:
FieldTypeDescription
marketIdstringThe canonical Market.id
pricestringCurrent mid price
markPricestringCurrent mark price
prevDayPricestring?Previous day’s price
volume24hstring?24-hour trading volume in USD
openIntereststring?Total open interest in USD (perps markets only)
fundingFundingInfo?Current funding rate and next funding time (perps markets only)
API Reference: GET /prices

getOhlcv

Returns OHLCV candle data for charts.
import { getOhlcv } from '@lifi/perps-sdk';

const { candles } = await getOhlcv(client, {
  provider: 'hyperliquid',
  marketId: 'BTC',
  interval: '1h',
  limit: 100,
});

for (const candle of candles) {
  console.log(candle.t, candle.o, candle.h, candle.l, candle.c, candle.v);
}

Parameters

ParameterTypeRequiredDescription
clientPerpsSDKClientYesSDK client
params.providerstringYesProvider identifier
params.marketIdstringYesThe canonical Market.id
params.intervalstringYesCandle interval: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 8h, 12h, 1d, 3d, 1w, 1M
params.startTimenumberNoStart timestamp in milliseconds
params.endTimenumberNoEnd timestamp in milliseconds
params.limitnumberNoMax candles to return (default 100, max 1000)
optionsSDKRequestOptionsNoRequest options

Returns

OhlcvResponse:
FieldTypeDescription
providerstringProvider identifier
marketIdstringThe canonical Market.id
intervalstringCandle interval
candlesCandle[]Array of candle data
Each Candle:
FieldTypeDescription
tnumberTimestamp in milliseconds
ostringOpen price
hstringHigh price
lstringLow price
cstringClose price
vstringVolume
API Reference: GET /ohlcv

getOrderbook

Returns current orderbook snapshot with bids and asks.
import { getOrderbook } from '@lifi/perps-sdk';

const book = await getOrderbook(client, {
  provider: 'hyperliquid',
  marketId: 'BTC',
  depth: 20,
});

console.log('Best bid:', book.bids[0].price, book.bids[0].size);
console.log('Best ask:', book.asks[0].price, book.asks[0].size);

Parameters

ParameterTypeRequiredDescription
clientPerpsSDKClientYesSDK client
params.providerstringYesProvider identifier
params.marketIdstringYesThe canonical Market.id
params.depthnumberNoNumber of price levels (default 20, max 100)
optionsSDKRequestOptionsNoRequest options

Returns

OrderbookResponse:
FieldTypeDescription
providerstringProvider identifier
marketIdstringThe canonical Market.id
bidsOrderbookLevel[]Bid price levels (descending)
asksOrderbookLevel[]Ask price levels (ascending)
timestampnumberSnapshot timestamp in milliseconds
Each OrderbookLevel:
FieldTypeDescription
pricestringPrice level
sizestringSize at this price level
API Reference: GET /orderbook