Certainly! I'll create a user-friendly version of the documentation for CoinDCX's futures trading API. This version will be simplified and focus on the key aspects that users need to get started and perform common operations.
Welcome to the CoinDCX Futures Trading API! This guide will help you integrate futures trading functionality into your applications. Our API allows you to place orders, manage positions, and access market data for futures contracts.
All API requests should be made to:
https://api.coindcx.com
To use the API, you need to include your API key and signature in the request headers:
X-AUTH-APIKEY
: Your API keyX-AUTH-SIGNATURE
: HMAC SHA256 signature of the request payload
To generate the signature:
- Create a JSON string of your request body
- Use HMAC SHA256 to hash this string with your API secret as the key
- The resulting hash is your signature
Example (Python):
import hmac
import hashlib
import json
secret = "your_api_secret"
body = {"timestamp": 1612345678000, "side": "buy", "market": "BTCUSDT"}
json_body = json.dumps(body)
signature = hmac.new(secret.encode(), json_body.encode(), hashlib.sha256).hexdigest()
Endpoint: POST /exchange/v1/derivatives/futures/orders/create
Parameters:
timestamp
: Current timestamp in millisecondsside
: "buy" or "sell"pair
: Trading pair (e.g., "B-BTC_USDT")order_type
: "market", "limit", "stop_limit", "stop_market", "take_profit_limit", "take_profit_market"price
: Order price (for limit orders)total_quantity
: Order quantityleverage
: Leverage value
Example Request:
import requests
url = "https://api.coindcx.com/exchange/v1/derivatives/futures/orders/create"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': 'your_api_key',
'X-AUTH-SIGNATURE': 'your_signature'
}
body = {
"timestamp": 1612345678000,
"side": "buy",
"pair": "B-BTC_USDT",
"order_type": "limit",
"price": 50000,
"total_quantity": 0.1,
"leverage": 5
}
response = requests.post(url, json=body, headers=headers)
print(response.json())
Endpoint: POST /exchange/v1/derivatives/futures/positions
Parameters:
timestamp
: Current timestamp in millisecondspage
: Page numbersize
: Number of records per page
Example Request:
url = "https://api.coindcx.com/exchange/v1/derivatives/futures/positions"
body = {
"timestamp": 1612345678000,
"page": "1",
"size": "10"
}
response = requests.post(url, json=body, headers=headers)
print(response.json())
Endpoint: POST /exchange/v1/derivatives/futures/orders/cancel
Parameters:
timestamp
: Current timestamp in millisecondsid
: Order ID to cancel
Example Request:
url = "https://api.coindcx.com/exchange/v1/derivatives/futures/orders/cancel"
body = {
"timestamp": 1612345678000,
"id": "order_id_here"
}
response = requests.post(url, json=body, headers=headers)
print(response.json())
If an error occurs, the API will return an error response with a status code and message. Common error codes include:
- 400: Bad Request
- 401: Unauthorized
- 404: Not Found
- 429: Too Many Requests
- 500: Internal Server Error
Always check the response status and handle errors appropriately in your application.
Be aware of rate limits to avoid being temporarily blocked. If you exceed the limit, you'll receive a 429 error. Implement proper error handling and consider adding delays between requests if necessary.
- Always use HTTPS for secure communication.
- Store your API key and secret securely and never share them.
- Implement proper error handling in your code.
- Test your integration thoroughly before going live.
- Stay updated with the latest API changes and updates from CoinDCX.
For more detailed information on specific endpoints or advanced features, please refer to the full API documentation or contact CoinDCX support.