MUTEX
Docs
Home
Developers · Trading API

Trading API

A REST API for algo traders. It drives one API-type bot account - it cannot touch your main perp account and cannot move money (no deposits, withdrawals, swaps, or transfers). Base URL https://trade.mutex.exchange.

Open interactive reference live OpenAPI spec · always in sync with the deployed API
Step 1

Create an API bot

In the web app, create a bot with template API (no strategy params - the engine is inert; you drive it). This gives you a dedicated sub-account the key will trade.

Step 2

Fund it

Top the bot up from the bot's detail page (funding stays in the web app - never on this API). Balance shows up on GET /v1/account.

Step 3

Generate a key

In the app, open Settings, then the API tab, and generate the bot's trading key(an armed, running or paused bot lists there). It's shown once - copy it now (mtx_bot_…). Affiliates generate an mtx_aff_… key on the same tab instead - see the Affiliate API.

Check it's wired up:

curl https://trade.mutex.exchange/v1/key \
  -H "Authorization: Bearer mtx_bot_…"
# {"kind":"trading","display_prefix":"mtx_bot_a1b2","bot":"bot_…","created_at":1721480400000}
Step 4

Place your first order

curl -X POST https://trade.mutex.exchange/v1/orders \
  -H "Authorization: Bearer mtx_bot_…" \
  -H "Content-Type: application/json" \
  -d '{"type":"limit","symbol":"BTC","side":"buy","size":"0.01",
       "price":"50000","time_in_force":"gtc","client_order_id":"algo-1"}'
  • Markets are plain coin symbols ("BTC"). Numbers are decimal strings on output; inputs accept strings or JSON numbers. Timestamps are Unix ms.
  • client_order_id (≤ 64 chars, not UUID-shaped) is your idempotency + lookup handle, unique per bot. A duplicate is 409 duplicate_client_order_id before anything reaches the venue.
  • Attach take_profit / stop_loss (trigger prices) to an entry order and they fan out as reduce-only conditionals after the entry submits.

Preview first if you want the fee/margin estimate: POST /v1/orders/preview.

Step 5

Read fills

curl "https://trade.mutex.exchange/v1/fills?limit=50" \
  -H "Authorization: Bearer mtx_bot_…"
# {"fills":[{"fill_id":"…","symbol":"BTC","side":"buy","role":"taker",
#            "size":"0.01","price":"50000","fee":"0.15","liquidation":false,
#            "created_at":1721480400000}],"next_before":"…"}

Page with the cursor: pass the response's next_before as ?before=. Positions and balance are GET /v1/positions and GET /v1/account.

Contract

Auth

Authorization: Bearer <key> on every non-market-data route. Market data (/v1/markets, /v1/candles) needs no key. A trading key on affiliate routes (or the reverse) is 403 wrong_key_kind. Keys never expire; they die when revoked or when the bound bot is torn down. On a suspected leak, revoke the key (regenerate in the app or ask an admin) - the bot keeps running.

Contract

Rate limits

Two per-key fixed 1-minute buckets:

BucketLimitApplies to
orders60 / minPOST /v1/orders, modify, cancel
reads300 / mineverything else with a key

Every response carries X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset (seconds to reset). Over the limit → 429 rate_limited plus Retry-After - back off until then. Sustained flooding (> 1000 429s in 10 min) auto-suspends the key for an hour (key_suspended); three suspensions in 24 h needs a manual admin re-enable. Public market data has no per-key bucket - nginx per-IP flood control is the guard there.

Contract

Error codes

Honest HTTP status + { "error": { "code", "message" } }. Match on code.

CodeHTTPMeaning
service_disabled403The API is not enabled (dark).
missing_key401No Authorization: Bearer.
invalid_key401Unknown or malformed key.
wrong_key_kind403Key kind doesn't match the route (trading vs affiliate).
key_suspended403Auto-suspended for abuse; retry after the window.
account_suspended403The owning user is disabled.
rate_limited429Bucket exhausted; see Retry-After.
invalid_request400Bad params or body (validation detail in message).
bots_disabled403Bots subsystem off platform-wide.
trading_halted403Global kill switch is on.
bot_not_trading409Bot paused/quarantined - reads + cancels only.
unknown_market404No such symbol.
order_not_found404No order by that id / client_order_id.
duplicate_client_order_id409client_order_id already used on this bot.
order_rejected400Venue rejected the order (reason in message).
conflict409Modify/cancel raced venue state.
venue_unavailable503Upstream venue unreachable; retry.
internal_error500Unexpected; safe to retry idempotently.
Scope

Not on this API

Deposits, withdrawals, swaps, transfers, TWAP orders, WebSocket streams, and your main perp account. Slice your own algo orders; poll for market data. The full endpoint set, request/response schemas and examples live in the interactive reference.

Read-only reference