> For the complete documentation index, see [llms.txt](https://www.pionex.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.pionex.com/docs/api-docs/futures-websocket/public-stream.md).

# Public Stream

Public channels via `wss://ws.pionex.com/wsPub` (no auth required)

## Trade Stream

> \*\*Topic\*\*: \`TRADE\`\
> \
> Real-time market trade stream for futures symbols. Only TAKER side trades are pushed.\
> \
> \*\*Subscribe\*\*:\
> \`\`\`json\
> {"op": "SUBSCRIBE", "topic": "TRADE", "symbol": "BTC\_USDT\_PERP"}\
> \`\`\`\
> \
> \*\*Unsubscribe\*\*:\
> \`\`\`json\
> {"op": "UNSUBSCRIBE", "topic": "TRADE", "symbol": "BTC\_USDT\_PERP"}\
> \`\`\`<br>

````json
{"openapi":"3.0.3","info":{"title":"Pionex Futures WebSocket API","version":"1.0.0"},"tags":[{"name":"Public Stream","description":"Public channels via `wss://ws.pionex.com/wsPub` (no auth required)"}],"servers":[{"url":"wss://ws.pionex.com","description":"Pionex Futures WebSocket Server"}],"paths":{"/wsPub (trade)":{"get":{"tags":["Public Stream"],"summary":"Trade Stream","operationId":"subscribeTrade","description":"**Topic**: `TRADE`\n\nReal-time market trade stream for futures symbols. Only TAKER side trades are pushed.\n\n**Subscribe**:\n```json\n{\"op\": \"SUBSCRIBE\", \"topic\": \"TRADE\", \"symbol\": \"BTC_USDT_PERP\"}\n```\n\n**Unsubscribe**:\n```json\n{\"op\": \"UNSUBSCRIBE\", \"topic\": \"TRADE\", \"symbol\": \"BTC_USDT_PERP\"}\n```\n","parameters":[{"name":"symbol","in":"query","required":true,"description":"Futures trading pair symbol","schema":{"type":"string"}}],"responses":{"200":{"description":"Trade update message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TradeMessage"}}}}}}}},"components":{"schemas":{"TradeMessage":{"type":"object","description":"Trade stream message","properties":{"topic":{"type":"string"},"symbol":{"type":"string","description":"Futures trading pair symbol"},"timestamp":{"type":"integer","format":"int64","description":"Message timestamp in milliseconds"},"data":{"type":"array","description":"Trade records","items":{"$ref":"#/components/schemas/TradeRecord"}}}},"TradeRecord":{"type":"object","properties":{"symbol":{"type":"string","description":"Futures trading pair symbol"},"tradeId":{"type":"string","description":"Unique trade identifier"},"price":{"type":"string","description":"Execution price"},"size":{"type":"string","description":"Trade quantity"},"side":{"type":"string","enum":["BUY","SELL"],"description":"Liquidity taker's direction"},"type":{"type":"string","enum":["NORMAL"],"description":"Trade type (currently only NORMAL for regular trades)"},"timestamp":{"type":"integer","format":"int64","description":"Trade time in milliseconds"}}}}}}
````

## Depth Stream

> \*\*Topic\*\*: \`DEPTH\`\
> \
> Real-time order book depth stream. Updates every 250ms (if changes) to 5s (if no changes).\
> \
> \*\*Subscribe\*\*:\
> \`\`\`json\
> {"op": "SUBSCRIBE", "topic": "DEPTH", "symbol": "BTC\_USDT\_PERP", "limit": 5}\
> \`\`\`\
> \
> \*\*Unsubscribe\*\*:\
> \`\`\`json\
> {"op": "UNSUBSCRIBE", "topic": "DEPTH", "symbol": "BTC\_USDT\_PERP"}\
> \`\`\`<br>

````json
{"openapi":"3.0.3","info":{"title":"Pionex Futures WebSocket API","version":"1.0.0"},"tags":[{"name":"Public Stream","description":"Public channels via `wss://ws.pionex.com/wsPub` (no auth required)"}],"servers":[{"url":"wss://ws.pionex.com","description":"Pionex Futures WebSocket Server"}],"paths":{"/wsPub (depth)":{"get":{"tags":["Public Stream"],"summary":"Depth Stream","operationId":"subscribeDepth","description":"**Topic**: `DEPTH`\n\nReal-time order book depth stream. Updates every 250ms (if changes) to 5s (if no changes).\n\n**Subscribe**:\n```json\n{\"op\": \"SUBSCRIBE\", \"topic\": \"DEPTH\", \"symbol\": \"BTC_USDT_PERP\", \"limit\": 5}\n```\n\n**Unsubscribe**:\n```json\n{\"op\": \"UNSUBSCRIBE\", \"topic\": \"DEPTH\", \"symbol\": \"BTC_USDT_PERP\"}\n```\n","parameters":[{"name":"symbol","in":"query","required":true,"description":"Futures trading pair symbol","schema":{"type":"string"}},{"name":"limit","in":"query","description":"Depth level limit. Range: 1 - 100. Default: 5","schema":{"type":"integer","minimum":1,"maximum":100,"default":5}}],"responses":{"200":{"description":"Depth update message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DepthMessage"}}}}}}}},"components":{"schemas":{"DepthMessage":{"type":"object","description":"Depth stream message","properties":{"topic":{"type":"string"},"symbol":{"type":"string","description":"Futures trading pair symbol"},"timestamp":{"type":"integer","format":"int64","description":"Message timestamp in milliseconds"},"data":{"type":"object","properties":{"bids":{"type":"array","description":"Bid orders [[price, size], ...] sorted by price descending","items":{"type":"array","items":{"type":"string"},"minItems":2,"maxItems":2}},"asks":{"type":"array","description":"Ask orders [[price, size], ...] sorted by price ascending","items":{"type":"array","items":{"type":"string"},"minItems":2,"maxItems":2}}}}}}}}}
````

## Order Book Stream (Incremental)

> \*\*Topic\*\*: \`ORDERBOOK\`\
> \
> Real-time incremental order book updates. Maintains 100 price levels.\
> \
> \*\*Initial Response\*\*: Full snapshot with 100 levels\
> \*\*Subsequent Updates\*\*: Incremental changes only (50ms aggregation)\
> \
> \*\*Subscribe\*\*:\
> \`\`\`json\
> {"op": "SUBSCRIBE", "topic": "ORDERBOOK", "symbol": "BTC\_USDT\_PERP"}\
> \`\`\`\
> \
> \*\*Unsubscribe\*\*:\
> \`\`\`json\
> {"op": "UNSUBSCRIBE", "topic": "ORDERBOOK", "symbol": "BTC\_USDT\_PERP"}\
> \`\`\`\
> \
> \*\*Update Logic\*\*:\
> \- \`action: "SNAPSHOT"\` - Initial full order book (100 levels)\
> \- \`action: "UPDATE"\` - Incremental changes (aggregated over 50ms)\
> \- \`size: "0"\` means the price level was removed\
> \- \`number\` and \`prevNumber\` provide sequence tracking for consistency\
> \- Order book always maintains 100 levels: when a level is consumed, the 101st level becomes the new 100th<br>

````json
{"openapi":"3.0.3","info":{"title":"Pionex Futures WebSocket API","version":"1.0.0"},"tags":[{"name":"Public Stream","description":"Public channels via `wss://ws.pionex.com/wsPub` (no auth required)"}],"servers":[{"url":"wss://ws.pionex.com","description":"Pionex Futures WebSocket Server"}],"paths":{"/wsPub (orderbook)":{"get":{"tags":["Public Stream"],"summary":"Order Book Stream (Incremental)","operationId":"subscribeOrderBook","description":"**Topic**: `ORDERBOOK`\n\nReal-time incremental order book updates. Maintains 100 price levels.\n\n**Initial Response**: Full snapshot with 100 levels\n**Subsequent Updates**: Incremental changes only (50ms aggregation)\n\n**Subscribe**:\n```json\n{\"op\": \"SUBSCRIBE\", \"topic\": \"ORDERBOOK\", \"symbol\": \"BTC_USDT_PERP\"}\n```\n\n**Unsubscribe**:\n```json\n{\"op\": \"UNSUBSCRIBE\", \"topic\": \"ORDERBOOK\", \"symbol\": \"BTC_USDT_PERP\"}\n```\n\n**Update Logic**:\n- `action: \"SNAPSHOT\"` - Initial full order book (100 levels)\n- `action: \"UPDATE\"` - Incremental changes (aggregated over 50ms)\n- `size: \"0\"` means the price level was removed\n- `number` and `prevNumber` provide sequence tracking for consistency\n- Order book always maintains 100 levels: when a level is consumed, the 101st level becomes the new 100th\n","parameters":[{"name":"symbol","in":"query","required":true,"description":"Futures trading pair symbol (only futures symbols supported)","schema":{"type":"string"}}],"responses":{"200":{"description":"Order book update message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderBookMessage"}}}}}}}},"components":{"schemas":{"OrderBookMessage":{"type":"object","description":"Incremental order book message (100 levels)","properties":{"topic":{"type":"string"},"symbol":{"type":"string","description":"Futures trading pair symbol"},"timestamp":{"type":"integer","format":"int64","description":"Message timestamp in milliseconds"},"data":{"type":"object","properties":{"action":{"type":"string","enum":["SNAPSHOT","UPDATE"],"description":"SNAPSHOT for initial full book, UPDATE for incremental changes"},"bids":{"type":"array","description":"Bid updates [[price, size], ...]. size='0' means level removed.","items":{"type":"array","items":{"type":"string"},"minItems":2,"maxItems":2}},"asks":{"type":"array","description":"Ask updates [[price, size], ...]. size='0' means level removed.","items":{"type":"array","items":{"type":"string"},"minItems":2,"maxItems":2}},"number":{"type":"integer","format":"int64","description":"Sequence number of this update"},"prevNumber":{"type":"integer","format":"int64","description":"Sequence number of previous update (for consistency check)"},"timeStamp":{"type":"integer","format":"int64","description":"Order book update timestamp in milliseconds"}}}}}}}}
````

## Index Price Stream

> \*\*Topic\*\*: \`INDEX\`\
> \
> Real-time index price, mark price, and funding rate information for futures symbols.\
> \
> \*\*Subscribe\*\*:\
> \`\`\`json\
> {"op": "SUBSCRIBE", "topic": "INDEX", "symbol": "BTC\_USDT\_PERP"}\
> \`\`\`\
> \
> \*\*Unsubscribe\*\*:\
> \`\`\`json\
> {"op": "UNSUBSCRIBE", "topic": "INDEX", "symbol": "BTC\_USDT\_PERP"}\
> \`\`\`<br>

````json
{"openapi":"3.0.3","info":{"title":"Pionex Futures WebSocket API","version":"1.0.0"},"tags":[{"name":"Public Stream","description":"Public channels via `wss://ws.pionex.com/wsPub` (no auth required)"}],"servers":[{"url":"wss://ws.pionex.com","description":"Pionex Futures WebSocket Server"}],"paths":{"/wsPub (index)":{"get":{"tags":["Public Stream"],"summary":"Index Price Stream","operationId":"subscribeIndex","description":"**Topic**: `INDEX`\n\nReal-time index price, mark price, and funding rate information for futures symbols.\n\n**Subscribe**:\n```json\n{\"op\": \"SUBSCRIBE\", \"topic\": \"INDEX\", \"symbol\": \"BTC_USDT_PERP\"}\n```\n\n**Unsubscribe**:\n```json\n{\"op\": \"UNSUBSCRIBE\", \"topic\": \"INDEX\", \"symbol\": \"BTC_USDT_PERP\"}\n```\n","parameters":[{"name":"symbol","in":"query","required":true,"description":"Futures trading pair symbol","schema":{"type":"string"}}],"responses":{"200":{"description":"Index price update message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IndexMessage"}}}}}}}},"components":{"schemas":{"IndexMessage":{"type":"object","description":"Index price stream message","properties":{"topic":{"type":"string"},"symbol":{"type":"string","description":"Futures trading pair symbol"},"timestamp":{"type":"integer","format":"int64","description":"Message timestamp in milliseconds"},"data":{"type":"array","description":"Index price data","items":{"type":"object","properties":{"symbol":{"type":"string","description":"Futures trading pair symbol"},"indexPrice":{"type":"string","description":"Index price"},"markPrice":{"type":"string","description":"Mark price (used for liquidation calculation)"},"nextFundingRate":{"type":"string","description":"Estimated next funding rate"},"nextFundingTime":{"type":"integer","format":"int64","description":"Next funding time in milliseconds"},"updateTime":{"type":"integer","format":"int64","description":"Update time in milliseconds"}}}}}}}}}
````
