Skip to Content
Symmio Trading-SDK — the SDK surface for builders on Arbitrum
CoreOrderbookgetOrderbook

getOrderbook

Fetch a point-in-time depth snapshot from an OrderbookSource. Bids come back descending from the best price, asks ascending, both de-duplicated and free of zero-size levels.

import { createBinanceOrderbookSource, getOrderbookSpread } from "@symmio/trading-core"; const source = createBinanceOrderbookSource(); const book = await source.getOrderbook({ marketName: "BTCUSDT", limit: 20 }); const spread = getOrderbookSpread(book);

A snapshot is stale the moment it lands. Use this for a one-off read — sizing a single order, an impact estimate, a server-rendered summary. For anything a user watches, watchOrderbook is both fresher than any poll interval and far cheaper in rate-limit weight.

Parameters

marketNamestringrequired

Market name as SYMMIO names it. The source maps it onto its own symbol namespace.

limitnumberoptional

Levels per side. Must be one of the source’s supportedLimits; defaults to its defaultLimit.

signalAbortSignaloptional

Aborts the in-flight request.

Returns

Promise<Orderbook>

A point-in-time Orderbook: bids, asks, the lastUpdateId it is synchronized to, and the venue timestamp (0 when the venue omits one).

Query options

import { getOrderbookQueryOptions } from "@symmio/trading-core"; import { useQuery } from "@tanstack/react-query"; useQuery(getOrderbookQueryOptions(source, { marketName: "BTCUSDT", limit: 20 }));

Unlike the chain-scoped factories elsewhere in the SDK, this takes a source rather than a Config — which venue’s depth to read is your choice, not a property of the SYMMIO deployment. The source’s id is folded into the query key, so switching venues never reads another venue’s cached book. getOrderbookQueryKey builds the same key for cache matching and invalidation.

Throws

  • UNSUPPORTED_DEPTH_LIMIT when limit is not one the venue accepts. Binance USD-M takes an enum5, 10, 20, 50, 100, 500, 1000 — and rejects anything else outright rather than clamping.
  • UNMAPPED_ORDERBOOK_MARKET when the source’s symbol mapping declines the market name.
  • FETCH_BINANCE_DEPTH_FAILED when the request fails or the response is not a snapshot.
Last updated on