> For the complete documentation index, see [llms.txt](https://betmatic.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://betmatic.gitbook.io/documentation/data/markets-and-codes.md).

# Markets & Codes

Returns the available bet markets and racing codes. Call this at startup and cache the results — the values change infrequently.

***

## GET /bet/markets/

Returns all bet markets, racing codes, and sports market definitions. Requires authentication.

```
GET /bet/markets/
```

### Examples

```bash
curl https://betmatic.app/api/bet/markets/ \
  -H "Authorization: Token YOUR_TOKEN"
```

```python
import requests

response = requests.get(
    "https://betmatic.app/api/bet/markets/",
    headers={"Authorization": "Token YOUR_TOKEN"}
)
print(response.json())
```

### Success response — 200 OK

```json
{
  "markets": [
    "Fixed Win",
    "Fixed Place",
    "Top Fluc",
    "Tote Win",
    "Tote Place",
    "Best Tote Win",
    "Best Tote Place",
    "Mid Tote Win",
    "Mid Tote Place",
    "Best of Best",
    "Same Race Multi",
    "Betfair SP",
    "Lay Win",
    "Lay Place",
    "Betfair SP Back Win",
    "Betfair SP Back Place",
    "Betfair SP Lay Win",
    "Betfair SP Lay Place"
  ],
  "codes": [
    "FWIN",
    "FPLC",
    "TF",
    "TWIN",
    "TPLC",
    "BT3SP",
    "BTP",
    "MT",
    "MTP",
    "BOB",
    "SRM",
    "BFSP",
    "LWIN",
    "LPLC",
    "BFSBW",
    "BFSBP",
    "BFSLW",
    "BFSLP"
  ],
  "sports_markets": [
    {
      "sport": "AFL",
      "markets": ["Head to Head", "Handicap", "Total Match Points"]
    },
    {
      "sport": "NBA",
      "markets": ["Head to Head", "Handicap", "Total Match Points"]
    },
    {
      "sport": "Tennis",
      "markets": ["Head to Head"]
    }
  ]
}
```

### Response fields

| Field                      | Type   | Description                                                                   |
| -------------------------- | ------ | ----------------------------------------------------------------------------- |
| `markets`                  | array  | Full market name strings — use these in the `market` field when creating bets |
| `codes`                    | array  | Shorthand market codes corresponding to each market name                      |
| `sports_markets`           | array  | Sports market definitions grouped by sport                                    |
| `sports_markets[].sport`   | string | Sport code e.g. `"AFL"`, `"NBA"`, `"Tennis"`                                  |
| `sports_markets[].markets` | array  | Available market names for that sport                                         |

### Racing markets

| Market name             | Code    | Description                                                     |
| ----------------------- | ------- | --------------------------------------------------------------- |
| `Fixed Win`             | `FWIN`  | Win bet at fixed odds — runner must finish first                |
| `Fixed Place`           | `FPLC`  | Place bet at fixed odds — runner finishes in the top 2, 3, or 4 |
| `Top Fluc`              | `TF`    | Best of fixed or tote win price                                 |
| `Tote Win`              | `TWIN`  | Win bet at tote (dividends) odds                                |
| `Tote Place`            | `TPLC`  | Place bet at tote odds                                          |
| `Best Tote Win`         | `BT3SP` | Best win price across the three tote pools                      |
| `Best Tote Place`       | `BTP`   | Best place price across the three tote pools                    |
| `Mid Tote Win`          | `MT`    | Mid-point tote win price                                        |
| `Mid Tote Place`        | `MTP`   | Mid-point tote place price                                      |
| `Best of Best`          | `BOB`   | Best available price combining fixed and tote                   |
| `Same Race Multi`       | `SRM`   | Multi-leg bet within a single race                              |
| `Betfair SP`            | `BFSP`  | Betfair Starting Price                                          |
| `Lay Win`               | `LWIN`  | Lay bet on a runner to lose (win market)                        |
| `Lay Place`             | `LPLC`  | Lay bet on a runner to lose (place market)                      |
| `Betfair SP Back Win`   | `BFSBW` | Back a runner at Betfair SP (win market)                        |
| `Betfair SP Back Place` | `BFSBP` | Back a runner at Betfair SP (place market)                      |
| `Betfair SP Lay Win`    | `BFSLW` | Lay a runner at Betfair SP (win market)                         |
| `Betfair SP Lay Place`  | `BFSLP` | Lay a runner at Betfair SP (place market)                       |

> **Note:** Not all bookmakers support every market. Check `markets_unavailable` in `GET /bookie/names/` for per-bookmaker restrictions.

### Racing codes

Racing codes (`GET /bet/codes/`) identify the type of racing event:

| Code         | Description               |
| ------------ | ------------------------- |
| `Galloping`  | Thoroughbred horse racing |
| `Harness`    | Harness/trotting racing   |
| `Greyhounds` | Greyhound racing          |

> **Note:** Use the exact string values from this response in the `market` and `code` fields when creating bets. Values are case-sensitive.

***

## GET /bet/codes/

Returns valid racing code strings only. Requires authentication.

```
GET /bet/codes/
```

### Examples

```bash
curl https://betmatic.app/api/bet/codes/ \
  -H "Authorization: Token YOUR_TOKEN"
```

```python
import requests

response = requests.get(
    "https://betmatic.app/api/bet/codes/",
    headers={"Authorization": "Token YOUR_TOKEN"}
)
print(response.json())
```

### Success response — 200 OK

```json
{"codes": ["Galloping", "Harness", "Greyhounds"]}
```

> **Tip:** Use `GET /bet/markets/` if you need both markets and codes in a single call.
