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

# Sports Stream

> Public live game-state stream (Polymarket-hosted) — `league` is `nba`, `nfl`, or `mlb`.

Public live game-state stream (Polymarket-hosted) — `league` is `nba`, `nfl`, or `mlb`.


## AsyncAPI

````yaml openpx.asyncapi.yaml sports
id: sports
title: Sports Stream
description: >-
  Public live game-state stream (Polymarket-hosted) — `league` is `nba`, `nfl`,
  or `mlb`.
servers:
  - id: inprocess
    protocol: ws
    host: openpx-engine
    bindings: []
    variables: []
address: /v1/sports
parameters: []
bindings: []
operations:
  - &ref_12
    id: sports_subscribe
    title: Subscribe
    description: Add to the active sports subscription set
    type: send
    messages:
      - &ref_20
        id: sports_subscribe
        contentType: application/json
        payload:
          - name: Subscribe
            description: Add to the active sports subscription set
            type: object
            properties:
              - name: league
                type: string
                description: League slug — `nba`, `nfl`, or `mlb`.
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - league
          properties:
            league:
              type: string
              description: League slug — `nba`, `nfl`, or `mlb`.
              x-parser-schema-id: <anonymous-schema-116>
          x-parser-schema-id: <anonymous-schema-115>
        title: Subscribe
        description: Add to the active sports subscription set
        example: |-
          {
            "league": "example"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: sports_subscribe
    bindings: []
    extensions: &ref_0
      - id: x-parser-unique-object-id
        value: sports
  - &ref_13
    id: sports_unsubscribe
    title: Unsubscribe
    description: Remove from the active sports subscription set
    type: send
    messages:
      - &ref_21
        id: sports_unsubscribe
        contentType: application/json
        payload:
          - name: Unsubscribe
            description: Remove from the active sports subscription set
            type: object
            properties:
              - name: league
                type: string
                description: League slug — `nba`, `nfl`, or `mlb`.
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - league
          properties:
            league:
              type: string
              description: League slug — `nba`, `nfl`, or `mlb`.
              x-parser-schema-id: <anonymous-schema-118>
          x-parser-schema-id: <anonymous-schema-117>
        title: Unsubscribe
        description: Remove from the active sports subscription set
        example: |-
          {
            "league": "example"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: sports_unsubscribe
    bindings: []
    extensions: *ref_0
  - &ref_6
    id: sports_receive_SportResult
    title: SportResult
    description: Live score, period, and clock for a tracked game.
    type: receive
    messages:
      - &ref_14
        id: SportResult
        contentType: application/json
        payload:
          - name: SportResult
            description: Live score, period, and clock for a tracked game.
            type: object
            properties:
              - name: away_team
                type: string
                required: true
              - name: elapsed
                type: &ref_1
                  - string
                  - 'null'
                required: false
              - name: ended
                type: boolean
                required: true
              - name: finished_timestamp
                type: &ref_2
                  - string
                  - 'null'
                required: false
              - name: game_id
                type: integer
                required: true
              - name: home_team
                type: string
                required: true
              - name: league_abbreviation
                type: string
                required: true
              - name: live
                type: boolean
                required: true
              - name: period
                type: &ref_3
                  - string
                  - 'null'
                required: false
              - name: score
                type: &ref_4
                  - string
                  - 'null'
                required: false
              - name: slug
                type: string
                required: true
              - name: status
                type: string
                required: true
              - name: turn
                type: &ref_5
                  - string
                  - 'null'
                required: false
        headers: []
        jsonPayloadSchema:
          description: >-
            Real-time sports score/state from the Polymarket Sports WebSocket.
            Serializes as snake_case for end-users; aliases accept the upstream
            camelCase.
          properties:
            away_team:
              type: string
              x-parser-schema-id: <anonymous-schema-102>
            elapsed:
              type: *ref_1
              x-parser-schema-id: <anonymous-schema-103>
            ended:
              type: boolean
              x-parser-schema-id: <anonymous-schema-104>
            finished_timestamp:
              format: date-time
              type: *ref_2
              x-parser-schema-id: <anonymous-schema-105>
            game_id:
              format: uint64
              minimum: 0
              type: integer
              x-parser-schema-id: <anonymous-schema-106>
            home_team:
              type: string
              x-parser-schema-id: <anonymous-schema-107>
            league_abbreviation:
              type: string
              x-parser-schema-id: <anonymous-schema-108>
            live:
              type: boolean
              x-parser-schema-id: <anonymous-schema-109>
            period:
              type: *ref_3
              x-parser-schema-id: <anonymous-schema-110>
            score:
              type: *ref_4
              x-parser-schema-id: <anonymous-schema-111>
            slug:
              type: string
              x-parser-schema-id: <anonymous-schema-112>
            status:
              type: string
              x-parser-schema-id: <anonymous-schema-113>
            turn:
              type: *ref_5
              x-parser-schema-id: <anonymous-schema-114>
          required:
            - away_team
            - ended
            - game_id
            - home_team
            - league_abbreviation
            - live
            - slug
            - status
          title: SportResult
          type: object
          x-parser-schema-id: SportResult
        title: Sport result
        description: Live score, period, and clock for a tracked game.
        example: |-
          {
            "away_team": "example",
            "elapsed": "example",
            "ended": true,
            "finished_timestamp": "2026-01-01T00:00:00Z",
            "game_id": 0,
            "home_team": "example",
            "league_abbreviation": "example",
            "live": true,
            "period": "example",
            "score": "example",
            "slug": "example",
            "status": "example",
            "turn": "example"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: SportResult
    bindings: []
    extensions: *ref_0
  - &ref_7
    id: sports_receive_Connected
    title: Connected
    description: Initial socket establishment.
    type: receive
    messages:
      - &ref_15
        id: Connected
        contentType: application/json
        payload:
          - name: Connected
            description: Initial socket establishment.
            type: object
            properties:
              - name: kind
                type: string
                enumValues:
                  - Connected
                required: true
        headers: []
        jsonPayloadSchema:
          description: Initial socket establishment.
          properties:
            kind:
              enum:
                - Connected
              type: string
              x-parser-schema-id: <anonymous-schema-35>
          required:
            - kind
          type: object
          x-parser-schema-id: Connected
        title: Connected
        description: Initial socket establishment.
        example: |-
          {
            "kind": "Connected"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: Connected
    bindings: []
    extensions: *ref_0
  - &ref_8
    id: sports_receive_Reconnected
    title: Reconnected
    description: >-
      Socket re-established after an outage — `gap_ms` is the wall-clock
      interval since the last received message.
    type: receive
    messages:
      - &ref_16
        id: Reconnected
        contentType: application/json
        payload:
          - name: Reconnected
            description: >-
              Socket re-established after an outage — `gap_ms` is the wall-clock
              interval since the last received message.
            type: object
            properties:
              - name: gap_ms
                type: integer
                required: true
              - name: kind
                type: string
                enumValues:
                  - Reconnected
                required: true
        headers: []
        jsonPayloadSchema:
          description: >-
            Socket re-established after an outage — `gap_ms` is the wall-clock
            interval since the last received message.
          properties:
            gap_ms:
              format: uint64
              minimum: 0
              type: integer
              x-parser-schema-id: <anonymous-schema-36>
            kind:
              enum:
                - Reconnected
              type: string
              x-parser-schema-id: <anonymous-schema-37>
          required:
            - gap_ms
            - kind
          type: object
          x-parser-schema-id: Reconnected
        title: Reconnected
        description: >-
          Socket re-established after an outage — `gap_ms` is the wall-clock
          interval since the last received message.
        example: |-
          {
            "gap_ms": 0,
            "kind": "Reconnected"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: Reconnected
    bindings: []
    extensions: *ref_0
  - &ref_9
    id: sports_receive_Lagged
    title: Lagged
    description: >-
      Slow consumer dropped messages — every affected book is invalidated and
      must be rebuilt from the next `Snapshot`.
    type: receive
    messages:
      - &ref_17
        id: Lagged
        contentType: application/json
        payload:
          - name: Lagged
            description: >-
              Slow consumer dropped messages — every affected book is
              invalidated and must be rebuilt from the next `Snapshot`.
            type: object
            properties:
              - name: dropped
                type: integer
                required: true
              - name: first_seq
                type: integer
                required: true
              - name: kind
                type: string
                enumValues:
                  - Lagged
                required: true
              - name: last_seq
                type: integer
                required: true
        headers: []
        jsonPayloadSchema:
          description: >-
            Slow consumer dropped messages — every affected book is invalidated
            and must be rebuilt from the next `Snapshot`.
          properties:
            dropped:
              format: uint64
              minimum: 0
              type: integer
              x-parser-schema-id: <anonymous-schema-38>
            first_seq:
              format: uint64
              minimum: 0
              type: integer
              x-parser-schema-id: <anonymous-schema-39>
            kind:
              enum:
                - Lagged
              type: string
              x-parser-schema-id: <anonymous-schema-40>
            last_seq:
              format: uint64
              minimum: 0
              type: integer
              x-parser-schema-id: <anonymous-schema-41>
          required:
            - dropped
            - first_seq
            - kind
            - last_seq
          type: object
          x-parser-schema-id: Lagged
        title: Lagged
        description: >-
          Slow consumer dropped messages — every affected book is invalidated
          and must be rebuilt from the next `Snapshot`.
        example: |-
          {
            "dropped": 0,
            "first_seq": 0,
            "kind": "Lagged",
            "last_seq": 0
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: Lagged
    bindings: []
    extensions: *ref_0
  - &ref_10
    id: sports_receive_BookInvalidated
    title: BookInvalidated
    description: >-
      A specific market's book is no longer trustworthy — drop cache and wait
      for next `Snapshot` (reasons: `Reconnect`, `Lag`, `SequenceGap`,
      `ExchangeReset`).
    type: receive
    messages:
      - &ref_18
        id: BookInvalidated
        contentType: application/json
        payload:
          - name: BookInvalidated
            description: >-
              A specific market's book is no longer trustworthy — drop cache and
              wait for next `Snapshot` (reasons: `Reconnect`, `Lag`,
              `SequenceGap`, `ExchangeReset`).
            type: object
            properties:
              - name: kind
                type: string
                enumValues:
                  - BookInvalidated
                required: true
              - name: market_id
                type: string
                required: true
              - name: reason
                type: oneOf
                description: >-
                  Why a specific book was invalidated — handed to users so they
                  can decide whether to alert, log, or handle it silently.
                required: true
                properties:
                  - name: SequenceGap
                    type: object
                    required: true
                    properties:
                      - name: expected
                        type: integer
                        required: true
                      - name: received
                        type: integer
                        required: true
        headers: []
        jsonPayloadSchema:
          description: >-
            A specific market's book is no longer trustworthy — drop cache and
            wait for next `Snapshot` (reasons: `Reconnect`, `Lag`,
            `SequenceGap`, `ExchangeReset`).
          properties:
            kind:
              enum:
                - BookInvalidated
              type: string
              x-parser-schema-id: <anonymous-schema-42>
            market_id:
              type: string
              x-parser-schema-id: <anonymous-schema-43>
            reason:
              description: >-
                Why a specific book was invalidated — handed to users so they
                can decide whether to alert, log, or handle it silently.
              oneOf:
                - enum:
                    - Reconnect
                    - Lag
                    - ExchangeReset
                  type: string
                  x-parser-schema-id: <anonymous-schema-29>
                - additionalProperties: false
                  properties:
                    SequenceGap:
                      properties:
                        expected:
                          format: uint64
                          minimum: 0
                          type: integer
                          x-parser-schema-id: <anonymous-schema-32>
                        received:
                          format: uint64
                          minimum: 0
                          type: integer
                          x-parser-schema-id: <anonymous-schema-33>
                      required:
                        - expected
                        - received
                      type: object
                      x-parser-schema-id: <anonymous-schema-31>
                  required:
                    - SequenceGap
                  type: object
                  x-parser-schema-id: <anonymous-schema-30>
              x-parser-schema-id: InvalidationReason
          required:
            - kind
            - market_id
            - reason
          type: object
          x-parser-schema-id: BookInvalidated
        title: Book invalidated
        description: >-
          A specific market's book is no longer trustworthy — drop cache and
          wait for next `Snapshot` (reasons: `Reconnect`, `Lag`, `SequenceGap`,
          `ExchangeReset`).
        example: |-
          {
            "kind": "BookInvalidated",
            "market_id": "example",
            "reason": null
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: BookInvalidated
    bindings: []
    extensions: *ref_0
  - &ref_11
    id: sports_receive_Error
    title: Error
    description: A non-fatal error observed on the connection (session continues).
    type: receive
    messages:
      - &ref_19
        id: Error
        contentType: application/json
        payload:
          - name: Error
            description: A non-fatal error observed on the connection (session continues).
            type: object
            properties:
              - name: kind
                type: string
                enumValues:
                  - Error
                required: true
              - name: message
                type: string
                required: true
        headers: []
        jsonPayloadSchema:
          description: A non-fatal error observed on the connection (session continues).
          properties:
            kind:
              enum:
                - Error
              type: string
              x-parser-schema-id: <anonymous-schema-44>
            message:
              type: string
              x-parser-schema-id: <anonymous-schema-45>
          required:
            - kind
            - message
          type: object
          x-parser-schema-id: Error
        title: Error
        description: A non-fatal error observed on the connection (session continues).
        example: |-
          {
            "kind": "Error",
            "message": "example"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: Error
    bindings: []
    extensions: *ref_0
sendOperations:
  - *ref_6
  - *ref_7
  - *ref_8
  - *ref_9
  - *ref_10
  - *ref_11
receiveOperations:
  - *ref_12
  - *ref_13
sendMessages:
  - *ref_14
  - *ref_15
  - *ref_16
  - *ref_17
  - *ref_18
  - *ref_19
receiveMessages:
  - *ref_20
  - *ref_21
extensions:
  - id: x-parser-unique-object-id
    value: sports
securitySchemes: []

````