openapi: "3.1.0"

info:
  title: "PreciseData Sports Data API"
  version: "1.0.0"
  description: "Reference for the v1 routes of the PreciseData sports data service. Paths, parameters, credit costs, headers and response fields match the implemented API. Every response example is an illustrative fixture. Scores, dates, player lines and standings do not describe an actual game or record. Times use UTC. A successful read costs the credits shown on its route. A conditional request that matches the current ETag returns 304 at no cost."

servers:
  - url: "https://api.precisedata.io/v1"
    description: "Production v1 base URL"

security:
  - ApiKeyHeader: []
  - BearerAuth: []

tags:
  - name: "Catalog"
    description: "Sports, competitions, collection coverage and source acknowledgements."
  - name: "Events"
    description: "Schedules, live contests, box scores and plays."
  - name: "People"
    description: "Person profiles, game logs and statistical splits."
  - name: "Organizations"
    description: "Team profiles, dated rosters and schedules."
  - name: "Tables"
    description: "Standings and rankings snapshots."
  - name: "Identity"
    description: "Name search and provider identifier resolution."
  - name: "Account"
    description: "Key issuance, balance and recent usage."
  - name: "Billing"
    description: "Prepaid credit-pack purchases."

paths:
  /sports:
    get:
      tags: ["Catalog"]
      operationId: "sports"
      summary: "List sports"
      description: "List sport identifiers and the sport family each belongs to."
      x-credits: 1
      parameters:
        - name: "limit"
          in: "query"
          required: false
          description: "Maximum number of records in a page."
          schema:
            type: "integer"
            minimum: 1
            maximum: 250
            default: 50
          example: 50
        - name: "offset"
          in: "query"
          required: false
          description: "Number of records to skip. Use next_offset from the previous page."
          schema:
            type: "integer"
            minimum: 0
            maximum: 10000000
            default: 0
          example: 0
      responses:
        "200":
          description: "Successful response. The example contains illustrative fixture data."
          headers:
            ETag:
              $ref: "#/components/headers/ETag"
            X-Credits-Used:
              $ref: "#/components/headers/CreditsUsed"
            X-Credits-Remaining:
              $ref: "#/components/headers/CreditsRemaining"
            X-RateLimit-Limit:
              $ref: "#/components/headers/RateLimitLimit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/RateLimitRemaining"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    type: "array"
                    items:
                      $ref: "#/components/schemas/Sport"
                  meta:
                    $ref: "#/components/schemas/PageMeta"
                required: ["data", "meta"]
              example:
                data:
                  - id: "spt_basketball"
                    slug: "basketball"
                    name: "Basketball"
                    family: "Basketball"
                    updated_at: "2026-02-01T00:00:00Z"
                  - id: "spt_soccer"
                    slug: "soccer"
                    name: "Soccer"
                    family: "Soccer"
                    updated_at: "2026-02-01T00:00:00Z"
                meta:
                  limit: 50
                  offset: 0
                  has_more: false
                  next_offset: null
        "304":
          $ref: "#/components/responses/NotModified"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/InsufficientCredits"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /competitions:
    get:
      tags: ["Catalog"]
      operationId: "competitions"
      summary: "List competitions"
      description: "List competition IDs and slugs with their stored event count, collection capabilities, source order and per-source health."
      x-credits: 1
      parameters:
        - name: "sport"
          in: "query"
          required: false
          description: "Sport slug or ID, such as basketball or spt_basketball."
          schema:
            type: "string"
          example: "basketball"
        - name: "limit"
          in: "query"
          required: false
          description: "Maximum number of records in a page."
          schema:
            type: "integer"
            minimum: 1
            maximum: 250
            default: 50
          example: 50
        - name: "offset"
          in: "query"
          required: false
          description: "Number of records to skip. Use next_offset from the previous page."
          schema:
            type: "integer"
            minimum: 0
            maximum: 10000000
            default: 0
          example: 0
      responses:
        "200":
          description: "Successful response. The example contains illustrative fixture data."
          headers:
            ETag:
              $ref: "#/components/headers/ETag"
            X-Credits-Used:
              $ref: "#/components/headers/CreditsUsed"
            X-Credits-Remaining:
              $ref: "#/components/headers/CreditsRemaining"
            X-RateLimit-Limit:
              $ref: "#/components/headers/RateLimitLimit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/RateLimitRemaining"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    type: "array"
                    items:
                      $ref: "#/components/schemas/Competition"
                  meta:
                    $ref: "#/components/schemas/PageMeta"
                required: ["data", "meta"]
              example:
                data:
                  - id: "cmp_nba"
                    slug: "nba"
                    name: "NBA"
                    sport_id: "spt_basketball"
                    type: "league"
                    updated_at: "2026-02-01T00:00:00Z"
                    event_count: 1230
                    coverage:
                      scores: true
                      boxscore: true
                      plays: true
                      standings: true
                      rankings: false
                      history: true
                      sources: ["nba", "espn"]
                      source_roles:
                        - source: "nba"
                          role: "primary"
                          cadence: "event_dependent"
                        - source: "espn"
                          role: "backup"
                          cadence: "event_dependent"
                      notes: null
                      history_sources: ["nba", "espn"]
                      coverage_level: "event_dependent"
                      data_status: "collected"
                      source_health:
                        - competition_id: "cmp_nba"
                          source: "nba"
                          kind: "scoreboard"
                          last_success: "2026-02-04T02:36:00Z"
                          last_failure: null
                          state: "ok"
                meta:
                  limit: 50
                  offset: 0
                  has_more: false
                  next_offset: null
        "304":
          $ref: "#/components/responses/NotModified"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/InsufficientCredits"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /competitions/{id}/coverage:
    get:
      tags: ["Catalog"]
      operationId: "competition-coverage"
      summary: "Get observed coverage"
      description: "Count stored events, finals, events reported by two or more sources, and finals with statistics or plays. Each source lists its observed date range. Result checks report agreement with an independent comparison where one exists."
      x-credits: 1
      parameters:
        - name: "id"
          in: "path"
          required: true
          description: "Competition slug or ID, such as nba or cmp_nba."
          schema:
            type: "string"
            minLength: 1
            maxLength: 160
          example: "nba"
      responses:
        "200":
          description: "Successful response. The example contains illustrative fixture data."
          headers:
            ETag:
              $ref: "#/components/headers/ETag"
            X-Credits-Used:
              $ref: "#/components/headers/CreditsUsed"
            X-Credits-Remaining:
              $ref: "#/components/headers/CreditsRemaining"
            X-RateLimit-Limit:
              $ref: "#/components/headers/RateLimitLimit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/RateLimitRemaining"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    $ref: "#/components/schemas/ObservedCoverage"
                required: ["data"]
              example:
                data:
                  competition_id: "cmp_nba"
                  events: 1230
                  finals: 1180
                  events_with_two_sources: 1102
                  finals_with_stats: 1175
                  finals_with_plays: 1168
                  first_event: "2025-10-21"
                  last_event: "2026-04-12"
                  sources:
                    - source: "espn"
                      events: 1110
                      finals: 1080
                      first_event: "2025-10-21"
                      last_event: "2026-04-12"
                      last_observed_at: "2026-02-04T02:36:00Z"
                    - source: "nba"
                      events: 1230
                      finals: 1180
                      first_event: "2025-10-21"
                      last_event: "2026-04-12"
                      last_observed_at: "2026-02-04T02:36:02Z"
                  detail_sources:
                    - source: "nba"
                      part: "people"
                      events: 1175
                    - source: "nba"
                      part: "plays"
                      events: 1168
                    - source: "nba"
                      part: "teams"
                      events: 1175
                  result_checks: []
        "304":
          $ref: "#/components/responses/NotModified"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/InsufficientCredits"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /competitions/{id}/history:
    get:
      tags: ["Catalog"]
      operationId: "competition-history"
      summary: "List collection windows"
      description: "List completed historical collection windows and source editions by source, newest first. Empty windows are included. A date range gives the observed bounds and can contain gaps."
      x-credits: 1
      parameters:
        - name: "id"
          in: "path"
          required: true
          description: "Competition slug or ID, such as nba or cmp_nba."
          schema:
            type: "string"
            minLength: 1
            maxLength: 160
          example: "nba"
        - name: "source"
          in: "query"
          required: false
          description: "Restrict windows to one source, such as nba or wikipedia."
          schema:
            type: "string"
          example: "nba"
        - name: "limit"
          in: "query"
          required: false
          description: "Maximum number of records in a page."
          schema:
            type: "integer"
            minimum: 1
            maximum: 250
            default: 50
          example: 50
        - name: "offset"
          in: "query"
          required: false
          description: "Number of records to skip. Use next_offset from the previous page."
          schema:
            type: "integer"
            minimum: 0
            maximum: 10000000
            default: 0
          example: 0
      responses:
        "200":
          description: "Successful response. The example contains illustrative fixture data."
          headers:
            ETag:
              $ref: "#/components/headers/ETag"
            X-Credits-Used:
              $ref: "#/components/headers/CreditsUsed"
            X-Credits-Remaining:
              $ref: "#/components/headers/CreditsRemaining"
            X-RateLimit-Limit:
              $ref: "#/components/headers/RateLimitLimit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/RateLimitRemaining"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    type: "array"
                    items:
                      $ref: "#/components/schemas/HistoryWindow"
                  meta:
                    $ref: "#/components/schemas/PageMeta"
                required: ["data", "meta"]
              example:
                data:
                  - source: "nba"
                    first_day: "2026-01-01"
                    last_day: "2026-01-31"
                    state: "collected"
                    event_count: 214
                    kind: "window"
                    edition: null
                    source_url: null
                    updated_at: "2026-02-01T04:10:00Z"
                  - source: "nba"
                    first_day: "2025-12-01"
                    last_day: "2025-12-31"
                    state: "collected"
                    event_count: 221
                    kind: "window"
                    edition: null
                    source_url: null
                    updated_at: "2026-01-02T04:12:00Z"
                meta:
                  limit: 50
                  offset: 0
                  has_more: false
                  next_offset: null
        "304":
          $ref: "#/components/responses/NotModified"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/InsufficientCredits"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /events:
    get:
      tags: ["Events"]
      operationId: "events"
      summary: "List events"
      description: "Find events by competition, UTC date, season or status. A published date can have a null start time. An event spanning several days appears in each day it covers. Scores are strings so values such as -11 or E keep their meaning."
      x-credits: 1
      parameters:
        - name: "competition"
          in: "query"
          required: false
          description: "Competition slug or ID, such as nba or cmp_nba."
          schema:
            type: "string"
          example: "nba"
        - name: "date"
          in: "query"
          required: false
          description: "UTC calendar date in YYYY-MM-DD format."
          schema:
            type: "string"
            format: "date"
          example: "2026-02-04"
        - name: "status"
          in: "query"
          required: false
          description: "Restrict results to one event status."
          schema:
            type: "string"
            enum: ["scheduled", "in_progress", "final", "postponed", "cancelled", "suspended", "unknown"]
          example: "in_progress"
        - name: "season"
          in: "query"
          required: false
          description: "Season label or ID, such as 2025-26."
          schema:
            type: "string"
          example: "2025-26"
        - name: "limit"
          in: "query"
          required: false
          description: "Maximum number of records in a page."
          schema:
            type: "integer"
            minimum: 1
            maximum: 250
            default: 50
          example: 50
        - name: "offset"
          in: "query"
          required: false
          description: "Number of records to skip. Use next_offset from the previous page."
          schema:
            type: "integer"
            minimum: 0
            maximum: 10000000
            default: 0
          example: 0
      responses:
        "200":
          description: "Successful response. The example contains illustrative fixture data."
          headers:
            ETag:
              $ref: "#/components/headers/ETag"
            X-Credits-Used:
              $ref: "#/components/headers/CreditsUsed"
            X-Credits-Remaining:
              $ref: "#/components/headers/CreditsRemaining"
            X-RateLimit-Limit:
              $ref: "#/components/headers/RateLimitLimit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/RateLimitRemaining"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    type: "array"
                    items:
                      $ref: "#/components/schemas/Event"
                  meta:
                    $ref: "#/components/schemas/PageMeta"
                required: ["data", "meta"]
              example:
                data:
                  - id: "evt_example_001"
                    name: "New York Knicks at Boston Celtics"
                    sport_id: "spt_basketball"
                    competition_id: "cmp_nba"
                    season_id: "sea_example_2026"
                    season: "2025-26"
                    stage_id: "stg_example_regular"
                    stage: "Regular Season"
                    start_time: "2026-02-04T00:30:00Z"
                    event_date: "2026-02-04"
                    end_date: null
                    end_time: null
                    status: "in_progress"
                    clock: "2:14"
                    period: 4
                    source: "nba"
                    updated_at: "2026-02-04T02:36:02Z"
                    score_disputed: false
                    last_status_observed_at: "2026-02-04T02:36:02Z"
                    coverage:
                      person_stats: true
                      team_stats: true
                      plays: true
                    attributions: []
                    competition_ids: ["cmp_nba"]
                    participants:
                      - id: "org_bos"
                        type: "organization"
                        name: "Boston Celtics"
                        side: "home"
                        score: "108"
                        result: null
                        finish_position: null
                        seed: null
                      - id: "org_nyk"
                        type: "organization"
                        name: "New York Knicks"
                        side: "away"
                        score: "104"
                        result: null
                        finish_position: null
                        seed: null
                meta:
                  limit: 50
                  offset: 0
                  has_more: false
                  next_offset: null
        "304":
          $ref: "#/components/responses/NotModified"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/InsufficientCredits"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /events/{id}:
    get:
      tags: ["Events"]
      operationId: "event"
      summary: "Get an event"
      description: "Read one event with its participants, venue and period scores. A merged event ID returns the surviving event and its ID in the X-Canonical-Id header."
      x-credits: 1
      parameters:
        - name: "id"
          in: "path"
          required: true
          description: "Event ID returned by an event list."
          schema:
            type: "string"
            minLength: 1
            maxLength: 160
          example: "evt_example_001"
      responses:
        "200":
          description: "Successful response. The example contains illustrative fixture data."
          headers:
            ETag:
              $ref: "#/components/headers/ETag"
            X-Canonical-Id:
              $ref: "#/components/headers/CanonicalId"
            X-Credits-Used:
              $ref: "#/components/headers/CreditsUsed"
            X-Credits-Remaining:
              $ref: "#/components/headers/CreditsRemaining"
            X-RateLimit-Limit:
              $ref: "#/components/headers/RateLimitLimit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/RateLimitRemaining"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    $ref: "#/components/schemas/EventDetail"
                required: ["data"]
              example:
                data:
                  id: "evt_example_001"
                  name: "New York Knicks at Boston Celtics"
                  sport_id: "spt_basketball"
                  competition_id: "cmp_nba"
                  season_id: "sea_example_2026"
                  season: "2025-26"
                  stage_id: "stg_example_regular"
                  stage: "Regular Season"
                  start_time: "2026-02-04T00:30:00Z"
                  event_date: "2026-02-04"
                  end_date: null
                  end_time: null
                  status: "final"
                  clock: null
                  period: 4
                  source: "nba"
                  updated_at: "2026-02-04T02:58:40Z"
                  score_disputed: false
                  last_status_observed_at: "2026-02-04T02:58:40Z"
                  coverage:
                    person_stats: true
                    team_stats: true
                    plays: true
                  attributions: []
                  competition_ids: ["cmp_nba"]
                  participants:
                    - id: "org_bos"
                      type: "organization"
                      name: "Boston Celtics"
                      side: "home"
                      score: "112"
                      result: "win"
                      finish_position: null
                      seed: null
                    - id: "org_nyk"
                      type: "organization"
                      name: "New York Knicks"
                      side: "away"
                      score: "106"
                      result: "loss"
                      finish_position: null
                      seed: null
                  venue_id: "ven_example_001"
                  venue:
                    id: "ven_example_001"
                    type: "venue"
                    name: "Example Arena"
                    birth_date: null
                    abbreviation: null
                    timezone: "America/New_York"
                    updated_at: "2026-01-10T00:00:00Z"
                    aliases: []
                  periods:
                    - participant_id: "org_bos"
                      period: 1
                      score: "29"
                    - participant_id: "org_nyk"
                      period: 1
                      score: "26"
                    - participant_id: "org_bos"
                      period: 2
                      score: "27"
                    - participant_id: "org_nyk"
                      period: 2
                      score: "28"
                    - participant_id: "org_bos"
                      period: 3
                      score: "30"
                    - participant_id: "org_nyk"
                      period: 3
                      score: "24"
                    - participant_id: "org_bos"
                      period: 4
                      score: "26"
                    - participant_id: "org_nyk"
                      period: 4
                      score: "28"
        "304":
          $ref: "#/components/responses/NotModified"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/InsufficientCredits"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /events/{id}/boxscore:
    get:
      tags: ["Events"]
      operationId: "boxscore"
      summary: "Get a box score"
      description: "Read typed person and team stat blocks for an event. Each block names its sport and groups metrics by category. Missing values are omitted or null. A recorded zero is a value."
      x-credits: 1
      parameters:
        - name: "id"
          in: "path"
          required: true
          description: "Event ID returned by an event list."
          schema:
            type: "string"
            minLength: 1
            maxLength: 160
          example: "evt_example_001"
      responses:
        "200":
          description: "Successful response. The example contains illustrative fixture data."
          headers:
            ETag:
              $ref: "#/components/headers/ETag"
            X-Canonical-Id:
              $ref: "#/components/headers/CanonicalId"
            X-Credits-Used:
              $ref: "#/components/headers/CreditsUsed"
            X-Credits-Remaining:
              $ref: "#/components/headers/CreditsRemaining"
            X-RateLimit-Limit:
              $ref: "#/components/headers/RateLimitLimit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/RateLimitRemaining"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    $ref: "#/components/schemas/BoxScore"
                required: ["data"]
              example:
                data:
                  event_id: "evt_example_001"
                  attributions: []
                  organizations:
                    - id: "org_bos"
                      name: "Boston Celtics"
                      stats:
                        sport: "basketball"
                        game:
                          points: 112
                          rebounds: 46
                          assists: 27
                          steals: 8
                          blocks: 5
                          turnovers: 11
                      source: "nba"
                      updated_at: "2026-02-04T02:58:40Z"
                    - id: "org_nyk"
                      name: "New York Knicks"
                      stats:
                        sport: "basketball"
                        game:
                          points: 106
                          rebounds: 41
                          assists: 22
                          steals: 6
                          blocks: 3
                          turnovers: 13
                      source: "nba"
                      updated_at: "2026-02-04T02:58:40Z"
                  persons:
                    - id: "per_example_001"
                      name: "Avery Example"
                      organization_id: "org_bos"
                      stats:
                        sport: "basketball"
                        game:
                          minutes: 36
                          points: 31
                          rebounds: 7
                          assists: 8
                          steals: 2
                          blocks: 0
                          turnovers: 3
                      source: "nba"
                      updated_at: "2026-02-04T02:58:40Z"
        "304":
          $ref: "#/components/responses/NotModified"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/InsufficientCredits"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /events/{id}/plays:
    get:
      tags: ["Events"]
      operationId: "plays"
      summary: "List plays"
      description: "Page through plays in sequence order. Racing events return laps and golf events return holes in the same shape. Each page costs five credits."
      x-credits: 5
      parameters:
        - name: "id"
          in: "path"
          required: true
          description: "Event ID returned by an event list."
          schema:
            type: "string"
            minLength: 1
            maxLength: 160
          example: "evt_example_001"
        - name: "limit"
          in: "query"
          required: false
          description: "Maximum number of records in a page."
          schema:
            type: "integer"
            minimum: 1
            maximum: 250
            default: 50
          example: 50
        - name: "offset"
          in: "query"
          required: false
          description: "Number of records to skip. Use next_offset from the previous page."
          schema:
            type: "integer"
            minimum: 0
            maximum: 10000000
            default: 0
          example: 0
      responses:
        "200":
          description: "Successful response. The example contains illustrative fixture data."
          headers:
            ETag:
              $ref: "#/components/headers/ETag"
            X-Canonical-Id:
              $ref: "#/components/headers/CanonicalId"
            X-Credits-Used:
              $ref: "#/components/headers/CreditsUsed"
            X-Credits-Remaining:
              $ref: "#/components/headers/CreditsRemaining"
            X-RateLimit-Limit:
              $ref: "#/components/headers/RateLimitLimit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/RateLimitRemaining"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    type: "array"
                    items:
                      $ref: "#/components/schemas/Play"
                  meta:
                    $ref: "#/components/schemas/PlayPageMeta"
                required: ["data", "meta"]
              example:
                data:
                  - id: "ply_example_0411"
                    sequence: 411
                    period: 4
                    clock: "2:31"
                    type: "rebound"
                    description: "Avery Example defensive rebound"
                    stats:
                      home_score: 106
                      away_score: 104
                    updated_at: "2026-02-04T02:35:48Z"
                  - id: "ply_example_0412"
                    sequence: 412
                    period: 4
                    clock: "2:14"
                    type: "jump_shot"
                    description: "Avery Example 24-foot three-point jump shot made"
                    stats:
                      home_score: 109
                      away_score: 104
                      points: 3
                    updated_at: "2026-02-04T02:36:02Z"
                meta:
                  limit: 50
                  offset: 0
                  has_more: false
                  next_offset: null
                  attributions: []
        "304":
          $ref: "#/components/responses/NotModified"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/InsufficientCredits"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /live:
    get:
      tags: ["Events"]
      operationId: "live"
      summary: "List live events"
      description: "List events in progress whose status a source confirmed within the last five minutes. Each row includes last_status_observed_at. Responses can be cached for up to five seconds."
      x-credits: 1
      parameters:
        - name: "competition"
          in: "query"
          required: false
          description: "Competition slug or ID, such as nba or cmp_nba."
          schema:
            type: "string"
          example: "nba"
        - name: "limit"
          in: "query"
          required: false
          description: "Maximum number of records in a page."
          schema:
            type: "integer"
            minimum: 1
            maximum: 250
            default: 50
          example: 50
        - name: "offset"
          in: "query"
          required: false
          description: "Number of records to skip. Use next_offset from the previous page."
          schema:
            type: "integer"
            minimum: 0
            maximum: 10000000
            default: 0
          example: 0
      responses:
        "200":
          description: "Successful response. The example contains illustrative fixture data."
          headers:
            ETag:
              $ref: "#/components/headers/ETag"
            X-Credits-Used:
              $ref: "#/components/headers/CreditsUsed"
            X-Credits-Remaining:
              $ref: "#/components/headers/CreditsRemaining"
            X-RateLimit-Limit:
              $ref: "#/components/headers/RateLimitLimit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/RateLimitRemaining"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    type: "array"
                    items:
                      $ref: "#/components/schemas/Event"
                  meta:
                    $ref: "#/components/schemas/PageMeta"
                required: ["data", "meta"]
              example:
                data:
                  - id: "evt_example_001"
                    name: "New York Knicks at Boston Celtics"
                    sport_id: "spt_basketball"
                    competition_id: "cmp_nba"
                    season_id: "sea_example_2026"
                    season: "2025-26"
                    stage_id: "stg_example_regular"
                    stage: "Regular Season"
                    start_time: "2026-02-04T00:30:00Z"
                    event_date: "2026-02-04"
                    end_date: null
                    end_time: null
                    status: "in_progress"
                    clock: "2:14"
                    period: 4
                    source: "nba"
                    updated_at: "2026-02-04T02:36:02Z"
                    score_disputed: false
                    last_status_observed_at: "2026-02-04T02:36:02Z"
                    coverage:
                      person_stats: true
                      team_stats: true
                      plays: true
                    attributions: []
                    competition_ids: ["cmp_nba"]
                    participants:
                      - id: "org_bos"
                        type: "organization"
                        name: "Boston Celtics"
                        side: "home"
                        score: "108"
                        result: null
                        finish_position: null
                        seed: null
                      - id: "org_nyk"
                        type: "organization"
                        name: "New York Knicks"
                        side: "away"
                        score: "104"
                        result: null
                        finish_position: null
                        seed: null
                meta:
                  limit: 50
                  offset: 0
                  has_more: false
                  next_offset: null
        "304":
          $ref: "#/components/responses/NotModified"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/InsufficientCredits"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /persons/{id}:
    get:
      tags: ["People"]
      operationId: "person"
      summary: "Get a person"
      description: "Read a person profile with birth date where published and alternate names."
      x-credits: 1
      parameters:
        - name: "id"
          in: "path"
          required: true
          description: "Person ID returned by a box score, roster or search."
          schema:
            type: "string"
            minLength: 1
            maxLength: 160
          example: "per_example_001"
      responses:
        "200":
          description: "Successful response. The example contains illustrative fixture data."
          headers:
            ETag:
              $ref: "#/components/headers/ETag"
            X-Canonical-Id:
              $ref: "#/components/headers/CanonicalId"
            X-Credits-Used:
              $ref: "#/components/headers/CreditsUsed"
            X-Credits-Remaining:
              $ref: "#/components/headers/CreditsRemaining"
            X-RateLimit-Limit:
              $ref: "#/components/headers/RateLimitLimit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/RateLimitRemaining"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    $ref: "#/components/schemas/Entity"
                required: ["data"]
              example:
                data:
                  id: "per_example_001"
                  type: "person"
                  name: "Avery Example"
                  birth_date: "1998-04-12"
                  abbreviation: null
                  timezone: null
                  updated_at: "2026-02-04T02:58:40Z"
                  aliases: ["A. Example"]
        "304":
          $ref: "#/components/responses/NotModified"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/InsufficientCredits"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /persons/{id}/gamelog:
    get:
      tags: ["People"]
      operationId: "gamelog"
      summary: "Get a game log"
      description: "List a person's per-event statistics, newest first. Each row carries the organization the person appeared for and that side's result."
      x-credits: 1
      parameters:
        - name: "id"
          in: "path"
          required: true
          description: "Person ID returned by a box score, roster or search."
          schema:
            type: "string"
            minLength: 1
            maxLength: 160
          example: "per_example_001"
        - name: "season"
          in: "query"
          required: false
          description: "Season label or ID, such as 2025-26."
          schema:
            type: "string"
          example: "2025-26"
        - name: "limit"
          in: "query"
          required: false
          description: "Maximum number of records in a page."
          schema:
            type: "integer"
            minimum: 1
            maximum: 250
            default: 50
          example: 50
        - name: "offset"
          in: "query"
          required: false
          description: "Number of records to skip. Use next_offset from the previous page."
          schema:
            type: "integer"
            minimum: 0
            maximum: 10000000
            default: 0
          example: 0
      responses:
        "200":
          description: "Successful response. The example contains illustrative fixture data."
          headers:
            ETag:
              $ref: "#/components/headers/ETag"
            X-Canonical-Id:
              $ref: "#/components/headers/CanonicalId"
            X-Credits-Used:
              $ref: "#/components/headers/CreditsUsed"
            X-Credits-Remaining:
              $ref: "#/components/headers/CreditsRemaining"
            X-RateLimit-Limit:
              $ref: "#/components/headers/RateLimitLimit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/RateLimitRemaining"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    type: "array"
                    items:
                      $ref: "#/components/schemas/GameLogEntry"
                  meta:
                    $ref: "#/components/schemas/PageMeta"
                required: ["data", "meta"]
              example:
                data:
                  - event_id: "evt_example_001"
                    name: "New York Knicks at Boston Celtics"
                    start_time: "2026-02-04T00:30:00Z"
                    event_date: "2026-02-04"
                    competition_id: "cmp_nba"
                    season_id: "sea_example_2026"
                    season: "2025-26"
                    organization_id: "org_bos"
                    side: "home"
                    result: "win"
                    finish_position: null
                    stats:
                      sport: "basketball"
                      game:
                        minutes: 36
                        points: 31
                        rebounds: 7
                        assists: 8
                    source: "nba"
                    updated_at: "2026-02-04T02:58:40Z"
                    attributions: []
                  - event_id: "evt_example_003"
                    name: "Boston Celtics at Example City"
                    start_time: "2026-02-02T00:00:00Z"
                    event_date: "2026-02-02"
                    competition_id: "cmp_nba"
                    season_id: "sea_example_2026"
                    season: "2025-26"
                    organization_id: "org_bos"
                    side: "away"
                    result: "loss"
                    finish_position: null
                    stats:
                      sport: "basketball"
                      game:
                        minutes: 34
                        points: 22
                        rebounds: 5
                        assists: 6
                    source: "nba"
                    updated_at: "2026-02-02T02:41:15Z"
                    attributions: []
                meta:
                  limit: 50
                  offset: 0
                  has_more: false
                  next_offset: null
        "304":
          $ref: "#/components/responses/NotModified"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/InsufficientCredits"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /persons/{id}/splits:
    get:
      tags: ["People"]
      operationId: "splits"
      summary: "Get splits"
      description: "Group a person's numeric statistics by side, result or season. Each metric reports its mean and the number of games that recorded it."
      x-credits: 1
      parameters:
        - name: "id"
          in: "path"
          required: true
          description: "Person ID returned by a box score, roster or search."
          schema:
            type: "string"
            minLength: 1
            maxLength: 160
          example: "per_example_001"
        - name: "season"
          in: "query"
          required: false
          description: "Season label or ID, such as 2025-26."
          schema:
            type: "string"
          example: "2025-26"
        - name: "by"
          in: "query"
          required: false
          description: "Grouping dimension. Defaults to side."
          schema:
            type: "string"
            enum: ["side", "result", "season"]
          example: "side"
      responses:
        "200":
          description: "Successful response. The example contains illustrative fixture data."
          headers:
            ETag:
              $ref: "#/components/headers/ETag"
            X-Canonical-Id:
              $ref: "#/components/headers/CanonicalId"
            X-Credits-Used:
              $ref: "#/components/headers/CreditsUsed"
            X-Credits-Remaining:
              $ref: "#/components/headers/CreditsRemaining"
            X-RateLimit-Limit:
              $ref: "#/components/headers/RateLimitLimit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/RateLimitRemaining"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    $ref: "#/components/schemas/Splits"
                required: ["data"]
              example:
                data:
                  person_id: "per_example_001"
                  by: "side"
                  groups:
                    - value: "away"
                      games: 24
                      stats:
                        game:
                          points:
                            mean: 24.6
                            samples: 24
                          assists:
                            mean: 6.1
                            samples: 24
                    - value: "home"
                      games: 26
                      stats:
                        game:
                          points:
                            mean: 27.3
                            samples: 26
                          assists:
                            mean: 6.8
                            samples: 26
        "304":
          $ref: "#/components/responses/NotModified"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/InsufficientCredits"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /organizations/{id}:
    get:
      tags: ["Organizations"]
      operationId: "organization"
      summary: "Get an organization"
      description: "Read a team profile. related_teams gives the corrected team ID where a federation code previously covered two national teams."
      x-credits: 1
      parameters:
        - name: "id"
          in: "path"
          required: true
          description: "Organization ID returned by an event, standings table or search."
          schema:
            type: "string"
            minLength: 1
            maxLength: 160
          example: "org_bos"
      responses:
        "200":
          description: "Successful response. The example contains illustrative fixture data."
          headers:
            ETag:
              $ref: "#/components/headers/ETag"
            X-Canonical-Id:
              $ref: "#/components/headers/CanonicalId"
            X-Credits-Used:
              $ref: "#/components/headers/CreditsUsed"
            X-Credits-Remaining:
              $ref: "#/components/headers/CreditsRemaining"
            X-RateLimit-Limit:
              $ref: "#/components/headers/RateLimitLimit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/RateLimitRemaining"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    $ref: "#/components/schemas/Entity"
                required: ["data"]
              example:
                data:
                  id: "org_bos"
                  type: "organization"
                  name: "Boston Celtics"
                  birth_date: null
                  abbreviation: "BOS"
                  timezone: null
                  updated_at: "2026-01-10T00:00:00Z"
                  aliases: ["Boston", "Celtics"]
                  related_teams: []
        "304":
          $ref: "#/components/responses/NotModified"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/InsufficientCredits"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /organizations/{id}/roster:
    get:
      tags: ["Organizations"]
      operationId: "roster"
      summary: "Get a roster"
      description: "List dated roster observations. Without a season or date, the latest observed roster is returned. A date returns the roster valid on that day."
      x-credits: 1
      parameters:
        - name: "id"
          in: "path"
          required: true
          description: "Organization ID returned by an event, standings table or search."
          schema:
            type: "string"
            minLength: 1
            maxLength: 160
          example: "org_bos"
        - name: "season"
          in: "query"
          required: false
          description: "Season label or ID, such as 2025-26."
          schema:
            type: "string"
          example: "2025-26"
        - name: "date"
          in: "query"
          required: false
          description: "Return the roster valid on this UTC date."
          schema:
            type: "string"
            format: "date"
          example: "2026-02-04"
        - name: "limit"
          in: "query"
          required: false
          description: "Maximum number of records in a page."
          schema:
            type: "integer"
            minimum: 1
            maximum: 250
            default: 50
          example: 50
        - name: "offset"
          in: "query"
          required: false
          description: "Number of records to skip. Use next_offset from the previous page."
          schema:
            type: "integer"
            minimum: 0
            maximum: 10000000
            default: 0
          example: 0
      responses:
        "200":
          description: "Successful response. The example contains illustrative fixture data."
          headers:
            ETag:
              $ref: "#/components/headers/ETag"
            X-Canonical-Id:
              $ref: "#/components/headers/CanonicalId"
            X-Credits-Used:
              $ref: "#/components/headers/CreditsUsed"
            X-Credits-Remaining:
              $ref: "#/components/headers/CreditsRemaining"
            X-RateLimit-Limit:
              $ref: "#/components/headers/RateLimitLimit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/RateLimitRemaining"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    type: "array"
                    items:
                      $ref: "#/components/schemas/RosterEntry"
                  meta:
                    $ref: "#/components/schemas/PageMeta"
                required: ["data", "meta"]
              example:
                data:
                  - id: "per_example_001"
                    name: "Avery Example"
                    season_id: "sea_example_2026"
                    season: "2025-26"
                    position: "G"
                    jersey: "7"
                    valid_from: "2025-10-01"
                    valid_to: null
                    updated_at: "2026-02-01T00:00:00Z"
                  - id: "per_example_002"
                    name: "Jordan Sample"
                    season_id: "sea_example_2026"
                    season: "2025-26"
                    position: "F"
                    jersey: "12"
                    valid_from: "2025-10-01"
                    valid_to: null
                    updated_at: "2026-02-01T00:00:00Z"
                meta:
                  limit: 50
                  offset: 0
                  has_more: false
                  next_offset: null
        "304":
          $ref: "#/components/responses/NotModified"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/InsufficientCredits"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /organizations/{id}/schedule:
    get:
      tags: ["Organizations"]
      operationId: "schedule"
      summary: "Get a team schedule"
      description: "List events in which the organization participates. Accepts the same filters as the event list."
      x-credits: 1
      parameters:
        - name: "id"
          in: "path"
          required: true
          description: "Organization ID returned by an event, standings table or search."
          schema:
            type: "string"
            minLength: 1
            maxLength: 160
          example: "org_bos"
        - name: "competition"
          in: "query"
          required: false
          description: "Competition slug or ID, such as nba or cmp_nba."
          schema:
            type: "string"
          example: "nba"
        - name: "date"
          in: "query"
          required: false
          description: "UTC calendar date in YYYY-MM-DD format."
          schema:
            type: "string"
            format: "date"
          example: "2026-02-06"
        - name: "status"
          in: "query"
          required: false
          description: "Restrict results to one event status."
          schema:
            type: "string"
            enum: ["scheduled", "in_progress", "final", "postponed", "cancelled", "suspended", "unknown"]
          example: "scheduled"
        - name: "season"
          in: "query"
          required: false
          description: "Season label or ID, such as 2025-26."
          schema:
            type: "string"
          example: "2025-26"
        - name: "limit"
          in: "query"
          required: false
          description: "Maximum number of records in a page."
          schema:
            type: "integer"
            minimum: 1
            maximum: 250
            default: 50
          example: 50
        - name: "offset"
          in: "query"
          required: false
          description: "Number of records to skip. Use next_offset from the previous page."
          schema:
            type: "integer"
            minimum: 0
            maximum: 10000000
            default: 0
          example: 0
      responses:
        "200":
          description: "Successful response. The example contains illustrative fixture data."
          headers:
            ETag:
              $ref: "#/components/headers/ETag"
            X-Canonical-Id:
              $ref: "#/components/headers/CanonicalId"
            X-Credits-Used:
              $ref: "#/components/headers/CreditsUsed"
            X-Credits-Remaining:
              $ref: "#/components/headers/CreditsRemaining"
            X-RateLimit-Limit:
              $ref: "#/components/headers/RateLimitLimit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/RateLimitRemaining"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    type: "array"
                    items:
                      $ref: "#/components/schemas/Event"
                  meta:
                    $ref: "#/components/schemas/PageMeta"
                required: ["data", "meta"]
              example:
                data:
                  - id: "evt_example_004"
                    name: "Boston Celtics at New York Knicks"
                    sport_id: "spt_basketball"
                    competition_id: "cmp_nba"
                    season_id: "sea_example_2026"
                    season: "2025-26"
                    stage_id: "stg_example_regular"
                    stage: "Regular Season"
                    start_time: "2026-02-07T00:30:00Z"
                    event_date: "2026-02-06"
                    end_date: null
                    end_time: null
                    status: "scheduled"
                    clock: null
                    period: null
                    source: "nba"
                    updated_at: "2026-02-04T06:00:00Z"
                    score_disputed: false
                    last_status_observed_at: "2026-02-04T06:00:00Z"
                    coverage:
                      person_stats: false
                      team_stats: false
                      plays: false
                    attributions: []
                    competition_ids: ["cmp_nba"]
                    participants:
                      - id: "org_nyk"
                        type: "organization"
                        name: "New York Knicks"
                        side: "home"
                        score: null
                        result: null
                        finish_position: null
                        seed: null
                      - id: "org_bos"
                        type: "organization"
                        name: "Boston Celtics"
                        side: "away"
                        score: null
                        result: null
                        finish_position: null
                        seed: null
                meta:
                  limit: 50
                  offset: 0
                  has_more: false
                  next_offset: null
        "304":
          $ref: "#/components/responses/NotModified"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/InsufficientCredits"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /standings:
    get:
      tags: ["Tables"]
      operationId: "standings"
      summary: "Get standings"
      description: "Return the latest standings snapshot for each group, such as a conference or division. A date returns the latest snapshot on or before that day."
      x-credits: 1
      parameters:
        - name: "competition"
          in: "query"
          required: false
          description: "Competition slug or ID, such as nba or cmp_nba."
          schema:
            type: "string"
          example: "nba"
        - name: "season"
          in: "query"
          required: false
          description: "Season label or ID, such as 2025-26."
          schema:
            type: "string"
          example: "2025-26"
        - name: "date"
          in: "query"
          required: false
          description: "Latest snapshot on or before this UTC date."
          schema:
            type: "string"
            format: "date"
          example: "2026-02-04"
        - name: "type"
          in: "query"
          required: false
          description: "Group name, matched without regard to case."
          schema:
            type: "string"
          example: "Eastern Conference"
        - name: "limit"
          in: "query"
          required: false
          description: "Maximum number of records in a page."
          schema:
            type: "integer"
            minimum: 1
            maximum: 250
            default: 50
          example: 50
        - name: "offset"
          in: "query"
          required: false
          description: "Number of records to skip. Use next_offset from the previous page."
          schema:
            type: "integer"
            minimum: 0
            maximum: 10000000
            default: 0
          example: 0
      responses:
        "200":
          description: "Successful response. The example contains illustrative fixture data."
          headers:
            ETag:
              $ref: "#/components/headers/ETag"
            X-Credits-Used:
              $ref: "#/components/headers/CreditsUsed"
            X-Credits-Remaining:
              $ref: "#/components/headers/CreditsRemaining"
            X-RateLimit-Limit:
              $ref: "#/components/headers/RateLimitLimit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/RateLimitRemaining"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    type: "array"
                    items:
                      $ref: "#/components/schemas/Snapshot"
                  meta:
                    $ref: "#/components/schemas/PageMeta"
                required: ["data", "meta"]
              example:
                data:
                  - id: "snp_example_001"
                    competition_id: "cmp_nba"
                    season_id: "sea_example_2026"
                    season: "2025-26"
                    type: "Eastern Conference"
                    as_of: "2026-02-04"
                    entries:
                      - id: "org_bos"
                        name: "Boston Celtics"
                        rank: 1
                        stats:
                          wins: 36
                          losses: 14
                          winPercent: 0.72
                          gamesBehind: 0
                      - id: "org_nyk"
                        name: "New York Knicks"
                        rank: 2
                        stats:
                          wins: 33
                          losses: 17
                          winPercent: 0.66
                          gamesBehind: 3
                    source: "espn"
                    updated_at: "2026-02-04T06:00:00Z"
                meta:
                  limit: 50
                  offset: 0
                  has_more: false
                  next_offset: null
        "304":
          $ref: "#/components/responses/NotModified"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/InsufficientCredits"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /rankings:
    get:
      tags: ["Tables"]
      operationId: "rankings"
      summary: "Get rankings"
      description: "Return the latest rankings snapshot for each poll or ranking table. Entries can be organizations or people. A date returns the latest snapshot on or before that day."
      x-credits: 1
      parameters:
        - name: "competition"
          in: "query"
          required: false
          description: "Competition slug or ID, such as ncaam or cmp_ncaam."
          schema:
            type: "string"
          example: "ncaam"
        - name: "season"
          in: "query"
          required: false
          description: "Season label or ID, such as 2025-26."
          schema:
            type: "string"
          example: "2025-26"
        - name: "date"
          in: "query"
          required: false
          description: "Latest snapshot on or before this UTC date."
          schema:
            type: "string"
            format: "date"
          example: "2026-02-03"
        - name: "type"
          in: "query"
          required: false
          description: "Ranking name, matched without regard to case."
          schema:
            type: "string"
          example: "AP Top 25"
        - name: "limit"
          in: "query"
          required: false
          description: "Maximum number of records in a page."
          schema:
            type: "integer"
            minimum: 1
            maximum: 250
            default: 50
          example: 50
        - name: "offset"
          in: "query"
          required: false
          description: "Number of records to skip. Use next_offset from the previous page."
          schema:
            type: "integer"
            minimum: 0
            maximum: 10000000
            default: 0
          example: 0
      responses:
        "200":
          description: "Successful response. The example contains illustrative fixture data."
          headers:
            ETag:
              $ref: "#/components/headers/ETag"
            X-Credits-Used:
              $ref: "#/components/headers/CreditsUsed"
            X-Credits-Remaining:
              $ref: "#/components/headers/CreditsRemaining"
            X-RateLimit-Limit:
              $ref: "#/components/headers/RateLimitLimit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/RateLimitRemaining"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    type: "array"
                    items:
                      $ref: "#/components/schemas/Snapshot"
                  meta:
                    $ref: "#/components/schemas/PageMeta"
                required: ["data", "meta"]
              example:
                data:
                  - id: "snp_example_101"
                    competition_id: "cmp_ncaam"
                    season_id: "sea_example_ncaam_2026"
                    season: "2025-26"
                    type: "AP Top 25"
                    as_of: "2026-02-03"
                    entries:
                      - id: "org_example_201"
                        name: "Example State"
                        rank: 1
                        stats:
                          points: 1525
                          previous: 2
                      - id: "org_example_202"
                        name: "Sample University"
                        rank: 2
                        stats:
                          points: 1480
                          previous: 1
                    source: "espn"
                    updated_at: "2026-02-03T18:00:00Z"
                meta:
                  limit: 50
                  offset: 0
                  has_more: false
                  next_offset: null
        "304":
          $ref: "#/components/responses/NotModified"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/InsufficientCredits"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /search:
    get:
      tags: ["Identity"]
      operationId: "search"
      summary: "Search"
      description: "Find people, organizations and competitions by name, alias, slug or exact ID. Results are ordered by name."
      x-credits: 1
      parameters:
        - name: "q"
          in: "query"
          required: true
          description: "Name, alias, slug or ID to match."
          schema:
            type: "string"
            minLength: 1
            maxLength: 150
          example: "boston"
        - name: "limit"
          in: "query"
          required: false
          description: "Maximum number of records in a page."
          schema:
            type: "integer"
            minimum: 1
            maximum: 250
            default: 50
          example: 50
        - name: "offset"
          in: "query"
          required: false
          description: "Number of records to skip. Use next_offset from the previous page."
          schema:
            type: "integer"
            minimum: 0
            maximum: 10000000
            default: 0
          example: 0
      responses:
        "200":
          description: "Successful response. The example contains illustrative fixture data."
          headers:
            ETag:
              $ref: "#/components/headers/ETag"
            X-Credits-Used:
              $ref: "#/components/headers/CreditsUsed"
            X-Credits-Remaining:
              $ref: "#/components/headers/CreditsRemaining"
            X-RateLimit-Limit:
              $ref: "#/components/headers/RateLimitLimit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/RateLimitRemaining"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    type: "array"
                    items:
                      $ref: "#/components/schemas/SearchHit"
                  meta:
                    $ref: "#/components/schemas/PageMeta"
                required: ["data", "meta"]
              example:
                data:
                  - id: "org_bos"
                    type: "organization"
                    name: "Boston Celtics"
                    updated_at: "2026-01-10T00:00:00Z"
                  - id: "org_example_301"
                    type: "organization"
                    name: "Boston Example FC"
                    updated_at: "2026-01-10T00:00:00Z"
                meta:
                  limit: 50
                  offset: 0
                  has_more: false
                  next_offset: null
        "304":
          $ref: "#/components/responses/NotModified"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/InsufficientCredits"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /ids/lookup:
    get:
      tags: ["Identity"]
      operationId: "id-lookup"
      summary: "Look up a provider ID"
      description: "Resolve a provider's identifier to a stable PreciseData ID. A provider can reuse a number across scopes. When an ID matches more than one entity, the response is 409 with the candidate matches. Supply scope and type to choose one."
      x-credits: 1
      parameters:
        - name: "source"
          in: "query"
          required: true
          description: "Provider name, such as espn, mlb, nhl or nflverse."
          schema:
            type: "string"
          example: "espn"
        - name: "id"
          in: "query"
          required: true
          description: "Identifier published by that provider."
          schema:
            type: "string"
          example: "2"
        - name: "scope"
          in: "query"
          required: false
          description: "Provider scope, such as basketball/nba."
          schema:
            type: "string"
          example: "basketball/nba"
        - name: "type"
          in: "query"
          required: false
          description: "Entity type, such as person, organization, event or competition."
          schema:
            type: "string"
          example: "organization"
      responses:
        "200":
          description: "Successful response. The example contains illustrative fixture data."
          headers:
            ETag:
              $ref: "#/components/headers/ETag"
            X-Credits-Used:
              $ref: "#/components/headers/CreditsUsed"
            X-Credits-Remaining:
              $ref: "#/components/headers/CreditsRemaining"
            X-RateLimit-Limit:
              $ref: "#/components/headers/RateLimitLimit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/RateLimitRemaining"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    $ref: "#/components/schemas/IdMapping"
                required: ["data"]
              example:
                data:
                  id: "org_bos"
                  type: "organization"
                  source: "espn"
                  scope: "basketball/nba"
                  source_id: "2"
                  updated_at: "2026-01-10T00:00:00Z"
        "304":
          $ref: "#/components/responses/NotModified"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "402":
          $ref: "#/components/responses/InsufficientCredits"
        "404":
          $ref: "#/components/responses/NotFound"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /account:
    get:
      tags: ["Account"]
      operationId: "account"
      summary: "Get account balance"
      description: "Read the calling key's plan, remaining credits, rate limit and up to 30 days of daily usage. This request is free. credit_pack is null while self-service purchases are unavailable."
      x-credits: 0
      responses:
        "200":
          description: "Successful response. The example contains illustrative fixture data."
          headers:
            X-Credits-Used:
              $ref: "#/components/headers/CreditsUsed"
            X-RateLimit-Limit:
              $ref: "#/components/headers/RateLimitLimit"
            X-RateLimit-Remaining:
              $ref: "#/components/headers/RateLimitRemaining"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    $ref: "#/components/schemas/Account"
                required: ["data"]
              example:
                data:
                  id: "key_example_001"
                  plan: "prepaid"
                  credits: 4985
                  requests_per_minute: 120
                  credit_pack: null
                  usage:
                    - day: "2026-02-04"
                      credits: "15"
                      requests: "11"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "429":
          $ref: "#/components/responses/RateLimited"
        "500":
          $ref: "#/components/responses/ServerError"

  /keys:
    post:
      tags: ["Account"]
      operationId: "create-key"
      summary: "Issue a prepaid key"
      description: "Issue a new prepaid key with zero credits. The full key appears only in this response. Save it before buying credits. Each client address can issue five keys per UTC day. Returns 503 while self-service purchases are unavailable."
      x-credits: 0
      security: []
      responses:
        "201":
          description: "Key issued. The example contains illustrative fixture data."
          headers:
            Cache-Control:
              description: "Always no-store."
              schema:
                type: "string"
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    $ref: "#/components/schemas/IssuedKey"
                required: ["data"]
              example:
                data:
                  id: "key_example_002"
                  key: "psd_live_EXAMPLEexampleEXAMPLEexampleEXAMPLEexam"
                  plan: "prepaid"
                  credits: 0
                  requests_per_minute: 120
        "429":
          $ref: "#/components/responses/RateLimited"
        "503":
          $ref: "#/components/responses/Unavailable"

  /billing/checkout:
    post:
      tags: ["Billing"]
      operationId: "create-checkout"
      summary: "Create a credit-pack checkout"
      description: "Create or resume a Stripe Checkout session for one credit pack. Repeating a request with the same Idempotency-Key returns the same order. A paid order credits the calling key once."
      x-credits: 0
      parameters:
        - name: "Idempotency-Key"
          in: "header"
          required: true
          description: "8 to 100 letters, digits, underscores or hyphens. Reuse it to retry the same order."
          schema:
            type: "string"
            pattern: "^[a-zA-Z0-9_-]{8,100}$"
          example: "order-2026-02-04-a1"
      responses:
        "200":
          description: "Checkout session created or resumed. The example contains illustrative fixture data."
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    $ref: "#/components/schemas/Checkout"
                required: ["data"]
              example:
                data:
                  order_id: "ord_example_001"
                  url: "https://checkout.stripe.com/c/pay/cs_test_example"
                  status: "open"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "409":
          $ref: "#/components/responses/Conflict"
        "429":
          $ref: "#/components/responses/RateLimited"
        "503":
          $ref: "#/components/responses/Unavailable"

  /sources:
    servers:
      - url: "https://api.precisedata.io"
        description: "Served at the host root, outside /v1"
    get:
      tags: ["Catalog"]
      operationId: "sources"
      summary: "List source acknowledgements"
      description: "List each data source with its licence or permission status, notice and links. This route needs no key and costs no credits."
      x-credits: 0
      security: []
      responses:
        "200":
          description: "Successful response."
          content:
            "application/json":
              schema:
                type: "object"
                properties:
                  data:
                    type: "array"
                    items:
                      $ref: "#/components/schemas/SourcePolicy"
                required: ["data"]
              example:
                data:
                  - source: "openfootball"
                    status: "public_domain_dedication"
                    url: "https://github.com/openfootball/football.json"
                    notice: "OpenFootball publishes its football data in the public domain."
                  - source: "espn"
                    url: "https://www.espn.com/"
                    status: "commercial_review_pending"

