Skip to content

Orderbook Data

The polygolem orderbook family wraps the public CLOB market-data endpoints. Every command on this page is read-only — no API key, no wallet, no risk.

Get the order book

Full L2 depth (top bids and asks):

Terminal window
polygolem orderbook get --token-id 71321045679252212594626385532706912750332728571942134274583709853755746957851
{
"market": "0x...",
"asset_id": "71321045679...",
"bids": [
{ "price": "0.51", "size": "100" },
{ "price": "0.50", "size": "250" }
],
"asks": [
{ "price": "0.53", "size": "75" },
{ "price": "0.54", "size": "180" }
],
"hash": "0x..."
}

Best bid / ask

Terminal window
polygolem orderbook price --token-id 71321045679252212594626385532706912750332728571942134274583709853755746957851
{ "best_bid": "0.51", "best_ask": "0.53" }

Midpoint

The CLOB-computed midpoint between best bid and best ask:

Terminal window
polygolem orderbook midpoint --token-id 71321045679252212594626385532706912750332728571942134274583709853755746957851
{ "mid": "0.52" }

Spread

Terminal window
polygolem orderbook spread --token-id 71321045679252212594626385532706912750332728571942134274583709853755746957851
{ "spread": "0.02" }

Tick size

The minimum price increment and order size for a market. Required before placing any order:

Terminal window
polygolem orderbook tick-size --token-id 71321045679252212594626385532706912750332728571942134274583709853755746957851
{ "minimum_tick_size": "0.01", "minimum_order_size": "5" }

Fee rate

Maker/taker fees in basis points:

Terminal window
polygolem orderbook fee-rate --token-id 71321045679252212594626385532706912750332728571942134274583709853755746957851
{ "fee_rate_bps": 0 }

Last trade

The most recent fill on this token:

Terminal window
polygolem orderbook last-trade --token-id 71321045679252212594626385532706912750332728571942134274583709853755746957851
{
"price": "0.52",
"size": "100",
"side": "BUY",
"timestamp": 1746625200
}

Live market data

For live bot feeds, use marketdata live instead of stitching raw stream messages yourself. It subscribes to the same public market WebSocket as stream market, tracks each token’s latest book, and emits enriched snapshots with best_bid, best_ask, spread, midpoint, tick_size, last_trade_price, bids, and asks. It requests V2 custom feature events by default so best_bid_ask updates can refresh top-of-book snapshots without a full book delta.

Terminal window
polygolem marketdata live \
--asset-ids 71321045679252212594626385532706912750332728571942134274583709853755746957851 \
--max-messages 10

Using the Go SDK

If you want best-first orderbook reads from a Go program, prefer the pkg/orderbook package over shelling out to the CLI. If you need broader CLOB market data such as market lists, price history, tick size, or fee rate, use pkg/clob.

import "github.com/TrebuchetDynamics/polygolem/pkg/orderbook"
reader := orderbook.NewReader("")
book, err := reader.OrderBook(ctx, tokenID)
// book.Bids[0].Price, book.Asks[0].Size, ...

For live snapshots, use pkg/stream with pkg/marketdata.NewTracker().

See Go-Bot Integration for the full SDK story.

Reference

  • polygolem orderbook --help — flag-level reference for every subcommand
  • docs/COMMANDS.md — canonical command list
  • CLOB API — endpoint surface