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

# 获取赛事

> 列出某联赛的活跃赛事

返回某联赛的全部活跃赛事。响应**不**包含订单簿或任何价格 — 请调用 [获取订单簿](/zh-Hans/pages/rest/markets/get-orderbook) 获取。

<h2 id="request">
  请求
</h2>

`GET /exchange/v2/getGames`

<ParamField query="league" type="string" required>
  来自 [获取联赛](/zh-Hans/pages/rest/markets/get-leagues) 的联赛代码。使用特殊值 `upcoming` 可获取跨联赛的全部即将开赛赛事。
</ParamField>

<ParamField query="sport" type="string">
  可选的运动项目过滤。
</ParamField>

<CodeGroup>
  ```bash curl theme={null}
  curl "https://api.4casters.io/exchange/v2/getGames?league=NBA" \
    -H "Authorization: Bearer YOUR_TOKEN"
  ```
</CodeGroup>

<h2 id="response">
  响应
</h2>

<ResponseField name="data.games" type="array">
  <Expandable title="Game">
    <ResponseField name="id" type="string">赛事 ID。</ResponseField>
    <ResponseField name="parentGameID" type="string">父赛事 ID（若这是子市场：附加盘、分段盘）。</ResponseField>
    <ResponseField name="cheapDataUID" type="string">赛事的稳定跨系统标识（用于盘口关联）。</ResponseField>

    <ResponseField name="league" type="string" />

    <ResponseField name="sport" type="string" />

    <ResponseField name="start" type="string">ISO 8601 开赛时间。</ResponseField>

    <ResponseField name="ended" type="boolean" />

    <ResponseField name="live" type="boolean" />

    <ResponseField name="featured" type="boolean" />

    <ResponseField name="eventName" type="string" />

    <ResponseField name="tournamentName" type="string" />

    <ResponseField name="periodName" type="string">例如 `Full Time`、`1H`、`Set 1`。</ResponseField>
    <ResponseField name="isSpecials" type="boolean">期货盘及其他特殊盘为 `true`。</ResponseField>
    <ResponseField name="participants" type="array">二元 `[away, home]` 数组。每个参赛方有 `id`、`longName`、`shortName`、`homeAway`、`mainPitcher`、`rotationNumber`、`futuresSide`。</ResponseField>
  </Expandable>
</ResponseField>

<h3 id="example">
  示例
</h3>

<CodeGroup>
  ```json JSON theme={null}
  {
    "data": {
      "games": [
        {
          "id": "6266c12172aefcf0033374ce",
          "parentGameID": null,
          "cheapDataUID": "32620-79238-2022-04-26",
          "league": "NHL",
          "sport": "hockey",
          "start": "2022-04-26T18:00:00.000Z",
          "ended": false,
          "live": false,
          "featured": false,
          "participants": [
            { "id": "60747bc471b5071a80ca0ac8", "longName": "Carolina Hurricanes", "shortName": "CAR", "homeAway": "away", "mainPitcher": null, "rotationNumber": "25", "futuresSide": "" },
            { "id": "607349daf6d3364eb69604f6", "longName": "New York Rangers",    "shortName": "NEW", "homeAway": "home", "mainPitcher": null, "rotationNumber": "26", "futuresSide": "" }
          ]
        }
      ]
    }
  }
  ```
</CodeGroup>

<h2 id="errors">
  错误
</h2>

| 状态 | 含义 |
| - | - |
| `400` | `league` 为必填。 |


## OpenAPI

````yaml GET /exchange/v2/getGames
openapi: 3.1.0
info:
  title: 4casters REST API
  version: 1.0.0
  description: >-
    Public REST API for the 4casters peer-to-peer betting exchange. Use this API
    to manage your account, query the orderbook and games, and place / edit /
    cancel orders.


    All responses (unless noted otherwise) are JSON envelopes of the form `{
    "data": ... }`.
  contact:
    name: 4casters
    url: https://4casters.io
servers:
  - url: https://api.4casters.io
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Authentication
    description: Login and account session management
  - name: User
    description: Read account info, bets, and orders
  - name: Orders
    description: Place, edit, look up, and cancel orders
  - name: Markets
    description: Browse leagues, games, participants, and orderbooks
  - name: Affiliate
    description: Affiliate / referral commission
paths:
  /exchange/v2/getGames:
    get:
      tags:
        - Markets
      summary: Get games
      description: >-
        Return all active games for a league. This response does **not** include
        the orderbook or any prices — call `GET /exchange/v2/getOrderbook` for
        that.
      parameters:
        - name: league
          in: query
          required: true
          schema:
            type: string
          description: >-
            League code from `GET /exchange/getLeagues`. Use `upcoming` for all
            upcoming games across leagues.
        - name: sport
          in: query
          required: false
          schema:
            type: string
          description: Optional sport filter.
      responses:
        '200':
          description: Games list
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      games:
                        type: array
                        items:
                          $ref: '#/components/schemas/Game'
        '400':
          description: '`league` is required'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  schemas:
    Game:
      type: object
      description: Game without orderbook data.
      properties:
        id:
          type: string
        parentGameID:
          type: string
          nullable: true
        cheapDataUID:
          type: string
          description: >-
            Stable cross-system identifier for the game (used for line
            correlation).
        league:
          type: string
        sport:
          type: string
        start:
          type: string
          format: date-time
        ended:
          type: boolean
        live:
          type: boolean
        featured:
          type: boolean
        eventName:
          type: string
          nullable: true
        tournamentName:
          type: string
          nullable: true
        periodName:
          type: string
          description: e.g. `Full Time`, `1H`, `Set 1`.
        isSpecials:
          type: boolean
          description: True for futures and other specials markets.
        participants:
          type: array
          items:
            $ref: '#/components/schemas/Participant'
    Participant:
      type: object
      properties:
        id:
          type: string
        longName:
          type: string
        shortName:
          type: string
        homeAway:
          type: string
          enum:
            - home
            - away
        mainPitcher:
          type: string
          nullable: true
        rotationNumber:
          type: string
          nullable: true
        futuresSide:
          type: string
          nullable: true
        score:
          type: number
          description: Final score; only present for ended games.
  responses:
    Unauthorized:
      description: Missing or invalid auth token
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Pass your auth token in the `Authorization` header. The `Bearer` prefix
        is optional; the server also accepts a signed `auth` cookie or a `token`
        field in the request body.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.