> 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.

# Open Interest

GET /ws/v5/public

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

## AsyncAPI Specification

```yaml
asyncapi: 2.6.0
info:
  title: Open Interest
  version: subpackage_open-interest.open-interest
channels:
  /ws/v5/public:
    publish:
      operationId: subpackage_open-interest.open-interest-publish
      summary: Server message
      message:
        name: subscribe
        payload:
          $ref: '#/components/schemas/openInterest_OpenInterestPush'
    subscribe:
      operationId: subpackage_open-interest.open-interest-subscribe
      summary: Client message
      message:
        name: publish
        payload:
          $ref: '#/components/schemas/openInterest_OpenInterestRequest'
servers:
  Production:
    url: wss://ws.okx.com:8443/
    protocol: wss
    x-default: true
components:
  schemas:
    openInterest_OpenInterestArg:
      type: object
      properties:
        channel:
          type: string
          description: Channel name.
        instId:
          type: string
          description: Subscription filter, echoed back.
      required:
        - channel
      title: OpenInterestArg
    openInterest_OpenInterestData:
      type: object
      properties:
        instType:
          type: string
          description: Instrument type.
        instId:
          type: string
          description: Instrument ID, e.g. BTC-USD-SWAP.
        oi:
          type: string
          description: Open interest in the number of contracts.
        oiCcy:
          type: string
          description: Open interest in the number of coins.
        oiUsd:
          type: string
          description: Open interest in USD.
        ts:
          type: string
          description: Data return time, Unix timestamp in milliseconds.
      description: One open-interest data element.
      title: OpenInterestData
    openInterest_OpenInterestPush:
      type: object
      properties:
        arg:
          $ref: '#/components/schemas/openInterest_OpenInterestArg'
          description: Subscribed channel, echoed back.
        data:
          type: array
          items:
            $ref: '#/components/schemas/openInterest_OpenInterestData'
          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: >-
        Total open interest of a contract; pushed every 3 seconds when data
        changes and at least once every 60 seconds.
      title: OpenInterestPush
    openInterest_OpenInterestSubArg:
      type: object
      properties:
        channel:
          type: string
          description: Channel name.
        instId:
          type: string
          description: Instrument ID, e.g. BTC-USD-SWAP.
      required:
        - channel
      title: OpenInterestSubArg
    openInterest_OpenInterestRequest:
      type: object
      properties:
        op:
          type: string
          description: Operation. `subscribe` or `unsubscribe`.
        args:
          type: array
          items:
            $ref: '#/components/schemas/openInterest_OpenInterestSubArg'
          description: Channels to subscribe to.
      required:
        - op
        - args
      description: Subscribe to the open-interest channel.
      title: OpenInterestRequest

```