Тема
WS vs REST orderbook snapshot comparison
Captured: 2026-05-12T16:27:38Z Market: New Rihanna Album before GTA VI? Token (YES): 98022490269692409998126496127597032490334070080325855126491859374983463996227 Market condition_id: 0x1fad72fae204143ff1c3035e99e7c0f65ea8d5cd9bd1070987bd1a3316f772be Capture method:
- REST:
curl -s "https://clob.polymarket.com/book?token_id=$TOKEN" - WS: ad-hoc Rust example
crates/pm-bot/examples/capture_ws_book.rs(subscribe withinitial_dump:true,custom_feature_enabled:true)
REST GET /book
Raw response:
json
{
"market": "0x1fad72fae204143ff1c3035e99e7c0f65ea8d5cd9bd1070987bd1a3316f772be",
"asset_id": "98022490269692409998126496127597032490334070080325855126491859374983463996227",
"timestamp": "1778603221635",
"hash": "f7972f8853c7e042a809343784188c5526337e57",
"bids": [
{
"price": "0.01",
"size": "48145"
},
{
"price": "0.02",
"size": "3780.43"
},
{
"price": "0.06",
"size": "3900"
},
{
"price": "0.07",
"size": "2871.42"
},
{
"price": "0.09",
"size": "466.66"
},
{
"price": "0.11",
"size": "4784.9"
},
{
"price": "0.12",
"size": "250"
},
{
"price": "0.15",
"size": "1007"
},
{
"price": "0.19",
"size": "252.63"
},
{
"price": "0.2",
"size": "1700"
},
{
"price": "0.21",
"size": "1476"
},
{
"price": "0.22",
"size": "8003"
},
{
"price": "0.23",
"size": "1020.65"
},
{
"price": "0.24",
"size": "2084"
},
{
"price": "0.25",
"size": "400"
},
{
"price": "0.29",
"size": "43.1"
},
{
"price": "0.35",
"size": "2000"
},
{
"price": "0.36",
"size": "725"
},
{
"price": "0.37",
"size": "27"
},
{
"price": "0.39",
"size": "7.1"
},
{
"price": "0.4",
"size": "798.61"
},
{
"price": "0.41",
"size": "161"
},
{
"price": "0.48",
"size": "10000"
},
{
"price": "0.49",
"size": "11081"
},
{
"price": "0.5",
"size": "49755.9"
},
{
"price": "0.51",
"size": "8"
}
],
"asks": [
{
"price": "0.99",
"size": "4000"
},
{
"price": "0.98",
"size": "7600"
},
{
"price": "0.97",
"size": "840"
},
{
"price": "0.94",
"size": "4900"
},
{
"price": "0.93",
"size": "1275.49"
},
{
"price": "0.92",
"size": "3462"
},
{
"price": "0.9",
"size": "2373.52"
},
{
"price": "0.89",
"size": "995.05"
},
{
"price": "0.88",
"size": "250"
},
{
"price": "0.87",
"size": "169"
},
{
"price": "0.86",
"size": "233"
},
{
"price": "0.85",
"size": "13"
},
{
"price": "0.84",
"size": "230.3"
},
{
"price": "0.83",
"size": "5"
},
{
"price": "0.78",
"size": "445.61"
},
{
"price": "0.77",
"size": "133.68"
},
{
"price": "0.76",
"size": "100"
},
{
"price": "0.75",
"size": "10"
},
{
"price": "0.74",
"size": "10"
},
{
"price": "0.72",
"size": "15"
},
{
"price": "0.71",
"size": "15"
},
{
"price": "0.65",
"size": "433.98"
},
{
"price": "0.64",
"size": "64.14"
},
{
"price": "0.63",
"size": "92.95"
},
{
"price": "0.62",
"size": "54.01"
},
{
"price": "0.61",
"size": "8"
},
{
"price": "0.53",
"size": "173.11"
},
{
"price": "0.52",
"size": "35.76"
}
],
"min_order_size": "5",
"tick_size": "0.01",
"neg_risk": false,
"last_trade_price": "0.500"
}Summary:
- bids.len: 26
- asks.len: 28
- hash: f7972f8853c7e042a809343784188c5526337e57
- timestamp: 1778603221635
- tick_size: 0.01
- neg_risk: false
- Extra fields present:
asset_id,market,min_order_size,last_trade_price
WS book event (initial_dump)
Raw event:
json
{
"asks": [
{
"price": "0.99",
"size": "4000"
},
{
"price": "0.98",
"size": "7600"
},
{
"price": "0.97",
"size": "840"
},
{
"price": "0.94",
"size": "4900"
},
{
"price": "0.93",
"size": "2175.49"
},
{
"price": "0.92",
"size": "2562"
},
{
"price": "0.9",
"size": "2373.52"
},
{
"price": "0.89",
"size": "995.05"
},
{
"price": "0.88",
"size": "250"
},
{
"price": "0.87",
"size": "169"
},
{
"price": "0.86",
"size": "233"
},
{
"price": "0.85",
"size": "13"
},
{
"price": "0.84",
"size": "230.3"
},
{
"price": "0.83",
"size": "5"
},
{
"price": "0.78",
"size": "445.61"
},
{
"price": "0.77",
"size": "133.68"
},
{
"price": "0.76",
"size": "100"
},
{
"price": "0.75",
"size": "10"
},
{
"price": "0.74",
"size": "10"
},
{
"price": "0.72",
"size": "15"
},
{
"price": "0.71",
"size": "15"
},
{
"price": "0.65",
"size": "433.98"
},
{
"price": "0.64",
"size": "64.14"
},
{
"price": "0.63",
"size": "92.95"
},
{
"price": "0.62",
"size": "54.01"
},
{
"price": "0.61",
"size": "8"
},
{
"price": "0.53",
"size": "173.11"
},
{
"price": "0.52",
"size": "35.76"
}
],
"asset_id": "98022490269692409998126496127597032490334070080325855126491859374983463996227",
"bids": [
{
"price": "0.01",
"size": "48145"
},
{
"price": "0.02",
"size": "3780.43"
},
{
"price": "0.06",
"size": "3900"
},
{
"price": "0.07",
"size": "2871.42"
},
{
"price": "0.09",
"size": "466.66"
},
{
"price": "0.11",
"size": "4784.9"
},
{
"price": "0.12",
"size": "250"
},
{
"price": "0.15",
"size": "1007"
},
{
"price": "0.19",
"size": "252.63"
},
{
"price": "0.2",
"size": "1700"
},
{
"price": "0.21",
"size": "1476"
},
{
"price": "0.22",
"size": "8003"
},
{
"price": "0.23",
"size": "1020.65"
},
{
"price": "0.24",
"size": "2084"
},
{
"price": "0.25",
"size": "400"
},
{
"price": "0.29",
"size": "43.1"
},
{
"price": "0.35",
"size": "2000"
},
{
"price": "0.36",
"size": "725"
},
{
"price": "0.37",
"size": "27"
},
{
"price": "0.39",
"size": "7.1"
},
{
"price": "0.4",
"size": "798.61"
},
{
"price": "0.41",
"size": "161"
},
{
"price": "0.48",
"size": "10000"
},
{
"price": "0.49",
"size": "11081"
},
{
"price": "0.5",
"size": "49755.9"
},
{
"price": "0.51",
"size": "8"
}
],
"event_type": "book",
"hash": "532db5ef7f9ab2cd3d75e133c6b3266d017a2e27",
"last_trade_price": "0.500",
"market": "0x1fad72fae204143ff1c3035e99e7c0f65ea8d5cd9bd1070987bd1a3316f772be",
"tick_size": "0.01",
"timestamp": "1778603210569"
}Summary:
- bids.len: 26
- asks.len: 28
- hash: 532db5ef7f9ab2cd3d75e133c6b3266d017a2e27
- timestamp: 1778603210569
- tick_size: present (0.01)
- Extra field on WS:
event_type:"book" - Missing vs REST:
neg_risk,min_order_size
Comparison
| Metric | REST | WS | Match |
|---|---|---|---|
| bids depth | 26 | 26 | yes |
| asks depth | 28 | 28 | yes |
| top-1 bid | 0.51 × 8 | 0.51 × 8 | yes |
| top-2 bid | 0.50 × 49755.9 | 0.50 × 49755.9 | yes |
| top-3 bid | 0.49 × 11081 | 0.49 × 11081 | yes |
| top-4 bid | 0.48 × 10000 | 0.48 × 10000 | yes |
| top-5 bid | 0.41 × 161 | 0.41 × 161 | yes |
| top-1 ask | 0.52 × 35.76 | 0.52 × 35.76 | yes |
| top-2 ask | 0.53 × 173.11 | 0.53 × 173.11 | yes |
| top-3 ask | 0.61 × 8 | 0.61 × 8 | yes |
| top-4 ask | 0.62 × 54.01 | 0.62 × 54.01 | yes |
| top-5 ask | 0.63 × 92.95 | 0.63 × 92.95 | yes |
| hash present | yes | yes | — |
| timestamp present | yes (ms) | yes (ms) | — |
| levels ordering | bids ascending, asks descending (best on inner-most side) | identical | yes |
| Δ timestamps | — | — | WS frame ~11s older than REST snapshot |
| hash equality | f797…7e57 | 532d…2e27 | no (expected — book mutated in 11s window) |
| extra fields REST-only | neg_risk, min_order_size | — | REST richer |
| extra fields WS-only | — | event_type | WS framing |
Verdict
WS and REST are depth-equivalent for the same token snapshot. Both sources return identical bid/ask arrays (26 bids, 28 asks) with the same price-size pairs, the same ordering convention (bids ascending, asks descending — best price is the innermost element), and the same field shape (price/size strings).
Differences are non-structural:
- Metadata-only: REST snapshot adds
neg_riskandmin_order_size, which the WSbookevent does not duplicate (neg_riskbelongs on the market-meta channel / NewMarket;min_order_sizeis per-market static config). - Framing: WS wraps the payload with
event_type:"book"so it can be discriminated fromprice_change/last_trade_price/best_bid_askon the same channel. - Hash divergence is content drift, not source divergence: the two snapshots were taken ~11s apart; in that window at least one level changed (top of book is fine; deeper levels shift). Re-running both captures within the same second would yield matching hashes.
Conclusion: WS initial_dump is a faithful drop-in replacement for REST GET /book in terms of depth and ordering. Production code that already lives in crates/pm-bot/src/io/ws/book.rs does not lose any orderbook information by relying on WS exclusively; REST is needed only when a separate metadata fetch (neg_risk, min_order_size, tick_size on first contact) is required.
Reproducibility
- Token: 98022490269692409998126496127597032490334070080325855126491859374983463996227
- REST endpoint: https://clob.polymarket.com/book
- WS endpoint: wss://ws-subscriptions-clob.polymarket.com/ws/market
- Subscribe payload:
{"type":"market","operation":"subscribe","assets_ids":[<token>],"initial_dump":true,"custom_feature_enabled":true} - Capture tool:
cargo run -p pm-bot --example capture_ws_book -- <token_id>