BTCMEX HTTP REST API
By using our HTTP REST API example, you can quickly start trading with the API.
Please check the REST API documents in the API browser for the API and the return types.
After you log in to BTCMEX, you can access the API Key management interface to create API secret with different permissions.
We have two types of permissions currently supported:
- Reading, it can only be used to query data API. Example: order check, fill check, etc. Other operations such as transaction are not allowed.
Entrust+Reading: You can use all API endpoints, include place orders, change orders and cancel orders.
After you create the API, please remember the following information:
- API Key.
Key used for signature authentication encryption (visible only when requesting).
Please notice: You can verify your IP address when creating API Key.
Risk warning: These two keys are closely related to account security. Please do not disclose them to others at any time. Leaking API Key may cause your asset loss, If you find that the API Key is leaked, please delete it at once.
Please click How to use API Key to know the detail.
BTCMEX REST API conforms to the swagger specification. Any Swagger-compatible client can connect to the BTCMEX API.
Please notice, al Bitcoin units returned are Satoshi:1 XBt (Satoshi) = 0.00000001 XBT (Bitcoin).
Frequency limiting rules
Each IP address restrictions 30 times within 1 second.
If you've exceeded the frequency limit and think it's a reasonable demand, please contact our Customer Service Department to increase your frequency limit.
When you send us an email that increases the frequency limit, please include the below information:
The purpose and expected growth of your application.
The speed limit you need.
Please confirm that your program is using the API effectively
Order size limit
In order to maintain an orderly market, BTCMEX sets the upper limit of the pending orders for each user:
Each user can hold up 200 not executed orders for each contract.
Each user can hold up 20 stop orders for each contract.
When your new submitted orders exceed these upper limits, it will be rejected and displayed “too many orders”.
Minimum trading limit
We specifically set the contract size of BTCMEX products to a small value to encourage institutional and individual traders to trade on BTCMEX. However, some traders abuse this mechanism and destroy the order book by sending many small orders.
If the user has too many unexecuted orders and the total value is less than 0.0025 XBT, the user will be marked as a spam user.
If you are marked as a spam user:
Your account trading rights will be restricted to only closing or cancellation.
The junk orders with value less than 0.0025 XBT has sent, will be cancelled automatically.
- If you want to remove the restriction of a spam account, please send your request to email@example.com via your verified email address or wait 24 hours for automatic recovery.
API Key usage
Authentication can be done by sending the following HTTP headers:
api-expires ：After UNIX timestamp, the request is no longer valid. This is to prevent a replay attack. For example, 2019-08-08T10:15:42Z is 1565230542. This timestamp will be compared with our system time before it reaches the order engine.
api-key ：Your API Key
api-signature: The signature of your current request. Its calculation method is
hex(HMAC_SHA256(apiSecret, verb + path + nonce + data))。 verb is one of GET/POST/PUT/DELET. Please check our example.