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

# Developer overview

> What the MagicMarkets API covers, where it lives, how the pieces fit, and the fastest way to start.

The MagicMarkets API lets a program do what the web app does: discover events, read live prices, quote and place orders, close them, and read positions and balance. MagicMarkets puts orders from other traders and liquidity aggregated from more than 25 sportsbooks, sports exchanges and prediction markets into one order book. Trading carries zero commission, and one API key authenticates every call.

The API is open to every individual account. Create an API key and start trading. There is no application, fee or onboarding. If you run a price aggregator, a comparison site or another platform that wants to display MagicMarkets prices, or you need higher limits, see [Partners](/partners/overview).

```bash theme={"dark"}
git clone https://github.com/magicmarkets/magicmarkets-cli && cd magicmarkets-cli && make install
MAGICMARKETS_API_KEY=your-key magicmarkets markets --sport fb --limit 5
```

The first line needs a recent Go toolchain. The second lists football events that have live prices now. [Create an API key](/developers/authentication) first. API access needs a minimum deposit of 10 USDT.

| | |
| - | - |
| REST base URL | `https://magicmarkets.com/v2/` |
| WebSocket | `wss://magicmarkets.com/v2/stream?api_key=<key>` |
| Authentication | `X-Api-Key` header on REST, `api_key` query parameter on the socket |
| Stakes and balances | `["USDT", <amount>]` tuples, always USDT |
| Prices | Decimal odds on a fixed tick schedule |
| Spec | OpenAPI 3.1 at `/v2/openapi.yaml` and `/v2/openapi.json` |

<Note>
  **Read prices from offers. Use betslips only to place orders.** Offers, from `GET /v2/offers/` or the WebSocket, carry the prices you need to scan markets. Open a betslip when you are ready to place an order, and close it with `DELETE /v2/betslips/{betslip_id}/` once the order is placed. The order stays open after its betslip closes.
</Note>

## Three ways in

<Columns cols={3}>
  <Card title="CLI" icon="square-terminal" href="/developers/tools/cli">
    The fastest start. One open-source binary for the whole API: markets, offers, betslips, orders, heartbeats and position. MIT licence.
  </Card>

  <Card title="REST and WebSocket" icon="server" href="/developers/quickstart">
    Any language. REST for event discovery, a price snapshot, betslips, orders, positions, balance and heartbeats. One WebSocket for live offers, your quotes and order updates.
  </Card>

  <Card title="MCP server" icon="bot" href="/developers/tools/mcp">
    For agents. The CLI runs a local MCP server that is read-only until you turn trading on. A hosted server runs at `magicmarkets.com/mcp`.
  </Card>
</Columns>

Reference pages: [REST endpoints](/developers/api-reference/introduction) and [WebSocket stream](/developers/websocket-stream).

## The shape of an integration

Placing an order takes two steps: create a betslip, then place an order against it. A full integration looks like this:

1. **Read prices and pick a selection.** List events with `GET /v2/events/` and read an event's offers with `GET /v2/offers/`, or take both from the WebSocket. An offer's `sport`, `event_id` and `bet_type` go into a betslip unchanged.
2. **Create a betslip.** You describe what you want to trade: the sport, the event, the bet type. The response carries no prices, because quotes are gathered asynchronously.
3. **Read your executable price.** It arrives as a `pmm` message on the WebSocket, or you poll the betslip. Prices usually land within a couple of seconds. The betslip is [short-lived](/developers/concepts#betslip).
4. **Place an order** against that betslip, with your price and stake.
5. **Watch the order** on the socket, or poll it.

A betslip is the first step to place an order on one selection. It is not an order, and nothing is at risk until you place against it. See [Concepts](/developers/concepts).

## Safe by default

Automated trading fails in known ways, so the platform and tooling guard against them:

* **Heartbeats** act as a dead-man's switch. If your code goes quiet, resting orders close themselves.
* **Order placement is idempotent when you send a `request_uuid`.** A retry with the same UUID returns the existing order and cannot place a second one.
* **Your limit is honoured.** An order fills only at your price or better. See [Prices and ticks](/developers/prices-and-ticks).
* **The API cannot move funds.** No deposit, withdrawal or key management endpoint exists. A leaked key can trade, not withdraw.
* **The local MCP server starts read-only.** Trading needs `MAGICMARKETS_ALLOW_TRADING=1`. The hosted MCP server has no read-only mode: see [MCP server](/developers/tools/mcp).

See [Safety](/developers/safety).

## Written for humans and agents

The API publishes its own machine-readable reference at `magicmarkets.com/llms.txt`, `magicmarkets.com/llms-full.txt` and the OpenAPI spec. This site adds `.md` versions of every page. `llms-full.txt` holds the full API reference in one Markdown file, so one URL gives an agent the whole contract. See [Machine-readable docs](/developers/tools/machine-readable-docs).

## Start

<Columns cols={3}>
  <Card title="Quickstart" icon="rocket" href="/developers/quickstart" />

  <Card title="Authentication" icon="key" href="/developers/authentication" />

  <Card title="Place an order in Python" icon="code" href="/developers/guides/place-an-order" />
</Columns>


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