Skip to content

Market Channel (WebSocket)

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


Direction: Client -> Server

FieldTypeRequiredDescription
typestringYes"subscribe" or "unsubscribe"
assets_idsarray of stringsYesAsset IDs to subscribe/unsubscribe
levelintegerNoSubscription level: 1=trades only, 2=+best bid/ask (default), 3=+full book
initial_dumpbooleanNoSend initial orderbook snapshot after subscribing (default: false)
{
"type": "subscribe",
"assets_ids": ["52114319501245..."],
"level": 2,
"initial_dump": true
}
LevelEvents
1last_trade_price
2Level 1 + best_bid_ask, price_change
3Level 2 + book

Lifecycle events (new_market, market_resolved, tick_size_change) are always delivered.

You can add or remove assets from your subscription without dropping the connection:

{
"type": "subscribe",
"assets_ids": ["71321045679252..."]
}
{
"type": "unsubscribe",
"assets_ids": ["71321045679252..."]
}

For backward compatibility, ?market= and ?asset_id= query parameters are still accepted at connection time.

The server emits a text "PING" frame every 10 seconds. The client must reply with text "PONG".


FieldTypeDescription
event_typestring"book"
asset_idstringAsset ID
marketstringCondition ID
bidsarray[{ "price": "0.50", "size": "15" }]
asksarray[{ "price": "0.52", "size": "25" }]
hashstringOrderbook content hash
timestampstringUnix ms

Requires level >= 2.

FieldTypeDescription
typestring"price_change"
marketstringCondition ID
asset_idstringAsset ID
pricestringAffected price level
sizestringNew size at this level ("0" = removed)
sidestring"BUY" or "SELL"
hashstringBook content hash
best_bidstring?Current best bid (if changed)
best_askstring?Current best ask (if changed)
timestampintegerUnix timestamp
FieldTypeDescription
event_typestring"last_trade_price"
asset_idstringAsset ID
marketstringCondition ID
pricestringExecution price
sizestringTrade size
sidestring"BUY" or "SELL" (taker perspective)
timestampintegerUnix ms

Requires custom_feature_enabled: true.

FieldTypeDescription
event_typestring"best_bid_ask"
asset_idstringAsset ID
marketstringCondition ID
best_bidstringBest bid price
best_askstringBest ask price
timestampintegerUnix ms
FieldTypeDescription
event_typestring"tick_size_change"
asset_idstringAsset ID
old_tick_sizestringPrevious tick size
new_tick_sizestringNew tick size
timestampintegerUnix ms

Broadcast to all connected clients regardless of subscription level.

FieldTypeDescription
typestring"new_market"
marketstringCondition ID
questionstringMarket question
slugstringURL-friendly market slug
outcomesarrayOutcome labels (e.g. ["Yes", "No"])
clob_token_idsarrayToken IDs for each outcome
tagsarrayMarket tags
timestampintegerUnix timestamp

Broadcast to all connected clients regardless of subscription level.

FieldTypeDescription
typestring"market_resolved"
marketstringCondition ID
winning_token_idstringWinning asset ID
winning_outcomestringWinning outcome label
assets_idsarrayAll asset IDs in the market
tagsarrayMarket tags
timestampintegerUnix timestamp