MagicMarkets Reference API

Exchange rates and bet type information.

GitHub OpenAPI

Operations 2

GET /v2/xrates/ Exchange rates #
GET /v2/sports/{sport}/bet_types/{bet_type}/ Bet type info #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/magicmarkets-com:magicmarkets-com-reference-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

magicmarkets-com-reference-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: MagicMarkets Reference API
  version: 0.1.0
  description: 'REST and WebSocket API for MagicMarkets. Place orders, stream real-time

    prices, and manage your positions programmatically. ## Authentication


    Every request must be authenticated with an **API key**. Pass it in the

    `X-Api-Key` header:


    ```

    X-Api-Key:

    ```


    ### Getting an API key


    API keys are created and managed through the MagicMarkets website at

    magicmarkets.com:


    1. Go to **Settings -> API**. 2. Click **Add API Key** and give it a name. 3. Copy the key value - it is shown **once at creation**, so store it

    somewhere safe immediately. You can also revoke or rename existing keys from the same page. There is

    no endpoint in this API to manage keys - all key management happens on

    the website. ### Using a key


    Send the key on every request:


    ```bash

    curl https://magicmarkets.com/v2/xrates/ \

    -H "X-Api-Key: $MAGIC_API_KEY"

    ```


    ## Quickstart


    This walkthrough goes from zero to a placed bet: stream prices over the

    WebSocket, read a `bet_type` off the feed, quote it as a betslip, place

    an order, and watch the order update on the same socket. ### Before you start


    You need an API key (see **Authentication** above) and Python 3.9+ with

    two libraries:


    ```bash

    pip install requests websockets

    ```


    Every snippet reads its configuration from the environment:


    ```bash

    export MAGIC_API_URL="https:///v2"

    export MAGIC_WS_URL="wss:///v2/stream"

    export MAGIC_API_KEY=""

    ```


    Three concepts carry the whole flow:


    - **Two steps to a bet.** A *betslip* registers your interest in one

    selection (`POST /v2/betslips/`); its live quote then arrives as

    `["pmm", ...]` entries on the WebSocket. An *order* commits a stake

    against that quote (`POST /v2/orders/`). You always create the

    betslip first. - **`bet_type` comes from the feed.** Offers on the WebSocket carry the

    `bet_type` string ready to use - pass it to `POST /v2/betslips/`

    verbatim. You never need to construct or parse it (the grammar in

    **Sports & bet types** is reference material, not required reading). - **Stakes are USDT.** Wherever money appears it is a

    `["USDT", amount]` pair. ### Step 1 - Check your key


    Before opening the socket, prove the key works with a cheap REST call -

    a bad key fails the WebSocket upgrade with HTTP 401, so verify the key

    first:


    ```bash

    curl "$MAGIC_API_URL/xrates/" -H "X-Api-Key: $MAGIC_API_KEY"

    ```


    A `200` with `{"status": "ok", ...}` means you are good to go. ### Step 2 - Connect to the stream


    Connect with the key as a query parameter. Every frame the server sends

    is a batch envelope `{"ts": ..., "data": [...]}` - iterate `data[]` and

    dispatch on each entry''s leading type tag (see the **Streaming API**

    endpoint for the full wire format):


    ```python

    import json, os

    from websockets.sync.client import connect


    ws = connect(f"{os.environ[''MAGIC_WS_URL'']}?api_key={os.environ[''MAGIC_API_KEY'']}")


    events, synced = [], False

    while not synced:

    frame = json.loads(ws.recv())

    for entry in frame["data"]:

    if entry[0] == "event":

    events.append(entry[1]) # {"sport": ..., "event_id": ..., ...}

    elif entry[0] == "sync":

    synced = True

    ```


    After `["sync", ...]` you hold the list of currently-priced events, e.g.:


    ```json

    ["event", {"event_type": "normal", "sport": "fb",

    "event_id": "2026-06-15,1001,2002", "competition_id": 1,

    "competition_name": "England Premier League",

    "competition_country": "XE", "home": "Arsenal", "away": "Chelsea",

    "event_name": "Arsenal vs. Chelsea", "ir_status": "pre_event",

    "start_time": "2026-06-15T15:00:00Z"}]

    ```


    ### Step 3 - Register for offers on an event


    Pick an event and register.'
security:
- ApiKeyHeader: []
tags:
- name: Reference
  description: Exchange rates and bet type information.
