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

# Markets WebSocket — stream real-time market price updates

> Establishes a WebSocket connection for streaming V2 market price changes in real-time.

**Connection**: `wss://therundown.io/api/v2/ws/markets?key=YOUR_API_KEY`

**Filter parameters** (query string):
- `affiliate_ids` — comma-separated affiliate IDs
- `sport_ids` — comma-separated sport IDs
- `event_ids` — comma-separated event IDs
- `market_ids` — comma-separated market IDs

All filters are optional. If none are specified, all messages are received.

**Heartbeat**: Server sends `{"meta":{"type":"heartbeat"},"data":{"now":"<RFC3339>"}}` every 15 seconds.

**Message format**:
```json
{
  "meta": {...},
  "data": {
    "affiliate_id": 19,
    "sport_id": 4,
    "event_id": "abc123",
    "market_id": 1,
    ...
  }
}
```

**Queue**: 1024-message buffer per client. If the client falls behind, messages are dropped.




## OpenAPI

````yaml get /api/v2/ws/markets
openapi: 3.1.0
info:
  title: TheRundown Sports API
  version: 2.0.0
  description: >
    Real-time and historical sports betting data, odds, lines, and statistics
    across major North American and international sports leagues.


    ## Authentication

    All endpoints (except `/sports` and `/affiliates`) require authentication.
    Pass your API key using one of:

    - **Query parameter**: `?key=YOUR_API_KEY`

    - **Header**: `X-Therundown-Key: YOUR_API_KEY`

    ## Off-the-Board Sentinel Value

    The value **0.0001** indicates a line is "off the board" — the sportsbook
    has temporarily removed pricing (e.g., pending injury news). This is NOT an
    error. Display as "Off Board" or "N/A" in your UI.


    ## Rate Limiting

    Requests are rate-limited per API key tier. Check response headers for
    current limits.


    ## Data Updates

    - Live odds update in real-time during games

    - Use delta endpoints for efficient polling of changes

    - WebSocket connections available for streaming updates


    ## V1 vs V2

    V2 endpoints use market-based data structures (market_id, participants, line
    prices). V1 endpoints use legacy line-based structures (moneyline, spread,
    total objects). V2 is recommended for new integrations.
  contact:
    name: TheRundown API Support
    url: https://therundown.io
    email: support@therundown.io
  termsOfService: https://therundown.io/terms
servers:
  - url: https://therundown.io
    description: Production
security:
  - ApiKeyQuery: []
  - ApiKeyHeader: []
tags:
  - name: V2 Sports
    description: Sport listings, dates, and teams (V2)
  - name: V2 Events
    description: Events with market-based odds (V2)
  - name: V2 Markets
    description: Market definitions, odds, deltas, and history (V2)
  - name: V2 Teams
    description: Team data, players, and stats (V2)
  - name: V2 Players
    description: Player data (V2)
  - name: V2 Stats
    description: Team and player statistics (V2)
  - name: V2 WebSocket
    description: Real-time streaming via WebSocket (V2)
  - name: V2 Reference
    description: Reference data — affiliates, sportsbooks, season types (V2)
  - name: V1 Events
    description: Events with line-based odds (V1 legacy)
  - name: V1 Lines
    description: Moneyline, spread, total, best-line endpoints (V1 legacy)
  - name: V1 Sports
    description: Sport listings, dates, events, schedules (V1 legacy)
  - name: V1 Delta
    description: Delta/change feeds (V1 legacy)
  - name: V1 Reference
    description: Reference data (V1 legacy)
  - name: V1 WebSocket
    description: Real-time streaming via WebSocket (V1 legacy)
paths:
  /api/v2/ws/markets:
    get:
      tags:
        - V2 WebSocket
      summary: Markets WebSocket — stream real-time market price updates
      description: >
        Establishes a WebSocket connection for streaming V2 market price changes
        in real-time.


        **Connection**: `wss://therundown.io/api/v2/ws/markets?key=YOUR_API_KEY`


        **Filter parameters** (query string):

        - `affiliate_ids` — comma-separated affiliate IDs

        - `sport_ids` — comma-separated sport IDs

        - `event_ids` — comma-separated event IDs

        - `market_ids` — comma-separated market IDs


        All filters are optional. If none are specified, all messages are
        received.


        **Heartbeat**: Server sends
        `{"meta":{"type":"heartbeat"},"data":{"now":"<RFC3339>"}}` every 15
        seconds.


        **Message format**:

        ```json

        {
          "meta": {...},
          "data": {
            "affiliate_id": 19,
            "sport_id": 4,
            "event_id": "abc123",
            "market_id": 1,
            ...
          }
        }

        ```


        **Queue**: 1024-message buffer per client. If the client falls behind,
        messages are dropped.
      operationId: v2WebSocketMarkets
      parameters:
        - $ref: '#/components/parameters/AffiliateIDsQuery'
        - name: sport_ids
          in: query
          schema:
            type: string
          description: Comma-separated sport IDs to filter
        - name: event_ids
          in: query
          schema:
            type: string
          description: Comma-separated event IDs to filter
        - name: market_ids
          in: query
          schema:
            type: string
          description: Comma-separated market IDs to filter
      responses:
        '101':
          description: WebSocket upgrade successful
components:
  parameters:
    AffiliateIDsQuery:
      name: affiliate_ids
      in: query
      schema:
        type: string
      description: >-
        Comma-separated sportsbook/affiliate IDs to filter. Common values
        include DraftKings (19), FanDuel (23), BetMGM (22), Bovada (2), Pinnacle
        (3).
  securitySchemes:
    ApiKeyQuery:
      type: apiKey
      in: query
      name: key
      description: API key as query parameter
    ApiKeyHeader:
      type: apiKey
      in: header
      name: X-Therundown-Key
      description: API key as request header

````