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

# Orderbook WebSocket

> Connect to `wss://synthesis.trade/api/v1/orderbook/ws` and send JSON messages over the socket.

Subscription behavior:
- If you send `markets`, an initial snapshot is returned and then live deltas are streamed.
- If you send `venue` without `markets`, the socket subscribes to that venue.
- If you send only `{ "type": "subscribe" }`, the socket subscribes to all venues.



## OpenAPI

````yaml /openapi.json get /api/v1/orderbook/ws
openapi: 3.1.0
info:
  title: Synthesis API
  version: 1.0.0
  description: Unified prediction market API for Polymarket and Kalshi.
servers:
  - url: https://synthesis.trade
security: []
tags:
  - name: Projects
    description: Create and manage project accounts, sessions, and account API keys.
  - name: Accounts
    description: >-
      Authenticate and manage account-level sessions, account API keys, and
      public account preferences.
  - name: Markets
    description: Unified market discovery and analytics across Polymarket and Kalshi.
  - name: Polymarket
    description: Polymarket market data, prices, orderbooks, trades, and holders endpoints.
  - name: Kalshi
    description: Kalshi market data, events, history, leaderboard, and profile endpoints.
  - name: Wallets
    description: Wallet management routes. Each wallet supports multiple chains.
  - name: Polygon
    description: >-
      Polygon wallet routes for balances, orders, minting, redemption,
      withdrawals, and swaps.
  - name: Polygon Copytrades
    description: Polymarket copytrade configuration and management for Polygon wallets.
  - name: Solana
    description: >-
      Solana wallet routes used for Kalshi balances, KYC, orders, redemption,
      and withdrawals.
  - name: News
    description: News endpoints with market and event matching.
  - name: WebSockets
    description: >-
      Real-time streaming endpoints for orderbooks, trades, balances, and live
      data feeds.
paths:
  /api/v1/orderbook/ws:
    get:
      tags:
        - WebSockets
      summary: Orderbook WebSocket
      description: >-
        Connect to `wss://synthesis.trade/api/v1/orderbook/ws` and send JSON
        messages over the socket.


        Subscription behavior:

        - If you send `markets`, an initial snapshot is returned and then live
        deltas are streamed.

        - If you send `venue` without `markets`, the socket subscribes to that
        venue.

        - If you send only `{ "type": "subscribe" }`, the socket subscribes to
        all venues.
      operationId: orderbook-ws
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - type
              properties:
                type:
                  type: string
                  description: >-
                    WebSocket message type. Supported values: `subscribe` or
                    `unsubscribe`.
                venue:
                  type: string
                  description: >-
                    Optional venue filter when subscribing without explicit
                    markets. Supported values: `polymarket` or `kalshi`.
                markets:
                  type: array
                  items:
                    type: string
                  description: >-
                    Optional market list. Maximum `1000` items. Accepts both
                    Polymarket token IDs and Kalshi market IDs. Mixed-venue
                    lists are supported in the same subscribe request.
                  example:
                    - '12345'
                    - KXBTC-25-T100000
      responses:
        '101':
          description: WebSocket connection established
          content:
            application/json:
              examples:
                Snapshot:
                  summary: Initial orderbook snapshot returned on subscribe
                  value:
                    success: true
                    response:
                      orderbooks:
                        - venue: polymarket
                          orderbook:
                            condition_id: >-
                              0xbd71b43bb47eb60dbcb41fa25df2a0ed4da612873d6e0447a2c730bd4cc25910
                            token_id: >-
                              21742633143463906290569050155826241533067272736897614950488156847949938836455
                            bids:
                              '0.61': '1000'
                              '0.60': '800'
                            asks:
                              '0.62': '900'
                              '0.63': '600'
                            best_bid: '0.61'
                            best_ask: '0.62'
                            hash: abc123
                            created_at: '2026-01-01T00:00:00'
                        - venue: kalshi
                          orderbook:
                            market_id: KXBTC-25-T100000
                            'yes':
                              bids:
                                '58': '25'
                              asks:
                                '60': '15'
                              best_bid: '58'
                              best_ask: '60'
                            'no':
                              bids:
                                '40': '15'
                              asks:
                                '42': '20'
                              best_bid: '40'
                              best_ask: '42'
                            sequence: 12345
                            created_at: '2026-01-01T00:00:00'
                Polymarket Delta:
                  summary: Live Polymarket orderbook delta streamed after subscribe
                  value:
                    success: true
                    response:
                      venue: polymarket
                      delta:
                        condition_id: >-
                          0xbd71b43bb47eb60dbcb41fa25df2a0ed4da612873d6e0447a2c730bd4cc25910
                        token_id: >-
                          21742633143463906290569050155826241533067272736897614950488156847949938836455
                        amount: '500'
                        price: '0.62'
                        side: BUY
                        best_bid: '0.62'
                        best_ask: '0.63'
                        hash: def456
                        created_at: '2026-01-01T00:00:01'
                Kalshi Delta:
                  summary: Live Kalshi orderbook delta streamed after subscribe
                  value:
                    success: true
                    response:
                      venue: kalshi
                      delta:
                        market_id: KXBTC-25-T100000
                        amount: '25'
                        price: '58'
                        side: 'yes'
                        yes_best_bid: '58'
                        yes_best_ask: '60'
                        no_best_bid: '40'
                        no_best_ask: '42'
                        sequence: 12346
                        created_at: '2026-01-01T00:00:01'
                Unsubscribed:
                  summary: Unsubscribe acknowledgment
                  value:
                    success: true
                    response: Unsubscribed
                Error:
                  summary: Error response
                  value:
                    success: false
                    response: Invalid markets
      security: []

````