> Use the canonical URL for citations. For the complete Predict API documentation index, fetch https://docs.staging.trypredict.com/llms.txt.

# Orderbook Updates

GET /ws

Subscribe to full replacement Hyperliquid L2 order-book snapshots for one Predict outcome side, with aggregated bid and ask price levels.

Reference: https://docs.staging.trypredict.com/api-reference/web-socket-api/order-book

## AsyncAPI Specification

```yaml
asyncapi: 2.6.0
info:
  title: Orderbook Updates
  version: subpackage_order-book.order-book
  description: >-
    Subscribe to full replacement Hyperliquid L2 order-book snapshots for one
    Predict outcome side, with aggregated bid and ask price levels.
channels:
  /ws:
    description: >-
      Subscribe to full replacement Hyperliquid L2 order-book snapshots for one
      Predict outcome side, with aggregated bid and ask price levels.
    publish:
      operationId: subpackage_order-book.order-book-publish
      summary: Server message
      message:
        name: update
        payload:
          $ref: '#/components/schemas/orderBook_OrderBookUpdate'
    subscribe:
      operationId: subpackage_order-book.order-book-subscribe
      summary: Client message
      message:
        name: subscribe
        payload:
          $ref: '#/components/schemas/orderBook_SubscribeOrderBook'
servers:
  Testnet:
    url: wss://api.hyperliquid-testnet.xyz/
    protocol: wss
    x-default: true
  Mainnet:
    url: wss://api.hyperliquid.xyz/
    protocol: wss
components:
  schemas:
    common_BookLevel:
      type: object
      properties:
        px:
          type: string
        sz:
          type: string
        'n':
          type: integer
      required:
        - px
        - sz
        - 'n'
      title: BookLevel
    orderBook_OrderBookData:
      type: object
      properties:
        coin:
          type: string
        time:
          type: integer
          format: int64
        levels:
          type: array
          items:
            type: array
            items:
              $ref: '#/components/schemas/common_BookLevel'
          description: Full replacement snapshot with bids first and asks second.
      required:
        - coin
        - time
        - levels
      title: OrderBookData
    orderBook_OrderBookUpdate:
      type: object
      properties:
        channel:
          type: string
          enum:
            - l2Book
        data:
          $ref: '#/components/schemas/orderBook_OrderBookData'
      required:
        - channel
        - data
      title: OrderBookUpdate
    common_SubscriptionMethod:
      type: string
      enum:
        - subscribe
        - unsubscribe
      title: SubscriptionMethod
    common_Coin:
      type: string
      description: Side-specific coin in `#<10 * hl_id + side>` form.
      title: Coin
    orderBook_OrderBookSubscription:
      type: object
      properties:
        type:
          type: string
          enum:
            - l2Book
        coin:
          $ref: '#/components/schemas/common_Coin'
        nSigFigs:
          type: integer
        mantissa:
          type: integer
        fast:
          type: boolean
          description: True sends five levels per side. False sends twenty.
      required:
        - type
        - coin
      title: OrderBookSubscription
    orderBook_SubscribeOrderBook:
      type: object
      properties:
        method:
          $ref: '#/components/schemas/common_SubscriptionMethod'
        subscription:
          $ref: '#/components/schemas/orderBook_OrderBookSubscription'
      required:
        - method
        - subscription
      title: SubscribeOrderBook

```