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

> Query active sports markets from the SX Bet API.

All active markets are available from [`GET /markets/active`](/api-reference/get-markets-active). You can filter by sport, league, event, market type, and more. To look up a specific market by hash, use [`GET /markets/find`](/api-reference/get-markets-find).

***

## Fetch markets by sport

Pass one or more `sportIds` to scope results to a particular sport.

```bash theme={null}
# NFL and NBA together
curl "https://api.sx.bet/markets/active?sportIds=1,4"
```

Use [`GET /sports`](/api-reference/get-sports) to get a full list of sport IDs and their labels.

***

## Fetch markets by league

Pass a `leagueId` to get all active markets in a specific league.

```bash theme={null}
# English Premier League (leagueId=29)
curl "https://api.sx.bet/markets/active?leagueId=29"
```

Use [`GET /leagues/active`](/api-reference/get-leagues-active) to get a full list of active league IDs.

***

## Fetch markets by event

If you already have a `sportXeventId` (returned on any market object), you can fetch all markets for that specific fixture.

```bash theme={null}
curl "https://api.sx.bet/markets/active?eventId=L16068923"
```

This returns every market type available for that single game — moneylines, spreads, totals, and any period or prop markets.

***

## Find fixtures by team name

If you don't already have an `eventId`, use [`GET /search`](/api-reference/search) to look up active fixtures by team name. Pass a `query` between 3 and 100 characters; matching is case-insensitive and supports partial names. Results are limited to 8 active fixtures, ordered by `gameTime`.

```bash theme={null}
curl "https://api.sx.bet/search?query=mia"
```

Each result includes the `eventId`, scheduled `gameTime`, both team names, and a `type` array of available market type IDs for that fixture. Pass the `eventId` to [`GET /markets/active`](/api-reference/get-markets-active) to fetch markets for that fixture.

***

## Fetch a specific market by marketHash

If you have a `marketHash`, use [`GET /markets/find`](/api-reference/get-markets-find) to retrieve it directly. You can pass up to 30 hashes in a single request.

```bash theme={null}
curl "https://api.sx.bet/markets/find?marketHashes=0x024902...dd7667b,0x1c8f12...bcbc83"
```

[`GET /markets/find`](/api-reference/get-markets-find) also returns settled markets, so it's useful for looking up historical results.

***

## Filters

### Main lines only

For spread and total markets, multiple lines are usually available at once (e.g. over 1.5, 2.5, 3.5 goals). Set `onlyMainLine=true` to return only the primary line for each market type — the line where both sides are closest to 50/50.

```bash theme={null}
curl "https://api.sx.bet/markets/active?leagueId=29&onlyMainLine=true"
```

### Live markets only

Set `liveOnly=true` to return only markets currently available for in-play betting.

```bash theme={null}
curl "https://api.sx.bet/markets/active?liveOnly=true"
```

### Filter by market type

Pass one or more market type IDs using the `type` parameter to narrow results to a specific bet type.

```bash theme={null}
# Moneyline and Asian Handicap
curl "https://api.sx.bet/markets/active?type=52,3"
```

Common market types:

| `type` | Name                      |
| ------ | ------------------------- |
| `1`    | 1X2 (win / draw / no win) |
| `52`   | 12 (moneyline, no draw)   |
| `226`  | 12 Including Overtime     |
| `3`    | Asian Handicap (spread)   |
| `2`    | Under/Over (totals)       |

See the full list on the [Market Types](/api-reference/market-types) page.

***

## Pagination

[`GET /markets/active`](/api-reference/get-markets-active) uses cursor-based pagination. Each response includes a `nextKey` field — pass it as `paginationKey` in your next request. Keep paginating until `nextKey` is absent or empty. Maximum `pageSize` is 100.

***

## Real-time market updates

Rather than polling [`GET /markets/active`](/api-reference/get-markets-active), subscribe to WebSocket channels to receive market changes as they happen. Three channels are relevant when working with markets:

| Channel                | What you receive                                                 |
| ---------------------- | ---------------------------------------------------------------- |
| `markets:global`       | Market status changes — new markets added, suspended, or settled |
| `main_line:global`     | Main line shifts on spread and totals markets                    |
| `fixtures:live_scores` | Live score updates for a specific event                          |

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