Websocket
Real-time orderbook, trade, and market updates via WebSocket.
Connection
wss://api.turbinefi.com/api/v1/stream
No authentication is required. The WebSocket endpoint is public.
Connection lifecycle
The server sends a ping every 54 seconds.
Clients must respond with a pong within 60 seconds or the connection is closed.
On subscribe, you receive a confirmation message followed by the current orderbook snapshot.
Example
const ws = new WebSocket("wss://api.turbinefi.com/api/v1/stream");
ws.onopen = () => {
console.log("Connected");
};
ws.onmessage = (event) => {
const msg = JSON.parse(event.data);
console.log(msg.type, msg.data);
};Subscribe
Subscribe to real-time updates for a market. You can optionally filter by outcome.
Request
With outcome filter:
type
string
"subscribe"
marketId
bytes32
Market to subscribe to
data.outcome
uint8
Optional. 0 = YES only, 1 = NO only. Omit for all outcomes
Response
You receive a subscription confirmation followed by the initial orderbook snapshot:
Unsubscribe
Stop receiving updates for a market.
Request
Response
Event Types
All server messages follow this format:
orderbook
Full orderbook snapshot sent on subscribe and after each trade or order change.
bids
array
Buy orders, sorted by price descending
asks
array
Sell orders, sorted by price ascending
bids[].price
uint64
Bid price (6 decimals). 450000 = $0.45
bids[].size
uint64
Total size at this price (6 decimals). 20000000 = 20 shares
asks[].price
uint64
Ask price (6 decimals). 550000 = $0.55
asks[].size
uint64
Total size at this price (6 decimals)
lastUpdate
uint64
Unix timestamp of last update
trade
Sent when a trade is executed.
price
uint64
Trade price (6 decimals). 550000 = $0.55
size
uint64
Trade size (6 decimals). 10000000 = 10 shares
outcome
uint8
0 = YES, 1 = NO
timestamp
uint64
Unix timestamp
tradeHash
string
Unique trade identifier
maker
address
Limit order placer
taker
address
Market order placer
side
uint8
Taker's side: 0 = BUY, 1 = SELL
trade_error
Sent when an on-chain trade settlement fails.
buyer
address
Buyer's wallet address
seller
address
Seller's wallet address
price
uint64
Trade price (6 decimals)
size
uint64
Trade size (6 decimals)
txHash
string
Failed transaction hash
error
string
Error description
order_cancelled
Sent when an order is cancelled, either by the user or by the system (e.g., during market rebalancing).
orderHash
string
Cancelled order hash
marketId
string
Market identifier
side
string
"buy" or "sell"
trader
address
Order owner
reason
string
Cancellation reason (e.g., "user_cancelled", "market_rebalancing")
quick_market
Broadcast to all connected clients when a quick market is created or resolved.
data.type
string
"new_market" or "resolved"
data.asset
string
Asset symbol (e.g., "BTC")
data.marketId
string
Market identifier
data.quickMarket
object
Quick market details
Quick market events are sent to all connected clients regardless of subscriptions.
Full example
Last updated
