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

# Fetching Trades

> Query trade history from the SX Bet API.

Every trade made on SX Bet is publicly available through the SX Bet API. You can
query trades for a specific user, event, market, time period, and more.

| Endpoint                   | Best for                                                                                                   |
| -------------------------- | ---------------------------------------------------------------------------------------------------------- |
| `GET /trades`              | Individual filled orders — split by order, so one taker bet filling five maker orders returns five records |
| `GET /trades/consolidated` | Aggregated history — that same bet appears as one record with weighted average odds                        |
| `GET /trades/orders`       | When you have specific order hashes and want to see all fills against them                                 |

<Note>
  `tradeStatus` reflects the on-chain confirmation state of a trade: `"PENDING"` while awaiting confirmation, then `"SUCCESS"` or `"FAILED"` once confirmation completes.
</Note>

***

## GET /trades

Use this when you need granular fill data — individual order matches, settlement
status, or trade history for a specific market or user. Filter by bettor, market
hash, time range, settlement status, and more. See the
[full parameter reference →](/api-reference/get-trades).

```bash theme={null}
curl "https://api.sx.bet/trades?bettor=0xYourAddress&marketHashes=0x1a46...&settled=false"
```

<Accordion title="Sample response + field notes">
  ```json theme={null}
  {
    "status": "success",
    "data": {
      "trades": [
        {
          "fillHash": "0xabc123...",
          "orderHash": "0xdef456...",
          "marketHash": "0x1a46...",
          "bettor": "0xYourAddress",
          "stake": "1035620",
          "normalizedStake": "1",
          "odds": "50875000000000000000",
          "maker": true,
          "bettingOutcomeOne": true,
          "betTime": 1774491706,
          "betTimeValue": 1.03562,
          "settleValue": 0,
          "settled": false,
          "tradeStatus": "SUCCESS",
          "valid": true,
          "betType": 0,
          "netReturn": "2.035617",
          "fillOrderHash": "0x789abc...",
          "fillOrderHashAttempts": ["0x789abc..."],
          "lastMineAttemptTime": "2026-03-26T02:21:48.098Z",
          "targetNonce": 27614,
          "contractsVersion": "6.0",
          "chainVersion": "SXR",
          "sportXeventId": "L16068923",
          "marketHasRefunds": false,
          "baseToken": "0x6629Ce1Cf35Cc1329ebB4F63202F3f197b3F050B",
          "createdAt": "2026-03-26T02:21:47.041Z",
          "updatedAt": "2026-03-26T02:21:48.224Z",
          "_id": "69c4983a23f5052c3b0a6dc2"
        }
      ],
      "nextKey": "66ae05484c2e5e971bcb7f29",
      "pageSize": 100,
      "count": 142
    }
  }
  ```

  `odds` is the bettor's implied probability as a fixed-point integer — divide by
  10^20 to get a decimal. `50875000000000000000` = 50.875% (1.97 in decimal odds format).

  `stake` and `normalizedStake` reflect the bettor's stake — `stake` is in raw token units, `normalizedStake` is in whole token units. See
  [Unit Conversions](/api-reference/unit-conversion) for token decimal details.
</Accordion>

Results are paginated using a cursor — each response includes a `nextKey` field inside `data`.
Pass it as `paginationKey` in your next request. Default page size is 100, max 300.
When `nextKey` is absent, you've reached the last page.

***

## GET /trades/consolidated

Use this when you want one record per bet regardless of how many maker orders it
filled — for portfolio views, PnL tracking, or reviewing a user's betting history.
Fills that crossed multiple maker orders are rolled up with weighted average odds.
See the [full parameter reference →](/api-reference/get-trades-consolidated).

<Note>
  `page`, `perPage`, `sortBy`, `sortAsc`, and `settled` are all required parameters for this endpoint.
</Note>

```bash theme={null}
curl "https://api.sx.bet/trades/consolidated?bettor=0xYourAddress&settled=false&page=0&perPage=100&sortBy=gameTime&sortAsc=false"
```

<Accordion title="Sample response + field notes">
  ```json theme={null}
  {
    "status": "success",
    "data": {
      "trades": [
        {
          "fillHash": "0xabc123...",
          "marketHash": "0x1a46...",
          "bettor": "0xYourAddress",
          "totalStake": "5000000000",
          "weightedAverageOdds": "54200000000000000000",
          "bettingOutcomeLabel": "Los Angeles Lakers",
          "gameLabel": "Los Angeles Lakers vs Boston Celtics",
          "leagueLabel": "NBA",
          "gameTime": "2025-11-15T02:00:00.000Z",
          "bettingOutcome": 1,
          "maker": false,
          "settled": false,
          "tradeStatus": "SUCCESS",
          "sportXeventId": "L16068923",
          "baseToken": "0x6629Ce1Cf35Cc1329ebB4F63202F3f197b3F050B"
        }
      ],
      "count": 142
    }
  }
  ```

  `count` is the total number of matching trades — use it to calculate total pages:
  `Math.ceil(count / perPage)`. Pagination starts at page `0`.
</Accordion>

***

## GET /trades/orders

Use this when you have specific order hashes and want to see exactly how and when
they were filled. See the [full parameter reference →](/api-reference/get-trades-orders).

```bash theme={null}
curl "https://api.sx.bet/trades/orders?orderHashes=0xdef456...,0x789abc..."
```

<Accordion title="Sample response + field notes">
  ```json theme={null}
  {
    "status": "success",
    "data": {
      "trades": [
        {
          "fillHash": "0xabc123...",
          "orderHash": "0xdef456...",
          "marketHash": "0x1a46...",
          "bettor": "0xYourAddress",
          "stake": "1035620",
          "normalizedStake": "1",
          "odds": "50875000000000000000",
          "maker": true,
          "bettingOutcomeOne": true,
          "betTime": "2026-03-26T02:21:46.964Z",
          "betTimeValue": 1.03562,
          "settleValue": 0,
          "settled": false,
          "tradeStatus": "SUCCESS",
          "valid": true,
          "betType": 0,
          "affiliate": "0x0000000000000000000000000000000000000000",
          "netReturn": "2.035617",
          "fillOrderHash": "0x789abc...",
          "fillOrderHashAttempts": ["0x789abc..."],
          "contractsVersion": "6.0",
          "chainVersion": "SXR",
          "sportXeventId": "L16068923",
          "providerEventId": "17438473",
          "marketHasRefunds": false,
          "baseToken": "0x6629Ce1Cf35Cc1329ebB4F63202F3f197b3F050B",
          "id": "69c4983a23f5052c3b0a6dc2"
        }
      ]
    }
  }
  ```

  Each order hash returns two trade records — one for the maker and one for the taker. `odds` is from each bettor's perspective as a fixed-point integer — divide by 10^20 to get a decimal.
</Accordion>

***

## Real-time trades

Rather than polling, subscribe to WebSocket channels to receive trades as they happen:

* **`recent_trades:global`** — Global feed of every trade on the exchange, one message per order fill.
* **`recent_trades_consolidated:global`** — Same feed, but one message per taker bet regardless of how many maker orders it filled.

For setup and full payload references, see [Real-time Data →](/developers/real-time).
