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

# Obter um livro de ordens

> Lê o livro de ordens aninhado de um evento, mais os mercados filhos

Retorna o livro de ordens **aninhado** de um único evento: spreads e totals são objetos indexados pelo número de spread / total em vez de arrays planos. Também retorna quaisquer eventos filhos (props, períodos alternativos) e um `orderSummary` das próprias ordens em aberto da conta autenticada na liga.

Para a forma plana mais simples, prefira [Obter livro de ordens](https://docs.4casters.io/pt-BR/pages/rest/markets/get-orderbook.md).

## Requisição

`GET /exchange/getSingleOrderbook`

**gameID** `string` *required*

Id do evento.

```bash curl theme={null}
curl "https://api.4casters.io/exchange/getSingleOrderbook?gameID=65b67450503180295ade9216" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

## Resposta

**data.game** `object`

Objeto de evento com campos de livro de ordens aninhado. Aplicam-se os campos padrão de `Game` (consulte [Obter eventos](https://docs.4casters.io/pt-BR/pages/rest/markets/get-games.md#response)), mais:

**Campos do livro de ordens por evento**

**awayMoneylines** `array`

Ordens moneyline em aberto do lado visitante. Ordenadas com o melhor preço primeiro.

**homeMoneylines** `array`

Ordens moneyline em aberto do lado mandante.

**awaySpreads** `object`

Objeto indexado por número de spread (p. ex. `"-3.5"`). Cada valor é um array de ordens.

**homeSpreads** `object`

Objeto indexado por número de spread.

**over** `object`

Objeto indexado por número de total (p. ex. `"220.5"`). Cada valor é um array de ordens.

**under** `object`

**homeMoneylines1x2** `object`

**Somente futebol.** Objeto com arrays `homeYes` / `homeNo`.

**awayMoneylines1x2** `object`

**Somente futebol.** Objeto com arrays `awayYes` / `awayNo`.

**draw1x2** `object`

**Somente futebol.** Objeto com arrays `drawYes` / `drawNo`.

**mainHomeSpread** `string`

O spread mandante principal exibido no momento (a linha de consenso).

**mainAwaySpread** `number`

**mainTotal** `string`

**openInterest** `number`

**matchedVolume** `number`

**data.orderSummary** `array`

As próprias ordens em aberto da conta autenticada em toda a liga (não só este evento). Útil para renderizar selos de "suas ofertas" em uma UI.

**data.childGames** `array`

Eventos filhos (períodos alternativos, etc.) do evento solicitado. Mesma forma que `data.game`.

**data.propGames** `array`

Eventos de props ligados ao evento solicitado.

Cada ordem individual tem a forma padrão de ordem:

<Snippet file="pt-BR/types/orderbook-order.mdx" />

## Erros

| Status | Significado |
| - | - |
| `400` | Falta `gameID`. |


## OpenAPI

````yaml GET /exchange/getSingleOrderbook
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/getSingleOrderbook:
    get:
      tags:
        - Markets
      summary: Get single orderbook
      description: >-
        Return the nested orderbook for a single game, plus any child games
        (props, alternate periods) and an `orderSummary` of the caller's own
        resting orders for the league.
      parameters:
        - name: gameID
          in: query
          required: true
          schema:
            type: string
          description: Game id.
      responses:
        '200':
          description: Single-game orderbook
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      game:
                        $ref: '#/components/schemas/GameOrderbookNested'
                      orderSummary:
                        type: array
                        items:
                          type: object
                      childGames:
                        type: array
                        items:
                          $ref: '#/components/schemas/GameOrderbookNested'
                      propGames:
                        type: array
                        items:
                          $ref: '#/components/schemas/GameOrderbookNested'
        '400':
          description: Missing required parameter `gameID`
        '401':
          $ref: '#/components/responses/Unauthorized'
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.