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

# Get bet by ID

> Look up a single bet by id or transaction id

Look up a single bet (matched, graded, or open offer) belonging to the caller. Pass **either** `id` or `txID`, not both.

## Request

`GET /user/getBetByID`

<ParamField query="id" type="string">
  Bet `id` from a list endpoint such as `/user/getMatchedBets`.
</ParamField>

<ParamField query="txID" type="string">
  Transaction id, e.g. the `wagerRequestID` or `txID` returned by `/session/v3/place`.
</ParamField>

You must pass exactly one of `id` or `txID`.

<CodeGroup>
  ```bash curl (by txID) theme={null}
  curl "https://api.4casters.io/user/getBetByID?txID=64824b329556daa319747e31" \
    -H "Authorization: Bearer YOUR_TOKEN"
  ```

  ```bash curl (by id) theme={null}
  curl "https://api.4casters.io/user/getBetByID?id=6494ca85c9346058f35b2b1e" \
    -H "Authorization: Bearer YOUR_TOKEN"
  ```
</CodeGroup>

## Response

The shape of `bet` depends on the bet's current state:

* A **graded** bet returns the [GradedWager](/pages/rest/user/get-graded-wagers#response) shape, including `risk`, `win`, `fee`, and `result`.
* A **matched** bet returns the [MatchedBet](/pages/rest/user/get-matched-bets#response) shape.
* An **open offer** returns the [UnmatchedOrder](/pages/rest/user/get-unmatched-orders#response) shape.

Note that, unlike most endpoints, this one returns the bet at the **top level** (not under `data`).

### Example

<CodeGroup>
  ```json JSON (open offer) theme={null}
  {
    "bet": {
      "id": "667c1e870c0d22ec36ccb438",
      "txID": "667c1e870c0d22ec36ccb439",
      "type": "moneyline",
      "bet": 222,
      "graded": false,
      "closed": false,
      "createdAt": "2024-06-26T13:58:31.224Z",
      "origin": "offer",
      "wagerRequestID": "667c1e870c...",
      "game": {
        "id": "6679ee8c9f05a804e064b6ed",
        "league": "FED-EX-500",
        "sport": "golf",
        "start": "2024-06-27T10:45:00.000Z",
        "ended": false,
        "participants": [/* ... */]
      }
    }
  }
  ```
</CodeGroup>

## Errors

| Status | Meaning                                                                    |
| ------ | -------------------------------------------------------------------------- |
| `400`  | Both `id` and `txID` missing, or no bet found for the supplied identifier. |


## OpenAPI

````yaml GET /user/getBetByID
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:
  /user/getBetByID:
    get:
      tags:
        - User
      summary: Get bet by ID or txID
      description: >-
        Look up a single bet (matched, graded, or open offer) belonging to the
        caller. Pass **either** `id` (the bet's `id`, e.g. from
        `/user/getMatchedBets`) **or** `txID` (the transaction id, e.g. from a
        `/session/v3/place` response).
      parameters:
        - name: id
          in: query
          required: false
          schema:
            type: string
          description: Bet `id` from a list endpoint.
        - name: txID
          in: query
          required: false
          schema:
            type: string
          description: >-
            Transaction id (e.g. `wagerRequestID` or `txID` returned from
            place). 
      responses:
        '200':
          description: >-
            The bet, in matched, graded, or open form depending on its current
            state.
          content:
            application/json:
              schema:
                type: object
                properties:
                  bet:
                    oneOf:
                      - $ref: '#/components/schemas/MatchedBet'
                      - $ref: '#/components/schemas/GradedWager'
                      - $ref: '#/components/schemas/UnmatchedOrder'
        '400':
          description: Invalid `id` / `txID`
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  schemas:
    MatchedBet:
      type: object
      description: A bet that has been matched but not yet graded.
      properties:
        id:
          type: string
        txID:
          type: string
        type:
          $ref: '#/components/schemas/MarketType'
        bet:
          type: number
        odds:
          type: integer
        spread:
          type: number
          nullable: true
        total:
          type: number
          nullable: true
        OU:
          type: string
          enum:
            - over
            - under
          description: Present for `total`.
        participantID:
          type: string
          description: Present for `moneyline` / `spread`.
        market:
          type: string
          description: Present for `moneyline1x2`.
        side:
          $ref: '#/components/schemas/MarketSide'
        userReference:
          type: string
        createdAt:
          type: string
          format: date-time
        matchedTime:
          type: string
          format: date-time
        graded:
          type: boolean
        closed:
          type: boolean
        origin:
          type: string
          description: '`offer` or `wager`.'
        adminRefund:
          type: boolean
        risk:
          type: string
        win:
          type: string
        fee:
          type: string
        game:
          $ref: '#/components/schemas/GameSummary'
    GradedWager:
      type: object
      description: A settled wager.
      properties:
        id:
          type: string
        txID:
          type: string
        ticketNumber:
          type: string
        type:
          $ref: '#/components/schemas/MarketType'
        outcome:
          type: string
          enum:
            - winner
            - loser
            - push
            - refund
        bet:
          type: number
        odds:
          type: integer
        spread:
          type: number
          nullable: true
        total:
          type: number
          nullable: true
        OU:
          type: string
          enum:
            - over
            - under
        participantID:
          type: string
        market:
          type: string
        side:
          $ref: '#/components/schemas/MarketSide'
        matchedTime:
          type: string
          format: date-time
        settledAt:
          type: string
          format: date-time
        createdAt:
          type: string
          format: date-time
        graded:
          type: boolean
        closed:
          type: boolean
        cancelled:
          type: boolean
        adminRefund:
          type: boolean
        platform:
          type: string
          example: api
        fee:
          type: string
          description: Commission charged on the matched portion.
        risk:
          type: string
        win:
          type: string
        result:
          type: string
          description: Net P&L on this wager (signed).
        pinnacleLine:
          type: object
          description: >-
            Snapshot of the comparable Pinnacle line at fill time, when
            available.
        game:
          $ref: '#/components/schemas/GameSummary'
    UnmatchedOrder:
      type: object
      description: An open order that is currently resting on the exchange.
      properties:
        id:
          type: string
        txID:
          type: string
        type:
          $ref: '#/components/schemas/MarketType'
        bet:
          type: number
        odds:
          type: integer
        spread:
          type: number
          nullable: true
        total:
          type: number
          nullable: true
        participantID:
          type: string
          description: Present for `moneyline` / `spread`.
        otherParticipantID:
          type: string
          description: The opposite participant id (the one whose side is being offered).
        expiry:
          type: string
          format: date-time
          nullable: true
        filled:
          type: number
        offered:
          type: number
        remaining:
          type: number
        takenRatio:
          type: number
        createdAt:
          type: string
          format: date-time
        origin:
          type: string
          description: '`offer` or `wager`.'
        graded:
          type: boolean
        closed:
          type: boolean
        adminRefund:
          type: boolean
        userReference:
          type: string
        wagerRequestID:
          type: string
        game:
          $ref: '#/components/schemas/GameSummary'
    MarketType:
      type: string
      enum:
        - moneyline
        - spread
        - total
        - moneyline1x2
      description: >-
        Market type. `moneyline1x2` is **soccer-only** (three-way money line:
        home / away / draw).
    MarketSide:
      type: string
      description: |-
        Order side. Meaning depends on `type`:

        - `moneyline`, `spread` — the participant id you are backing.
        - `total` — `"over"` or `"under"`.
        - `moneyline1x2` — `"yes"` or `"no"` on the outcome named by `market`.
    GameSummary:
      type: object
      properties:
        id:
          type: string
        league:
          type: string
        sport:
          type: string
        start:
          type: string
          format: date-time
        ended:
          type: boolean
        eventName:
          type: string
          nullable: true
        isFutures:
          type: boolean
        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.

````