components:
  securitySchemes:
    ApiKeyHeader:
      type: "apiKey"
      in: "header"
      name: "X-API-Key"
      description: "Send the key in the X-API-Key header."
    BearerAuth:
      type: "http"
      scheme: "bearer"
      description: "Alternatively, send the key in the Authorization header using the Bearer scheme."

  headers:
    ETag:
      description: "Response hash. Send it in If-None-Match to receive 304 at no credit cost when the response has not changed."
      schema:
        type: "string"
    CanonicalId:
      description: "Present when the requested ID was merged into another record. The response describes this surviving ID."
      schema:
        type: "string"
    CreditsUsed:
      description: "Credits charged for this request."
      schema:
        type: "integer"
        minimum: 0
    CreditsRemaining:
      description: "Credits left on the key after this request."
      schema:
        type: "integer"
        minimum: 0
    RateLimitLimit:
      description: "Requests allowed per minute for this key."
      schema:
        type: "integer"
        minimum: 1
    RateLimitRemaining:
      description: "Requests left in the current minute."
      schema:
        type: "integer"
        minimum: 0
    RetryAfter:
      description: "Seconds to wait before retrying."
      schema:
        type: "integer"
        minimum: 1

  schemas:
    PageMeta:
      type: "object"
      properties:
        limit:
          type: "integer"
        offset:
          type: "integer"
        has_more:
          type: "boolean"
        next_offset:
          type: ["integer", "null"]
          description: "Offset of the next page. Null marks the end of the collection."
        attribution:
          type: "string"
          description: "Present when a row on the page derives from Retrosheet."
      required: ["limit", "offset", "has_more", "next_offset"]

    PlayPageMeta:
      allOf:
        - $ref: "#/components/schemas/PageMeta"
        - type: "object"
          properties:
            attributions:
              type: "array"
              items:
                $ref: "#/components/schemas/Attribution"
          required: ["attributions"]

    Attribution:
      type: "object"
      description: "Credit and licence for data derived from an attributed source."
      properties:
        source:
          type: "string"
        url:
          type: "string"
        credit:
          type: "string"
        license_url:
          type: ["string", "null"]
      required: ["source", "url", "credit"]

    Sport:
      type: "object"
      properties:
        id:
          type: "string"
          pattern: "^spt_"
        slug:
          type: "string"
        name:
          type: "string"
        family:
          type: "string"
        updated_at:
          type: "string"
          format: "date-time"
      required: ["id", "slug", "name", "family", "updated_at"]

    Competition:
      type: "object"
      properties:
        id:
          type: "string"
          pattern: "^cmp_"
        slug:
          type: "string"
        name:
          type: "string"
        sport_id:
          type: "string"
          pattern: "^spt_"
        type:
          type: "string"
          description: "league, tournament, series or tour."
        updated_at:
          type: "string"
          format: "date-time"
        event_count:
          type: "integer"
          minimum: 0
        coverage:
          $ref: "#/components/schemas/CompetitionCapabilities"
        history_attribution:
          type: "string"
          description: "Present for competitions with Retrosheet history."
      required: ["id", "slug", "name", "sport_id", "type", "updated_at", "event_count", "coverage"]

    CompetitionCapabilities:
      type: "object"
      properties:
        scores:
          type: "boolean"
        boxscore:
          type: "boolean"
        plays:
          type: "boolean"
        standings:
          type: "boolean"
        rankings:
          type: "boolean"
        history:
          type: "boolean"
        sources:
          type: "array"
          items:
            type: "string"
          description: "Configured sources in collection order."
        source_roles:
          type: "array"
          items:
            type: "object"
            properties:
              source:
                type: "string"
              role:
                type: "string"
                enum: ["primary", "backup"]
              cadence:
                type: "string"
                enum: ["event_dependent", "results", "published_edition_results", "community_match_updates"]
            required: ["source", "role", "cadence"]
        notes:
          type: ["string", "null"]
        history_sources:
          type: "array"
          items:
            type: "string"
        coverage_level:
          type: "string"
          enum: ["planned", "scores", "event_dependent"]
        data_status:
          type: "string"
          enum: ["collected", "awaiting_data"]
        source_health:
          type: "array"
          items:
            type: "object"
            properties:
              competition_id:
                type: "string"
              source:
                type: "string"
              kind:
                type: "string"
              last_success:
                type: ["string", "null"]
                format: "date-time"
              last_failure:
                type: ["string", "null"]
                format: "date-time"
              state:
                type: "string"
                enum: ["ok", "degraded"]
            required: ["competition_id", "source", "kind", "last_success", "last_failure", "state"]

    ObservedCoverage:
      type: "object"
      properties:
        competition_id:
          type: "string"
        events:
          type: "integer"
        finals:
          type: "integer"
        events_with_two_sources:
          type: "integer"
        finals_with_stats:
          type: "integer"
        finals_with_plays:
          type: "integer"
        first_event:
          type: ["string", "null"]
          format: "date"
        last_event:
          type: ["string", "null"]
          format: "date"
        sources:
          type: "array"
          items:
            type: "object"
            properties:
              source:
                type: "string"
              events:
                type: "integer"
              finals:
                type: "integer"
              first_event:
                type: "string"
                format: "date"
              last_event:
                type: "string"
                format: "date"
              last_observed_at:
                type: "string"
                format: "date-time"
        detail_sources:
          type: "array"
          items:
            type: "object"
            properties:
              source:
                type: "string"
              part:
                type: "string"
                enum: ["people", "teams", "plays"]
              events:
                type: "integer"
        result_checks:
          type: "array"
          items:
            type: "object"
            properties:
              source:
                type: "string"
              compared:
                type: "integer"
              agreed:
                type: "integer"
              disagreements:
                type: "integer"
              possible_disagreements_on_ambiguous_fixtures:
                type: "integer"
      required: ["competition_id", "events", "finals", "events_with_two_sources", "finals_with_stats", "finals_with_plays", "first_event", "last_event", "sources", "detail_sources", "result_checks"]

    HistoryWindow:
      type: "object"
      properties:
        source:
          type: "string"
        first_day:
          type: "string"
          format: "date"
        last_day:
          type: "string"
          format: "date"
        state:
          type: "string"
          enum: ["collected", "empty", "outside_coverage"]
        event_count:
          type: "integer"
        kind:
          type: "string"
          enum: ["window", "edition"]
        edition:
          type: ["string", "null"]
        source_url:
          type: ["string", "null"]
        updated_at:
          type: "string"
          format: "date-time"
      required: ["source", "first_day", "last_day", "state", "event_count", "kind", "edition", "source_url", "updated_at"]

    Participant:
      type: "object"
      properties:
        id:
          type: "string"
        type:
          type: "string"
          enum: ["person", "organization"]
        name:
          type: "string"
        side:
          type: ["string", "null"]
          description: "home or away for two-sided contests."
        score:
          type: ["string", "null"]
          description: "Score as published. Strings keep values such as -11 or E."
        result:
          type: ["string", "null"]
        finish_position:
          type: ["integer", "null"]
        seed:
          type: ["integer", "null"]
      required: ["id", "type", "name", "side", "score", "result", "finish_position", "seed"]

    EventStatus:
      type: "string"
      enum: ["scheduled", "in_progress", "final", "postponed", "cancelled", "suspended", "unknown"]

    Event:
      type: "object"
      properties:
        id:
          type: "string"
          pattern: "^evt_"
        name:
          type: "string"
        sport_id:
          type: "string"
        competition_id:
          type: "string"
          description: "Owning competition."
        competition_ids:
          type: "array"
          items:
            type: "string"
          description: "Every competition the event belongs to, such as a tour and a major."
        season_id:
          type: "string"
        season:
          type: "string"
        stage_id:
          type: "string"
        stage:
          type: "string"
        start_time:
          type: ["string", "null"]
          format: "date-time"
        event_date:
          type: "string"
          format: "date"
        end_time:
          type: ["string", "null"]
          format: "date-time"
        end_date:
          type: ["string", "null"]
          format: "date"
        status:
          $ref: "#/components/schemas/EventStatus"
        clock:
          type: ["string", "null"]
        period:
          type: ["integer", "null"]
        source:
          type: "string"
          description: "Source of the accepted event record."
        last_status_observed_at:
          type: ["string", "null"]
          format: "date-time"
        score_disputed:
          type: "boolean"
          description: "A current score comparison or reporting feed has an unresolved disagreement."
        coverage:
          type: "object"
          properties:
            person_stats:
              type: "boolean"
            team_stats:
              type: "boolean"
            plays:
              type: "boolean"
        attributions:
          type: "array"
          items:
            $ref: "#/components/schemas/Attribution"
        updated_at:
          type: "string"
          format: "date-time"
        participants:
          type: "array"
          items:
            $ref: "#/components/schemas/Participant"
      required: ["id", "name", "sport_id", "competition_id", "competition_ids", "season_id", "season", "stage_id", "stage", "start_time", "event_date", "status", "source", "score_disputed", "coverage", "attributions", "updated_at", "participants"]

    EventDetail:
      allOf:
        - $ref: "#/components/schemas/Event"
        - type: "object"
          properties:
            venue_id:
              type: ["string", "null"]
            venue:
              anyOf:
                - $ref: "#/components/schemas/Entity"
                - type: "null"
            periods:
              type: "array"
              items:
                type: "object"
                properties:
                  participant_id:
                    type: "string"
                  period:
                    type: "integer"
                  score:
                    type: "string"
                required: ["participant_id", "period", "score"]
            attribution:
              type: "string"
              description: "Present when the event derives from Retrosheet."
          required: ["venue_id", "venue", "periods"]

    StatBlock:
      type: "object"
      description: "Statistics for one sport. Metrics are grouped by category, such as game for basketball or batting and pitching for baseball. Missing values are omitted or null."
      properties:
        sport:
          type: "string"
      required: ["sport"]
      additionalProperties:
        type: "object"
        additionalProperties:
          type: ["number", "string", "boolean", "null"]

    StatResult:
      type: "object"
      properties:
        id:
          type: "string"
        name:
          type: "string"
        organization_id:
          type: ["string", "null"]
        stats:
          $ref: "#/components/schemas/StatBlock"
        source:
          type: "string"
        updated_at:
          type: "string"
          format: "date-time"
      required: ["id", "name", "stats", "source", "updated_at"]

    BoxScore:
      type: "object"
      properties:
        event_id:
          type: "string"
        attributions:
          type: "array"
          items:
            $ref: "#/components/schemas/Attribution"
        organizations:
          type: "array"
          items:
            $ref: "#/components/schemas/StatResult"
        persons:
          type: "array"
          items:
            $ref: "#/components/schemas/StatResult"
      required: ["event_id", "attributions", "organizations", "persons"]

    Play:
      type: "object"
      properties:
        id:
          type: "string"
        sequence:
          type: "integer"
        period:
          type: ["integer", "null"]
        clock:
          type: ["string", "null"]
        type:
          type: ["string", "null"]
        description:
          type: ["string", "null"]
        stats:
          type: "object"
          additionalProperties: true
          description: "Sport-specific values such as running scores, lap times or hole strokes."
        updated_at:
          type: "string"
          format: "date-time"
      required: ["id", "sequence", "period", "clock", "type", "description", "stats", "updated_at"]

    Entity:
      type: "object"
      properties:
        id:
          type: "string"
        type:
          type: "string"
          enum: ["person", "organization", "venue"]
        name:
          type: "string"
        birth_date:
          type: ["string", "null"]
          format: "date"
        abbreviation:
          type: ["string", "null"]
        timezone:
          type: ["string", "null"]
        aliases:
          type: "array"
          items:
            type: "string"
        related_teams:
          type: "array"
          description: "Organizations only."
          items:
            type: "object"
            properties:
              competition_id:
                type: "string"
              original_id:
                type: "string"
              organization_id:
                type: "string"
            required: ["competition_id", "original_id", "organization_id"]
        updated_at:
          type: "string"
          format: "date-time"
      required: ["id", "type", "name", "birth_date", "abbreviation", "timezone", "aliases", "updated_at"]

    GameLogEntry:
      type: "object"
      properties:
        event_id:
          type: "string"
        name:
          type: "string"
        start_time:
          type: ["string", "null"]
          format: "date-time"
        event_date:
          type: "string"
          format: "date"
        competition_id:
          type: "string"
        season_id:
          type: "string"
        season:
          type: "string"
        organization_id:
          type: ["string", "null"]
        side:
          type: ["string", "null"]
        result:
          type: ["string", "null"]
        finish_position:
          type: ["integer", "null"]
        stats:
          $ref: "#/components/schemas/StatBlock"
        source:
          type: "string"
        updated_at:
          type: "string"
          format: "date-time"
        attributions:
          type: "array"
          items:
            $ref: "#/components/schemas/Attribution"
      required: ["event_id", "name", "event_date", "competition_id", "season_id", "season", "stats", "source", "updated_at", "attributions"]

    Splits:
      type: "object"
      properties:
        person_id:
          type: "string"
        by:
          type: "string"
          enum: ["side", "result", "season"]
        groups:
          type: "array"
          items:
            type: "object"
            properties:
              value:
                type: "string"
                description: "Group value, or unspecified when the dimension is missing."
              games:
                type: "integer"
              stats:
                type: "object"
                description: "Category, then metric, then its mean and sample count."
                additionalProperties:
                  type: "object"
                  additionalProperties:
                    type: "object"
                    properties:
                      mean:
                        type: "number"
                      samples:
                        type: "integer"
            required: ["value", "games", "stats"]
      required: ["person_id", "by", "groups"]

    RosterEntry:
      type: "object"
      properties:
        id:
          type: "string"
        name:
          type: "string"
        season_id:
          type: "string"
        season:
          type: "string"
        position:
          type: ["string", "null"]
        jersey:
          type: ["string", "null"]
        valid_from:
          type: "string"
          format: "date"
        valid_to:
          type: ["string", "null"]
          format: "date"
        updated_at:
          type: "string"
          format: "date-time"
      required: ["id", "name", "season_id", "season", "position", "jersey", "valid_from", "valid_to", "updated_at"]

    Snapshot:
      type: "object"
      properties:
        id:
          type: "string"
        competition_id:
          type: "string"
        season_id:
          type: "string"
        season:
          type: "string"
        type:
          type: "string"
          description: "Group or ranking name."
        as_of:
          type: "string"
          format: "date"
        entries:
          type: "array"
          items:
            type: "object"
            properties:
              id:
                type: "string"
              name:
                type: "string"
              rank:
                type: ["integer", "null"]
              stats:
                type: "object"
                additionalProperties: true
                description: "Values as published by the source."
            required: ["id", "name", "rank", "stats"]
        source:
          type: "string"
        updated_at:
          type: "string"
          format: "date-time"
      required: ["id", "competition_id", "season_id", "season", "type", "as_of", "entries", "source", "updated_at"]

    SearchHit:
      type: "object"
      properties:
        id:
          type: "string"
        type:
          type: "string"
          enum: ["person", "organization", "competition"]
        name:
          type: "string"
        updated_at:
          type: "string"
          format: "date-time"
      required: ["id", "type", "name", "updated_at"]

    IdMapping:
      type: "object"
      properties:
        id:
          type: "string"
          description: "PreciseData ID."
        type:
          type: "string"
        source:
          type: "string"
        scope:
          type: "string"
        source_id:
          type: "string"
        updated_at:
          type: "string"
          format: "date-time"
      required: ["id", "type", "source", "scope", "source_id", "updated_at"]

    Account:
      type: "object"
      properties:
        id:
          type: "string"
          pattern: "^key_"
        plan:
          type: "string"
        credits:
          type: "integer"
          minimum: 0
        requests_per_minute:
          type: "integer"
          minimum: 1
        credit_pack:
          anyOf:
            - type: "object"
              properties:
                amount_cents:
                  type: "integer"
                currency:
                  type: "string"
                credits:
                  type: "integer"
              required: ["amount_cents", "currency", "credits"]
            - type: "null"
        usage:
          type: "array"
          description: "Daily totals, newest first. Counts are decimal strings."
          items:
            type: "object"
            properties:
              day:
                type: "string"
                format: "date"
              credits:
                type: "string"
              requests:
                type: "string"
            required: ["day", "credits", "requests"]
      required: ["id", "plan", "credits", "requests_per_minute", "credit_pack", "usage"]

    IssuedKey:
      type: "object"
      properties:
        id:
          type: "string"
          pattern: "^key_"
        key:
          type: "string"
          description: "The full key. It is shown only once."
        plan:
          type: "string"
        credits:
          type: "integer"
        requests_per_minute:
          type: "integer"
      required: ["id", "key", "plan", "credits", "requests_per_minute"]

    Checkout:
      type: "object"
      properties:
        order_id:
          type: "string"
          pattern: "^ord_"
        url:
          type: ["string", "null"]
          description: "Stripe Checkout page for the order."
        status:
          type: ["string", "null"]
      required: ["order_id", "url", "status"]

    SourcePolicy:
      type: "object"
      properties:
        source:
          type: "string"
        status:
          type: "string"
        url:
          type: "string"
        license_url:
          type: "string"
        notice:
          type: "string"
      required: ["source", "status", "url"]

    Error:
      type: "object"
      properties:
        error:
          type: "string"
          description: "Description of the failure."
        status:
          type: "integer"
          description: "HTTP status code."
        matches:
          type: "array"
          description: "Candidate matches for an ambiguous ID lookup."
          items:
            $ref: "#/components/schemas/IdMapping"
      required: ["error", "status"]

  responses:
    NotModified:
      description: "The response matches the ETag sent in If-None-Match. No body is returned and no credits are charged."
      headers:
        X-Credits-Used:
          $ref: "#/components/headers/CreditsUsed"

    InvalidRequest:
      description: "One or more parameters are invalid."
      content:
        "application/json":
          schema:
            $ref: "#/components/schemas/Error"
          example:
            error: "Invalid calendar date"
            status: 400

    Unauthorized:
      description: "The API key is missing, unknown or disabled."
      content:
        "application/json":
          schema:
            $ref: "#/components/schemas/Error"
          example:
            error: "An API key is required"
            status: 401

    InsufficientCredits:
      description: "The key has fewer credits than the request costs."
      content:
        "application/json":
          schema:
            $ref: "#/components/schemas/Error"
          example:
            error: "Insufficient credits"
            status: 402

    NotFound:
      description: "No record matches the identifier or competition."
      content:
        "application/json":
          schema:
            $ref: "#/components/schemas/Error"
          example:
            error: "Event not found"
            status: 404

    Conflict:
      description: "The request matches more than one record, or the order can no longer be created. An ambiguous ID lookup lists its candidates."
      content:
        "application/json":
          schema:
            $ref: "#/components/schemas/Error"
          example:
            error: "Source ID is ambiguous. Supply scope and type."
            status: 409
            matches:
              - id: "org_bos"
                type: "organization"
                source: "espn"
                scope: "basketball/nba"
                source_id: "2"
                updated_at: "2026-01-10T00:00:00Z"
              - id: "org_example_401"
                type: "organization"
                source: "espn"
                scope: "soccer"
                source_id: "2"
                updated_at: "2026-01-10T00:00:00Z"

    RateLimited:
      description: "The key has reached its per-minute request limit."
      headers:
        Retry-After:
          $ref: "#/components/headers/RetryAfter"
      content:
        "application/json":
          schema:
            $ref: "#/components/schemas/Error"
          example:
            error: "Rate limit reached"
            status: 429

    Unavailable:
      description: "Self-service purchases are not available."
      content:
        "application/json":
          schema:
            $ref: "#/components/schemas/Error"
          example:
            error: "Self-service purchases are unavailable"
            status: 503

    ServerError:
      description: "The service could not complete the request."
      content:
        "application/json":
          schema:
            $ref: "#/components/schemas/Error"
          example:
            error: "Internal server error"
            status: 500
