Market Channel (WebSocket)
Overview
Section titled “Overview”Clients subscribe by specifying one or more asset IDs (token IDs). The server then pushes orderbook snapshots, incremental price-level changes, trade notifications, and lifecycle events to the connection.
Server: wss://ws.openfish.fun/ws/market
Subscribe
Section titled “Subscribe”Direction: Client -> Server
| Field | Type | Required | Description |
|---|---|---|---|
type | string | Yes | "subscribe" or "unsubscribe" |
assets_ids | array of strings | Yes | Asset IDs to subscribe/unsubscribe |
level | integer | No | Subscription level: 1=trades only, 2=+best bid/ask (default), 3=+full book |
initial_dump | boolean | No | Send initial orderbook snapshot after subscribing (default: false) |
{ "type": "subscribe", "assets_ids": ["52114319501245..."], "level": 2, "initial_dump": true}Subscription Levels
Section titled “Subscription Levels”| Level | Events |
|---|---|
| 1 | last_trade_price |
| 2 | Level 1 + best_bid_ask, price_change |
| 3 | Level 2 + book |
Lifecycle events (new_market, market_resolved, tick_size_change) are always delivered.
Update Subscription
Section titled “Update Subscription”You can add or remove assets from your subscription without dropping the connection:
{ "type": "subscribe", "assets_ids": ["71321045679252..."]}{ "type": "unsubscribe", "assets_ids": ["71321045679252..."]}Legacy Query Parameters
Section titled “Legacy Query Parameters”For backward compatibility, ?market= and ?asset_id= query parameters are still accepted at connection time.
Heartbeat
Section titled “Heartbeat”The server emits a text "PING" frame every 10 seconds. The client must reply with text "PONG".
Events
Section titled “Events”book — Orderbook Snapshot
Section titled “book — Orderbook Snapshot”| Field | Type | Description |
|---|---|---|
event_type | string | "book" |
asset_id | string | Asset ID |
market | string | Condition ID |
bids | array | [{ "price": "0.50", "size": "15" }] |
asks | array | [{ "price": "0.52", "size": "25" }] |
hash | string | Orderbook content hash |
timestamp | string | Unix ms |
price_change — Orderbook Delta
Section titled “price_change — Orderbook Delta”Requires level >= 2.
| Field | Type | Description |
|---|---|---|
type | string | "price_change" |
market | string | Condition ID |
asset_id | string | Asset ID |
price | string | Affected price level |
size | string | New size at this level ("0" = removed) |
side | string | "BUY" or "SELL" |
hash | string | Book content hash |
best_bid | string? | Current best bid (if changed) |
best_ask | string? | Current best ask (if changed) |
timestamp | integer | Unix timestamp |
last_trade_price — Trade Execution
Section titled “last_trade_price — Trade Execution”| Field | Type | Description |
|---|---|---|
event_type | string | "last_trade_price" |
asset_id | string | Asset ID |
market | string | Condition ID |
price | string | Execution price |
size | string | Trade size |
side | string | "BUY" or "SELL" (taker perspective) |
timestamp | integer | Unix ms |
best_bid_ask — Best Bid/Ask Update
Section titled “best_bid_ask — Best Bid/Ask Update”Requires custom_feature_enabled: true.
| Field | Type | Description |
|---|---|---|
event_type | string | "best_bid_ask" |
asset_id | string | Asset ID |
market | string | Condition ID |
best_bid | string | Best bid price |
best_ask | string | Best ask price |
timestamp | integer | Unix ms |
tick_size_change — Tick Size Update
Section titled “tick_size_change — Tick Size Update”| Field | Type | Description |
|---|---|---|
event_type | string | "tick_size_change" |
asset_id | string | Asset ID |
old_tick_size | string | Previous tick size |
new_tick_size | string | New tick size |
timestamp | integer | Unix ms |
new_market — Market Created
Section titled “new_market — Market Created”Broadcast to all connected clients regardless of subscription level.
| Field | Type | Description |
|---|---|---|
type | string | "new_market" |
market | string | Condition ID |
question | string | Market question |
slug | string | URL-friendly market slug |
outcomes | array | Outcome labels (e.g. ["Yes", "No"]) |
clob_token_ids | array | Token IDs for each outcome |
tags | array | Market tags |
timestamp | integer | Unix timestamp |
market_resolved — Market Resolved
Section titled “market_resolved — Market Resolved”Broadcast to all connected clients regardless of subscription level.
| Field | Type | Description |
|---|---|---|
type | string | "market_resolved" |
market | string | Condition ID |
winning_token_id | string | Winning asset ID |
winning_outcome | string | Winning outcome label |
assets_ids | array | All asset IDs in the market |
tags | array | Market tags |
timestamp | integer | Unix timestamp |