BitMEX documents its API using the Swagger/OpenAPI Specification.
The basic structure of an API response is documented in the API Explorer, which is generated by this specification. All responses are application/json.
In general, expect results to be either a plain object or array of objects corresponding to the particular endpoint. The same object shape is used for table retrieved from the WebSocket.
If an error is thrown, the error is of the shape:
{"error": {
"message": "...",
"name": "HTTPError" | "ValidationError" | "WebsocketError" | "Error"
}}
A full list of possible errors is below. Note that throwing too many errors in a short period of time is grounds for a temporary IP or account ban.
GET /user
- Account does not exist
GET /
- table is not valid
- filter values are not valid
- startTime is invalid
- endTime is invalid
- depth is invalid
- filter columns are not valid
- start is invalid
- count is invalid
- columns are not valid
POST /user/requestWithdrawal
- Account does not exist
- Negative withdrawal amount
- Negative fee amount
- Invalid withdrawal amount
- Invalid fee amount
- Account has insufficient Withdrawable Balance
- Withdrawal ban expires at [Date]
- Withdrawals currently disabled, please contact Customer Support
POST /user/{cancel,confirm}Withdrawal
- Account does not exist
- transactStatus is not Pending
POST /order, PUT /order, POST /order/closePosition
- Duplicate clOrdID
- Invalid orderID
- Duplicate orderID
- Invalid symbol
- Instruments do not match
- Instrument not listed for trading yet
- Instrument expired
- Instrument has no mark price
- Accounts do not match
- Invalid account
- Account is suspended
- Account has no [XBt]
- Invalid ordStatus (trying to amend a canceled or filled order)
- Invalid triggered
- Invalid workingIndicator
- Invalid side
- Invalid orderQty or simpleOrderQty
- Invalid simpleOrderQty
- Invalid orderQty
- Invalid simpleLeavesQty
- Invalid simpleCumQty
- Invalid leavesQty
- Invalid cumQty
- Invalid avgPx
- Invalid price
- Invalid price tickSize
- Invalid displayQty
- Unsupported ordType
- Unsupported pegPriceType
- Invalid pegPriceType for ordType
- Invalid pegOffsetValue for pegPriceType
- Invalid pegOffsetValue tickSize
- Invalid stopPx for ordType
- Invalid stopPx tickSize
- Unsupported timeInForce
- Unsupported execInst
- Invalid execInst
- Invalid ordType or timeInForce for execInst
- Invalid displayQty for execInst
- Invalid ordType for execInst
- Unsupported contingencyType
- Invalid clOrdLinkID for contingencyType
- Invalid multiLegReportingType
- Invalid currency
- Invalid settlCurrency
Reject reasons for orders created by above
Note: In these cases, the order will be returned with an
ordRejReason
.
- Invalid ordStatus
- Market is not open
- Underlying leg market is not open
- Underlying leg instrument has no mark price
- Invalid price
- Invalid price tickSize
- Price greater than limitUpPrice
- Price less than limitDownPrice
- Invalid side
- Invalid orderQty or simpleOrderQty
- Invalid simpleOrderQty
- Invalid orderQty
- Invalid leavesQty
- Invalid simpleLeavesQty
- Invalid pegOffsetValue for pegPriceType
- Invalid pegOffsetValue tickSize
- Invalid stopPx for ordType
- Invalid stopPx tickSize
- Account has insufficient Available Balance, [100000 XBt] required
- Value of positions and orders exceeds account Risk Limit
- Value of position and orders exceeds position Risk Limit
- Position is in liquidation
- Order price is below the liquidation price of current long position
- Order price is above the liquidation price of current short position
- Executing at order price would lead to immediate liquidation
- Executing at order price would push account deeper into margin call
- Account is in margin call
- Executing at order price would put account into margin call
- Order had execInst of [Close|ReduceOnly] and side of [Buy|Sell] but current position is [100]
POST /position/riskLimit
- Market is not open
- Cannot exceed the maximum effective leverage
- Value of position and orders exceeds position Risk Limit
POST /position/leverage
- Instrument is not taxable
- Market is not open
- Invalid leverage
- Cannot exceed the maximum entry leverage
- Account has insufficient Available Balance
POST /position/isolate
- Instrument is not taxable
- Market is not open
POST /position/transferMargin
- Instrument is not taxable
- Market is not open
- Position has cross margin enabled
- Invalid amount for isolated margin transfer
- Account has insufficient Available Balance
- Position has insufficient isolated margin