Guide
BrokerMarket dataCrypto API key

BitMEX API guide

BitMEX’s API is mature and well documented, and its testnet is one of the best in crypto for derivatives rehearsals.

Last verified · Also known as BitMEX API, BitMEX testnet

Quick answer

BitMEX pioneered the perpetual swap and still offers a REST and WebSocket API for perpetuals, futures and spot. Requests are signed with HMAC-SHA256 over verb + path + expires + body, and a full testnet at testnet.bitmex.com with test coins makes it easy to rehearse a bot. Bucketed trade bins provide public OHLCV.

BitMEX API at a glance

Pricing
Free API; trading fees apply
Availability
Global; not US residents
Paper trading
Testnet at testnet.bitmex.com
Integration type
REST + API key
In AlgoGP
Design and backtest in AlgoGP, connect the exported code
Auth
api-key, api-expires, api-signature (HMAC-SHA256)
Host
https://www.bitmex.com/api/v1
Testnet
https://testnet.bitmex.com

Public market data from BitMEX

curl -s "https://www.bitmex.com/api/v1/trade/bucketed?binSize=1h&symbol=XBTUSD&count=200&reverse=true"
Hourly XBTUSD trade buckets (keyless).

Save the bars as CSV and replay them with the exported python backtest.py --csv bars.csv, or use CCXT to read the same candles in one line of Python.

What to know before automating BitMEX

  • Quantities on inverse contracts like XBTUSD are in USD contracts, not BTC.
  • Bucket timestamps mark the bin close.

Build a BitMEX strategy with AlgoGP

AlgoGP does not connect to BitMEX natively yet. BitMEX uses plain HTTPS with an API key, so it is a good candidate for a native adapter; it is not built in yet.

  1. 1

    Design and backtest in AlgoGP

    Describe the strategy to the copilot and backtest it on years of normalized history. The result does not depend on any vendor.

  2. 2

    Export the Python project

    Every project exports strategy.py, market_data.py, brokers.py and live.py. The strategy only sees bars, cash, positions and orders, never a vendor’s wire format.

  3. 3

    Plug in BitMEX

    Implement the four adapter methods (account, positions, submit_market_order and a candle fetcher) with BitMEX’s SDK, or keep a built-in platform for paper trading and add BitMEX when you go live.

Built-in brokers for the same markets: Alpaca, Binance, Kraken, Bybit.

BitMEX API: frequently asked questions

Is BitMEX available in the US?

No; US persons are excluded.

Design and backtest your BitMEX strategy first

AlgoGP turns an idea into Python and tests it on years of history before you connect it to BitMEX. The exported code keeps the broker behind four small adapter methods.

  • AI copilot writes and revises the rules
  • Backtests with realistic costs
  • Exported Python ready to wire to BitMEX

Free plan, no card required.

BitMEX alternatives

Independent guide. AlgoGP is not affiliated with BitMEX. Limits, prices and availability change; confirm them in the official documentation. Nothing here is investment advice.

Build a strategy