paths:
  /v2/xrates/:
    get:
      tags:
      - Reference
      summary: Exchange rates
      description: Returns current exchange rates.
      responses:
        '401':
          $ref: '#/components/responses/Error401'
        '403':
          $ref: '#/components/responses/Error403'
        '429':
          $ref: '#/components/responses/Error429'
        '500':
          $ref: '#/components/responses/Error500'
        '200':
          description: Exchange rate list
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/XRatesEnvelope'
              example:
                status: ok
                data:
                - ccy: USD
                  rate: 1.265
                - ccy: EUR
                  rate: 1.1347
                - ccy: USDT
                  rate: 1.1538
      operationId: getV2Xrates
      x-operation-id-source: derived
  /v2/sports/{sport}/bet_types/{bet_type}/:
    get:
      tags:
      - Reference
      summary: Bet type info
      description: Returns information about a bet type including the win/loss payout grid.
      parameters:
      - name: sport
        in: path
        required: true
        schema:
          type: string
        description: Sport code - see "Sports & bet types" in the introduction.
      - name: bet_type
        in: path
        required: true
        schema:
          type: string
        description: Bet type string - see "Sports & bet types" in the introduction.
      - name: home_team
        in: query
        schema:
          type: string
        description: Home team name for display labels
      - name: away_team
        in: query
        schema:
          type: string
        description: Away team name for display labels
      responses:
        '400':
          description: The `bet_type` string did not parse. Note this endpoint uses the `invalid_bet_type` code with the offending value under `data.bet_type`, not the usual `validation_error` shape. It also cannot validate multirunner bet types (`for,win,...`, `for,top,...`), which need an event context and return this error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
              example:
                status: error
                code: invalid_bet_type
                data:
                  bet_type: for,notabettype
        '401':
          $ref: '#/components/responses/Error401'
        '403':
          $ref: '#/components/responses/Error403'
        '429':
          $ref: '#/components/responses/Error429'
        '500':
          $ref: '#/components/responses/Error500'
        '200':
          description: Bet type information
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BetTypeInfoEnvelope'
              example:
                status: ok
                data:
                  sport: Football
                  bet_type_description: Away
                  winloss_grid:
                  - - l
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                  - - l
                    - l
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                  - - l
                    - l
                    - l
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                    - w
                  - '... 20x20 grid of w/l values'
      operationId: getV2SportsBySportBetTypesByBetType
      x-operation-id-source: derived
components:
  schemas:
    XRate:
      type: object
      required:
      - ccy
      - rate
      properties:
        ccy:
          type: string
          description: Currency code (e.g. USD, EUR, USDT)
        rate:
          type: number
          description: Exchange rate to USDT
    XRatesEnvelope:
      type: object
      required:
      - status
      - data
      properties:
        status:
          type: string
          enum:
          - ok
        data:
          type: array
          items:
            $ref: '#/components/schemas/XRate'
    ErrorEnvelope:
      type: object
      description: Standard error response. The shape of `data` varies by `code` - see the **Errors** section in the introduction and the named examples on each endpoint's error responses.
      required:
      - status
      - code
      properties:
        status:
          type: string
          enum:
          - error
        code:
          type: string
          description: Stable machine-readable error code (e.g. `validation_error`, `not_found`, `forbidden`).
          example: validation_error
        data:
          description: Variable. Null, string, or object - see examples.
    BetTypeInfoEnvelope:
      type: object
      required:
      - status
      - data
      properties:
        status:
          type: string
          enum:
          - ok
        data:
          $ref: '#/components/schemas/BetTypeInfoResponse'
    BetTypeInfoResponse:
      type: object
      required:
      - sport
      - bet_type_description
      - winloss_grid
      properties:
        sport:
          type: string
          description: Display name for the sport (e.g. "Football")
        bet_type_description:
          type: string
          description: Human-readable bet type label
        winloss_grid:
          description: 20x20 grid of `w`/`l`/`p` (push)/`v` (void) outcomes, or null when no grid can be computed for the bet type
          oneOf:
          - type: array
            items:
              type: array
              items:
                type: string
          - type: 'null'
  responses:
    Error401:
      description: Authentication failed - API key missing, malformed, or rejected.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          example:
            status: error
            code: auth_error
            data:
              detail: Authentication credentials were not provided.
    Error500:
      description: Unexpected internal error. Quote `data[1]` (the token) when contacting support.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          example:
            status: error
            code: server_error
            data:
            - 'An error has occurred, token:'
            - ABC123abc456DEF789gh
    Error429:
      description: Rate limit hit. Honour the `Retry-After` header.
      headers:
        Retry-After:
          description: Seconds to wait before retrying.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          example:
            status: error
            code: throttled
            data:
              message: Request was throttled. Expected available in 12 seconds.
              retry_after: 12
    Error403:
      description: Authorization failed - the key is valid but cannot perform this action.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          example:
            status: error
            code: forbidden
            data: null
  securitySchemes:
    ApiKeyHeader:
      type: apiKey
      in: header
      name: X-Api-Key
      description: API key created from the magic-markets website