> 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/trade-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. Up to 100 trade records per message, sorted by timestamp descending.\
> \
> \*\*Subscribe\*\*:\
> \`\`\`json\
> {"op": "SUBSCRIBE", "topic": "TRADE", "symbol": "BTC\_USDT"}\
> \`\`\`\
> \
> \*\*Unsubscribe\*\*:\
> \`\`\`json\
> {"op": "UNSUBSCRIBE", "topic": "TRADE", "symbol": "BTC\_USDT"}\
> \`\`\`<br>

````json
{"openapi":"3.0.3","info":{"title":"Pionex 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 WebSocket Server"}],"paths":{"/wsPub (trade)":{"get":{"tags":["Public Stream"],"summary":"Trade Stream","operationId":"subscribeTrade","description":"**Topic**: `TRADE`\n\nReal-time market trade stream. Up to 100 trade records per message, sorted by timestamp descending.\n\n**Subscribe**:\n```json\n{\"op\": \"SUBSCRIBE\", \"topic\": \"TRADE\", \"symbol\": \"BTC_USDT\"}\n```\n\n**Unsubscribe**:\n```json\n{\"op\": \"UNSUBSCRIBE\", \"topic\": \"TRADE\", \"symbol\": \"BTC_USDT\"}\n```\n","parameters":[{"name":"symbol","in":"query","required":true,"description":"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":"Trading pair symbol"},"timestamp":{"type":"integer","format":"int64","description":"Message timestamp in milliseconds"},"data":{"type":"array","description":"Up to 100 trade records sorted by timestamp descending","maxItems":100,"items":{"$ref":"#/components/schemas/TradeRecord"}}}},"TradeRecord":{"type":"object","properties":{"symbol":{"type":"string","description":"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"},"timestamp":{"type":"integer","format":"int64","description":"Fill time in milliseconds"}}}}}}
````

## Depth Stream

> \*\*Topic\*\*: \`DEPTH\`\
> \
> Real-time order book depth stream.\
> \
> \*\*Subscribe\*\*:\
> \`\`\`json\
> {"op": "SUBSCRIBE", "topic": "DEPTH", "symbol": "BTC\_USDT", "limit": 5}\
> \`\`\`\
> \
> \*\*Unsubscribe\*\*:\
> \`\`\`json\
> {"op": "UNSUBSCRIBE", "topic": "DEPTH", "symbol": "BTC\_USDT"}\
> \`\`\`<br>

````json
{"openapi":"3.0.3","info":{"title":"Pionex 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 WebSocket Server"}],"paths":{"/wsPub (depth)":{"get":{"tags":["Public Stream"],"summary":"Depth Stream","operationId":"subscribeDepth","description":"**Topic**: `DEPTH`\n\nReal-time order book depth stream.\n\n**Subscribe**:\n```json\n{\"op\": \"SUBSCRIBE\", \"topic\": \"DEPTH\", \"symbol\": \"BTC_USDT\", \"limit\": 5}\n```\n\n**Unsubscribe**:\n```json\n{\"op\": \"UNSUBSCRIBE\", \"topic\": \"DEPTH\", \"symbol\": \"BTC_USDT\"}\n```\n","parameters":[{"name":"symbol","in":"query","required":true,"description":"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":"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}}}}}}}}}
````
