> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hypedexer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# WebSocket endpoint

> Upgrade to WebSocket. After connection, send subscribe/unsubscribe JSON messages to start/stop receiving real-time data.



## OpenAPI

````yaml /live-data/openapi-websocket.json get /ws
openapi: 3.0.3
info:
  title: 'Hypedexer API: Live Data (WebSocket)'
  version: 0.1.0
  description: >-
    WebSocket API for real-time Hyperliquid live data streaming.


    ## Connection


    ```

    wss://api.hypedexer.com/ws

    ```


    Authenticate the handshake with your API key: `X-API-Key: <key>` header,
    `Authorization: Bearer <key>` header, or the `api_key` query parameter (the
    only option from a browser). A handshake without a valid key is refused with
    HTTP `401`.


    On successful connection, the server sends:

    ```json

    {"type": "connected"}

    ```


    ## Heartbeat


    The server sends `{"type": "ping", "ts": <ms>}` every 60 seconds. Answer
    each one with `{"method": "pong"}`. A client that never answers is closed
    after about 180 seconds with close code `4000` (`timeout`).


    ## Protocol


    All messages are JSON. The client sends **subscribe**, **unsubscribe**, and
    **pong** messages. The server sends **acknowledgements**, **snapshots**, and
    **real-time updates**.


    Both `"method"` and `"type"` fields are accepted as the message type
    discriminator (e.g., `{"method": "subscribe", ...}` and `{"type":
    "subscribe", ...}` are equivalent).


    ## Supported subscriptions


    | Type | Required params | Description |

    |------|----------------|-------------|

    | `userFills` | `user` | Fills for a specific user (snapshot + updates) |

    | `allFills` | - | All fills globally |

    | `allMids` | - | Mid prices for all coins (polled every 300ms) |

    | `trades` | - | Trade events |

    | `l2Book` | `coin` | L2 order book (snapshot + streaming updates) |

    | `l4Book` | `coin` | L4 raw order book (snapshot + streaming updates) |

    | `l4BookUpdates` | - | L4 book update events |

    | `bbo` | `coin` | Best Bid/Offer top-of-book (emitted only when top-of-book
    changes) |

    | `liquidations` | - | Liquidation events aggregated per `liquidatedUser`
    and block |


    ## Acknowledgement formats


    **userFills & allMids** use `subscriptionResponse`:

    ```json

    {"channel": "subscriptionResponse", "data": {"method": "subscribe",
    "subscription": {...}}}

    ```


    **All other types** use `subscriptionUpdate`:

    ```json

    {"type": "subscriptionUpdate", "subscription": {...}, "active": true}

    ```
  contact:
    name: Hypedexer
servers:
  - url: wss://api.hypedexer.com
    description: Production (WebSocket)
security:
  - ApiKeyQuery: []
tags:
  - name: WebSocket
    description: >-
      Single multiplex endpoint `GET /ws`: subscribe and unsubscribe via JSON
      messages. Message schemas are documented under **components/schemas**.
paths:
  /ws:
    get:
      tags:
        - WebSocket
      summary: WebSocket endpoint
      description: >-
        Upgrade to WebSocket. After connection, send subscribe/unsubscribe JSON
        messages to start/stop receiving real-time data.
      operationId: liveDataWebSocket
      parameters:
        - name: api_key
          in: query
          required: false
          schema:
            type: string
          description: >-
            Your API key, when you cannot set a header (browsers). Otherwise
            send `X-API-Key: <key>`.
      responses:
        '101':
          description: >-
            WebSocket upgrade successful. Server sends `{"type": "connected"}`
            immediately.
        '401':
          description: >-
            Missing or invalid API key. The handshake is refused before the
            connection opens.
      security:
        - ApiKeyQuery: []
components:
  securitySchemes:
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api_key
      description: >-
        Your Hypedexer API key (`wss://api.hypedexer.com/ws?api_key=<key>`).
        Outside a browser, prefer the `X-API-Key` header.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.