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

# API reference

> How to read the endpoint pages, the base URL, authentication, the response envelope, and a note on the playground.

The pages in this section are generated from the OpenAPI 3.1 spec that MagicMarkets publishes at `https://magicmarkets.com/v2/openapi.yaml`. Each endpoint page shows the request, every response shape, and an interactive playground.

## Base URL

```
https://magicmarkets.com/v2/
```

Every path also works behind the `/magic-api` prefix.

## Authentication

Send your API key in the `X-Api-Key` header on every request. See [Authentication](/developers/authentication).

## Envelope

```json theme={"dark"}
{"status": "ok", "data": ...}
{"status": "error", "code": "<code>", "data": <details>}
```

Check `status` before reading `data`. Branch on `code`. See [Errors and rate limits](/developers/errors-and-rate-limits).

## Endpoint groups

| Group | Endpoints |
| - | - |
| Betslips | `GET`, `POST /v2/betslips/`; `GET`, `DELETE /v2/betslips/{betslip_id}/`; `POST /v2/betslips/{betslip_id}/refresh/` |
| Orders | `GET`, `POST /v2/orders/`; `GET /v2/orders/{order_id}/`; `GET /v2/orders/updates/`; `GET /v2/orders/tracked/{uuid}/`; `POST /v2/orders/{order_id}/close/`; `POST /v2/orders/close_many/`; `POST /v2/orders/close_all/`; `GET /v2/orders/position/` |
| Account | `GET /v2/balance/`; `GET /v2/xrates/` |
| Heartbeats | `GET`, `POST /v2/heartbeats/`; `GET`, `DELETE /v2/heartbeats/{heartbeat_id}/`; `POST /v2/heartbeats/{heartbeat_id}/refresh/` |
| Market data | `GET /v2/events/`; `GET /v2/offers/` |
| Reference | `GET /v2/sports/{sport}/bet_types/{bet_type}/` |
| Streaming | `GET /v2/stream` (WebSocket upgrade). See [WebSocket stream](/developers/websocket-stream) |

<Warning>
  The playground sends real requests to the production API with the key you enter. `POST /v2/orders/` places a real order with real USDT. `POST /v2/orders/close_all/` with an empty body closes every open order on the account.
</Warning>

## Versions

The spec carries `info.version`, currently `0.1.0`. The [changelog](/developers/changelog) records dated changes to the API, the tools and these docs.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.