> ## 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.

# 獲取訂單簿（v1，已棄用）

> 為向後相容保留的舊版巢狀訂單簿端點

<Warning>
  **已棄用。** 更簡單、推薦的扁平格式請使用 [`GET /exchange/v2/getOrderbook`](/zh-Hant/pages/rest/markets/get-orderbook)。

  此端點僅為與舊用戶端向後相容而保留。
</Warning>

以**巢狀**形式回傳整個聯賽的訂單簿，按讓分 / 大小分數鍵控。單場形態與 [獲取單場訂單簿](/zh-Hant/pages/rest/markets/get-single-orderbook) 相同，但覆蓋該聯賽的每一場賽事。

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

`POST /exchange/getOrderbook`

<ParamField body="leagueRequested" type="string" required>
  聯賽代碼（不區分大小寫）。
</ParamField>

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://api.4casters.io/exchange/getOrderbook \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"leagueRequested": "NBA"}'
  ```
</CodeGroup>

<h2 id="response">
  回應
</h2>

<ResponseField name="data.market" type="string">此端點始終為 `null`。</ResponseField>

<ResponseField name="data.games" type="array">
  帶巢狀訂單簿欄位的賽事陣列。單場形態見 [獲取單場訂單簿](/zh-Hant/pages/rest/markets/get-single-orderbook#response) — `awayMoneylines` / `homeMoneylines` 陣列，以及按讓分或大小分數鍵控的 `awaySpreads` / `homeSpreads` / `over` / `under` 物件。
</ResponseField>

這些桶中的每筆單獨訂單具有標準訂單形態：

<Snippet file="zh-Hant/types/orderbook-order.mdx" />


## OpenAPI

````yaml POST /exchange/getOrderbook
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/getOrderbook:
    post:
      tags:
        - Markets
      summary: Get orderbook (v1, deprecated)
      description: >-
        **Deprecated.** Use `GET /exchange/v2/getOrderbook` instead.


        Returns the orderbook for an entire league in **nested** form, keyed by
        spread / total number. Kept for backwards compatibility with older
        clients.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - leagueRequested
              properties:
                leagueRequested:
                  type: string
                  description: League code (case-insensitive).
            example:
              leagueRequested: NBA
      responses:
        '200':
          description: Nested-orderbook response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      market:
                        type:
                          - string
                          - 'null'
                      games:
                        type: array
                        items:
                          $ref: '#/components/schemas/GameOrderbookNested'
        '401':
          $ref: '#/components/responses/Unauthorized'
      deprecated: true
components:
  schemas:
    GameOrderbookNested:
      allOf:
        - $ref: '#/components/schemas/Game'
        - type: object
          description: >-
            v1 orderbook: spreads and totals are objects keyed by spread / total
            number; values are arrays of orders.
          properties:
            homeMoneylines:
              type: array
              items:
                $ref: '#/components/schemas/OrderbookOrder'
            awayMoneylines:
              type: array
              items:
                $ref: '#/components/schemas/OrderbookOrder'
            homeSpreads:
              type: object
              additionalProperties:
                type: array
                items:
                  $ref: '#/components/schemas/OrderbookOrder'
              description: Keyed by spread number, e.g. `"-3.5"`.
            awaySpreads:
              type: object
              additionalProperties:
                type: array
                items:
                  $ref: '#/components/schemas/OrderbookOrder'
            over:
              type: object
              additionalProperties:
                type: array
                items:
                  $ref: '#/components/schemas/OrderbookOrder'
              description: Keyed by total number, e.g. `"220.5"`.
            under:
              type: object
              additionalProperties:
                type: array
                items:
                  $ref: '#/components/schemas/OrderbookOrder'
            homeMoneylines1x2:
              type: object
            awayMoneylines1x2:
              type: object
            draw1x2:
              type: object
            mainHomeSpread:
              type:
                - string
                - number
              nullable: true
            mainAwaySpread:
              type:
                - string
                - number
              nullable: true
            mainTotal:
              type:
                - string
                - number
              nullable: true
            openInterest:
              type: number
            matchedVolume:
              type: number
    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'
    OrderbookOrder:
      type: object
      description: A single resting order on the book.
      properties:
        id:
          type: string
        type:
          $ref: '#/components/schemas/MarketType'
        createdBy:
          type: string
          description: Present **only** when the order belongs to the caller.
        sumUntaken:
          type: number
          description: Win amount still available (taker pays risk to claim it).
        odds:
          type: integer
          description: American odds.
        bet:
          type: number
          description: Original `bet` amount.
        gameID:
          type: string
        takenRatio:
          type: number
          nullable: true
          description: Fraction of the order that has been matched.
        expiry:
          type: string
          format: date-time
          nullable: true
        createdAt:
          type: string
          format: date-time
        mockOrder:
          type: boolean
        gameStartExpiry:
          type: boolean
          description: True when the order is set to auto-cancel at game start.
        isPostArb:
          type: boolean
          description: 'Present when the order was placed with `orderType: postArb`.'
        participantID:
          type: string
          description: Present for `moneyline` and `spread`.
        spread:
          type: number
          description: Present for `spread`.
        total:
          type: number
          description: Present for `total`.
        OU:
          type: string
          enum:
            - over
            - under
          description: Present for `total`.
        market:
          type: string
          description: Present for `moneyline1x2`.
        side:
          type: string
          enum:
            - 'yes'
            - 'no'
          description: Present for `moneyline1x2`.
    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.
    MarketType:
      type: string
      enum:
        - moneyline
        - spread
        - total
        - moneyline1x2
      description: >-
        Market type. `moneyline1x2` is **soccer-only** (three-way money line:
        home / away / draw).
  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.