> This page is for WebSocket.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://okx-demo.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://okx-demo.ferndocs.com/_mcp/server.

# Trades

GET /ws/v5/public

Reference: https://okx-demo.ferndocs.com/ws/web-socket-api/trades/trades

## AsyncAPI Specification

```yaml
asyncapi: 2.6.0
info:
  title: Trades
  version: subpackage_trades.trades
channels:
  /ws/v5/public:
    publish:
      operationId: subpackage_trades.trades-publish
      summary: Server message
      message:
        name: subscribe
        payload:
          $ref: '#/components/schemas/trades_TradesPush'
    subscribe:
      operationId: subpackage_trades.trades-subscribe
      summary: Client message
      message:
        name: publish
        payload:
          $ref: '#/components/schemas/trades_TradesRequest'
servers:
  Production:
    url: wss://ws.okx.com:8443/
    protocol: wss
    x-default: true
components:
  schemas:
    trades_TradesArg:
      type: object
      properties:
        channel:
          type: string
          description: Channel name.
        instId:
          type: string
          description: Subscription filter, echoed back.
      required:
        - channel
      title: TradesArg
    trades_TradesData:
      type: object
      properties:
        instId:
          type: string
          description: Instrument ID.
        tradeId:
          type: string
          description: Trade ID.
        px:
          type: string
          description: Trade price.
        sz:
          type: string
          description: Trade size.
        side:
          type: string
          description: Trade direction of the taker.
        count:
          type: string
          description: >-
            Number of trades aggregated into this push at the same price and
            side.
        ts:
          type: string
          description: Trade time, Unix timestamp in milliseconds.
      description: One trades data element.
      title: TradesData
    trades_TradesPush:
      type: object
      properties:
        arg:
          $ref: '#/components/schemas/trades_TradesArg'
          description: Subscribed channel, echoed back.
        data:
          type: array
          items:
            $ref: '#/components/schemas/trades_TradesData'
          description: >-
            Subscribed data, pushed on update. For candlesticks each element is
            a string array [ts, o, h, l, c, ...].
        event:
          type: string
          description: >-
            On subscription acknowledgments and errors: `subscribe`,
            `unsubscribe`, or `error`.
        id:
          type: string
          description: Request ID, echoed on acknowledgments and errors.
        code:
          type: string
          description: Error code (error events only).
        msg:
          type: string
          description: Error message (error events only).
        connId:
          type: string
          description: WebSocket connection ID.
      description: >-
        Public trade fills for an instrument; pushed once per taker order
        (aggregated), with a maximum of one push every 100 ms.
      title: TradesPush
    trades_TradesSubArg:
      type: object
      properties:
        channel:
          type: string
          description: Channel name.
        instId:
          type: string
          description: Instrument ID, e.g. BTC-USDT.
      required:
        - channel
      title: TradesSubArg
    trades_TradesRequest:
      type: object
      properties:
        op:
          type: string
          description: Operation. `subscribe` or `unsubscribe`.
        args:
          type: array
          items:
            $ref: '#/components/schemas/trades_TradesSubArg'
          description: Channels to subscribe to.
      required:
        - op
        - args
      description: Subscribe to the trades channel.
      title: TradesRequest

```