Margin Order API Reference
Margin Order API Reference
docs.coindcx.com
Terminology
Common
target currency refers to the asset that is the quantity of a symbol.
base currency refers to the asset that is the price of a symbol.
pair uniquely identifies the market along with its exchange, and is available in
market details api.
Orders
status: used to denote the current status of the given order. Valid values for status
include:
init: order is just created, but not placed in the orderbook (eg: stop-limit
orders whose stop/trigger price hasn't reached)
open: order is successfully placed in the orderbook
partially_filled: order is partially filled
filled: order is completely filled
partially_cancelled: order is partially filled, but cancelled, thus inactive
cancelled: order is completely or partially cancelled
rejected: order is rejected (not placed on the exchange)
untriggered: order is untriggered (only applies to Futures Take Profit and
Stop Loss orders)
Margin Orders
1/192
status: used to denote the current status of the given margin order. Valid values for
status include:
init: order is just created, but not placed in the orderbook
open: order is successfully placed in the orderbook
partial_entry: internal entry order is partially filled
partial_close: internal target order is partially closed
cancelled: order is completely cancelled
rejected: order is rejected (not placed on the exchange)
close: order is completely filled
triggered: stop variant order triggered at specified stop price
order_type: used to denote the type of order to be placed. Valid values for
order_type includes:
market_order: in this order type we don't specify price; it is executed on the
market price
limit_order: in this order type we specify the price on which order is to be
executed
stop_limit: it is a type of limit order whether we specify stop price and a
price, once price reaches stop_price, order is placed on the given price
take_profit: it is a type of limit order whether we specify stop price and a
price, once price reaches stop_price, order is placed on the given price
Other Terms:
target_price: The price at which the trader plans to buy/sell or close the
order position is called the Target Price. When the Target price is hit, the trade
is closed and the trader’s funds are settled according to the P&L incurred.
Target price feature is available if the trader checks the Bracket order
checkbox.
sl_price: The price at which the trader wishes to Stop Loss is the SL Price.
stop_price: It is used in the Stop Variant order, to specify stop price
2/192
status for internal orders: used to denote the type of internal orders. Valid values
for order_type includes:
initial: order is just created
open: order is successfully placed in the orderbook
partially_filled: order is partially filled
filled: order is completely filled
cancelled: order is completely cancelled
rejected: order is rejected (not placed on the exchange)
partially_cancelled: order is partially cancelled
untriggered: stop variant order was not triggered
Setup
To access CoinDCX Public APIs and Sockets you will need
NOTE: If the Key is binded with the IP, then these API can only be used
with the binded IP and cannot be shared with ony other user having
different IP.
a. Javascript:
We recommend using Node.js. We recommend that you use v14 and above You’ll need
to have the following 2 Node modules installed to be able to work with our APIs:
Request module
Crypto module
b. Python:
3/192
We recommend that you use Python 3.8 and above. We recommend that you do not use
Python 2 as it is on its path to be sunset. You can install/know more from the official
Python website
3. For Sockets
a. Javascript:
We recommend using Node.js. We recommend that you use v14 and above You’ll need
to have the following Node modules installed to be able to work with our APIs:
Socket.io: Please note only version 2.4.0 of this module would work with our
Websockets. Please check this version in package.json
b. Python:
We recommend that you use Python 3.8 and above. We recommend that you do not use
Python 2 as it is on its path to be sunset. You can install/know more from the official
Python website
YAY!!, You are all set to access CoinDCX Public APIs and Sockets
Public endpoints
4/192
Ticker
HTTP Request
GET /exchange/ticker
url = "https://api.coindcx.com/exchange/ticker"
response = requests.get(url)
data = response.json()
print(data)
Response
[
{
"market": "REQBTC",
"change_24_hour": "-1.621",
"high": "0.00002799",
"low": "0.00002626",
"volume": "14.10",
"last_price": "0.00002663",
"bid": "0.00002663",
"ask": "0.00002669",
"timestamp": 1524211224
}
]
Definitions
bid - Highest bid offer in the orderbook
ask - Highest ask offer in the orderbook
high - 24 hour high
low - 24 hour low
volume - Volume of the market in last 24 hours.
timestamp - Time when this ticker was generated
Markets
HTTP Request
GET /exchange/v1/markets
5/192
import requests # Install requests module first.
url = "https://api.coindcx.com/exchange/v1/markets"
response = requests.get(url)
data = response.json()
print(data)
Respose:
[
"SNTBTC",
"TRXBTC",
"TRXETH"
.
.
]
Markets details
HTTP Request
GET /exchange/v1/markets_details
url = "https://api.coindcx.com/exchange/v1/markets_details"
response = requests.get(url)
data = response.json()
print(data)
Response:
6/192
[
{
"coindcx_name": "SNMBTC",
"base_currency_short_name": "BTC",
"target_currency_short_name": "SNM",
"target_currency_name": "Sonm",
"base_currency_name": "Bitcoin",
"min_quantity": 1,
"max_quantity": 90000000,
"min_price": 5.66e-7,
"max_price": 0.0000566,
"min_notional": 0.001,
"base_currency_precision": 8,
"target_currency_precision": 0,
"step": 1,
"order_types": [ "take_profit", "stop_limit", "market_order", "limit_order" ],
"symbol": "SNMBTC",
"ecode": "B",
"max_leverage": 3,
"max_leverage_short": null,
"pair": "B-SNM_BTC",
"status": "active"
}
]
Parameter Definitions
7/192
Parameter Definitions
order_types Different type of orders that can be placed for the market.
For example: limit_order, market_order etc
Trades
The base URL for Trades API call is https://public.coindcx.com
HTTP request
GET /market_data/trade_history
url = "https://public.coindcx.com/market_data/trade_history?pair=B-
BTC_USDT&limit=50" # Replace 'B-BTC_USDT' with your desired market pair.
response = requests.get(url)
data = response.json()
print(data)
Response
[
{
"p": 11603.88,
"q": 0.023519,
"s": "BTCUSDT",
"T": 1565163305770,
"m": false
}
]
Query parameters
8/192
Name Required Example
This API provides with a sorted list of most recent 30 trades by default if limit parameter is
not passed.
Definitions
Order book
The base URL for Order book API call is https://public.coindcx.com
response = requests.get(url)
data = response.json()
print(data)
Response
9/192
{
"bids":{
"11570.67000000": "0.000871",
"11570.58000000": "0.001974",
"11570.02000000": "0.280293",
"11570.00000000": "5.929216",
"11569.91000000": "0.000871",
"11569.89000000": "0.0016",
,
,
,
},
"asks":{
"13900.00000000": "27.04094600",
"13100.00000000": "15.48547100",
"12800.00000000": "36.93142200",
"12200.00000000": "92.04554800",
"12000.00000000": "72.66595000",
"11950.00000000": "17.16624600",
,
,
,
},
HTTP request
GET /market_data/orderbook
Query parameters
Candles
The base URL for Candles API call is https://public.coindcx.com
url = "https://public.coindcx.com/market_data/candles?pair=B-BTC_USDT&interval=1m"
# Replace 'SNTBTC' with the desired market pair.
response = requests.get(url)
data = response.json()
print(data)
Response
10/192
[
{
"open": 0.011803, // open price
"high": 0.011803, // highest price
"low": 0.011803, // lowest price
"volume": 0.35, // total volume in terms of target currency (in BTC for
B-BTC_USDT)
"close": 0.011803, // close price
"time": 1561463700000 //open time in ms
}
.
.
.
],
HTTP request
GET /market_data/candles
Query parameters
This API provides with a sorted list (in descending order according to time key) of
candlestick bars for given pair. Candles are uniquely identified by their time.
Valid intervals
m -> minutes, h -> hours, d -> days, w -> weeks, M -> months
1m
5m
15m
30m
1h
2h
4h
6h
8h
11/192
1d
3d
1w
1M
Authentication
Common Notes:
All the Authenticated API calls use POST method.
Parameters are to be passed as JSON in the request body.
Every request must contain a timestamp parameter of when the request was
generated. This timestamp is used to validate that the request is not a very old one
(due to some lag in any layer) - the request is rejected with an appropriate error if
this timestamp deviates too much from the server's time at which it is received to be
processed.
12/192
require 'net/http'
require 'uri'
require 'json'
require 'openssl'
payload = {
"side" : "buy",
"order_type" : "limit_order",
"price_per_unit": 0.00001724,
"market" : "SNTBTC",
"total_quantity" : 100,
"timestamp": 1524211224
}.to_json
headers = {
'Content-Type' => 'application/json',
'X-AUTH-APIKEY' => key,
'X-AUTH-SIGNATURE' => signature
}
uri = URI.parse("https://api.coindcx.com/exchange/v1/orders/create")
request.body = payload
response = https.request(request)
13/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"side": "buy", #Toggle between 'buy' or 'sell'.
"order_type": "limit_order", #Toggle between a 'market_order' or 'limit_order'.
"market": "SNTBTC", #Replace 'SNTBTC' with your desired market pair.
"price_per_unit": 0.03244, #This parameter is only required for a 'limit_order'
"total_quantity": 400, #Replace this with the quantity you want
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/orders/create"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Make sure to replace API key and API secret with your own.
14/192
payload = parameters-object -> JSON encode
The signature is the hex digest of an HMAC-SHA256 hash where the message is
your payload, and the secret key is your API secret.
signature = HMAC-SHA256(payload, api-secret).digest('hex')
After this, You will have to add following headers into all the authenticated requests
X-AUTH-APIKEY your-api-key
X-AUTH-SIGNATURE signature
You must replace your-api-key and signature with your personal API key and
generated signature respectively.
User
Get balances
15/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/users/balances"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
[
{
"currency": "BTC",
"balance": 1.167,
"locked_balance": 2.1
}
]
16/192
This endpoint retrieves account's balances.
HTTP Request
POST /exchange/v1/users/balances
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/users/info"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
17/192
Response:
[
{
"coindcx_id": "fda259ce-22fc-11e9-ba72-ef9b29b5db2b",
"first_name": "First name",
"last_name": "Last name",
"mobile_number": "000000000",
"email": "[email protected]"
}
]
HTTP Request
POST /exchange/v1/users/info
For security reasons, this endpoint would only be available to users who have created an
API key post 12th August, 2024.
HTTP Request
POST https://api.coindcx.com/exchange/v1/wallets/sub_account_transfer
Request Defnitions
18/192
to_account_id String YES The account to which assets are being
transferred (main or sub-account ID)
Status
Code Message Reason
422 Your withdrawals are blocked for another XX User is under surveillance
hours because you changed your account
authentication mode
19/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "xxx"
secret = "xxx"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
# secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp, # EPOCH timestamp in seconds
"from_account_id": "xxxxx",
"to_account_id": "yyyyy",
"currency_short_name": "USDT",
"amount": 1,
}
url = "https://api.coindcx.com/exchange/v1/wallets/sub_account_transfer"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response
{
"status": "success",
"message": 200,
"code": 200
}
20/192
Wallet Transfer
Using this endpoint,master account can carry out the following fund transfers:
HTTP Request
POST https://api.coindcx.com/exchange/v1/wallets/transfer
Request Defnitions
Status
Code Message Reason
422 Derivatives Futures Wallet creation is not Futures wallet creation not
allowed for currency_short_name: allowed for currency
<currency_short_name>
422 This feature is not enabled yet. Futures wallet not enabled for
user
21/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "xxx"
secret = "xxx"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
# secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp, # EPOCH timestamp in seconds
"source_wallet_type": "futures",
"destination_wallet_type": "spot",
"currency_short_name": "USDT",
"amount": 1,
}
url = "https://api.coindcx.com/exchange/v1/wallets/transfer"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response
{
"status": "success",
"message": 200,
"code": 200
}
22/192
Order
Enum definitions for the purpose of order are as follows:
Name Values
ecode I, B, HB, KC
New order
23/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"side": "buy", #Toggle between 'buy' or 'sell'.
"order_type": "limit_order", #Toggle between a 'market_order' or 'limit_order'.
"market": "SNTBTC", #Replace 'SNTBTC' with your desired market pair.
"price_per_unit": 0.03244, #This parameter is only required for a 'limit_order'
"total_quantity": 400, #Replace this with the quantity you want
"timestamp": timeStamp,
"client_order_id": "2022.02.14-btcinr_1" #Replace this with the client order id
you want
}
url = "https://api.coindcx.com/exchange/v1/orders/create"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
24/192
{
"orders":[
{
"id":"ead19992-43fd-11e8-b027-bb815bcb14ed",
"client_order_id": "2022.02.14-btcinr_1",
"market":"TRXETH",
"order_type":"limit_order",
"side":"buy",
"status":"open",
"fee_amount":0.0000008,
"fee":0.1,
"total_quantity":2,
"remaining_quantity":2.0,
"avg_price":0.0,
"price_per_unit":0.00001567,
"created_at":"2018-04-19T18:17:28.022Z",
"updated_at":"2018-04-19T18:17:28.022Z"
}
]
}
You can only have a maximum of 25 open orders at a time for one specific market
HTTP Request
POST /exchange/v1/orders/create
Request Parameters
Response Parameters
25/192
Name Description
status This tells the current status of the order. For example: When the
order firstly is placed, the status shows open
fee_amount Amount of fee charged to the user if the order gets executed and
moved to the filled status
avg_price The price on which the user's order gets executed, it's 0.0 when
order is in open status
updated_at It's a time when anything related to the order was updated. For
example avg_price, total_quantity, status etc
26/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"orders": [
{
"side": "buy", #Toggle between 'buy' or 'sell'.
"order_type": "limit_order", #Toggle between a 'market_order' or
'limit_order'.
"market": "SNTBTC", #Replace 'SNTBTC' with your desired market pair.
"price_per_unit": 0.03244, #This parameter is only required for a
'limit_order'
"total_quantity": 400, #Replace this with the quantity you want
"timestamp": timeStamp,
"ecode": "I",
"client_order_id": "2022.02.14-btcinr_1" #Replace this with the client order
id you want
},
{
"side": "buy", #Toggle between 'buy' or 'sell'.
"order_type": "limit_order", #Toggle between a 'market_order' or
'limit_order'.
"market": "SNTBTC", #Replace 'SNTBTC' with your desired market pair.
"price_per_unit": 0.03244, #This parameter is only required for a
'limit_order'
"total_quantity": 400, #Replace this with the quantity you want
"timestamp": timeStamp,
"ecode": "I"
}
]
}
url = "https://api.coindcx.com/exchange/v1/orders/create_multiple"
27/192
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
{
"orders":[
{
"id":"ead19992-43fd-11e8-b027-bb815bcb14ed",
"client_order_id": "2022.02.14-btcinr_1",
"market":"TRXETH",
"order_type":"limit_order",
"side":"buy",
"status":"open",
"fee_amount":0.0000008,
"fee":0.1,
"total_quantity":2,
"remaining_quantity":2.0,
"avg_price":0.0,
"price_per_unit":0.00001567,
"created_at":"2018-04-19T18:17:28.022Z",
"updated_at":"2018-04-19T18:17:28.022Z"
}
]
}
HTTP Request
POST /exchange/v1/orders/create_multiple
28/192
Name Required Example Description
Order status
29/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"id": "ead19992-43fd-11e8-b027-bb815bcb14ed", # Enter your Order ID here.
# "client_order_id": "2022.02.14-btcinr_1", # Enter your Client Order ID here.
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/orders/status"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
30/192
{
"id":"ead19992-43fd-11e8-b027-bb815bcb14ed",
"client_order_id": "2022.02.14-btcinr_1",
"market":"TRXETH",
"order_type":"limit_order",
"side":"buy",
"status":"open",
"fee_amount":0.0000008,
"fee":0.1,
"total_quantity":2,
"remaining_quantity":2.0,
"avg_price":0.0,
"price_per_unit":0.00001567,
"created_at":"2018-04-19T18:17:28.022Z",
"updated_at":"2018-04-19T18:17:28.022Z"
}
HTTP Request
POST /exchange/v1/orders/status
Parameters
31/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
# "ids": ["8a2f4284-c895-11e8-9e00-5b2c002a6ff4", "8a1d1e4c-c895-11e8-9dff-
df1480546936"], # Array of Order ids
"client_order_ids": ["2022.02.14-btcinr_1", "2022.02.14-btcinr_2"], # Array of
Client Order ids
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/orders/status_multiple"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
32/192
[
{
"id":"ead19992-43fd-11e8-b027-bb815bcb14ed",
"client_order_id": "2022.02.14-btcinr_1",
"market":"TRXETH",
"order_type":"limit_order",
"side":"buy",
"status":"open",
"fee_amount":0.0000008,
"fee":0.1,
"total_quantity":2,
"remaining_quantity":2.0,
"avg_price":0.0,
"price_per_unit":0.00001567,
"created_at":"2018-04-19T18:17:28.022Z",
"updated_at":"2018-04-19T18:17:28.022Z"
}
]
HTTP Request
POST /exchange/v1/orders/status_multiple
Parameters
Active orders
33/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"side": "buy", # Toggle between a 'buy' or 'sell' order.
"market": "SNTBTC", # Replace 'SNTBTC' with your desired market pair.
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/orders/active_orders"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
34/192
[
{
"id":"ead19992-43fd-11e8-b027-bb815bcb14ed",
"client_order_id": "2022.02.14-btcinr_1",
"market":"TRXETH",
"order_type":"limit_order",
"side":"buy",
"status":"open",
"fee_amount":0.0000008,
"fee":0.1,
"total_quantity":2,
"remaining_quantity":2.0,
"avg_price":0.0,
"price_per_unit":0.00001567,
"created_at":"2018-04-19T18:17:28.022Z",
"updated_at":"2018-04-19T18:17:28.022Z"
}
]
HTTP Request
POST /exchange/v1/orders/active_orders
Parameters
side No buy
35/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"from_id": 352622,
"limit": 50,
"timestamp": timeStamp,
"sort": "asc",
"from_timestamp": 1514745000000, # replace this with your from timestamp filter
"to_timestamp": 1514745000000, # replace this with your to timestamp filter
"symbol": "BCHBTC" # replace this with your symbol filter
}
url = "https://api.coindcx.com/exchange/v1/orders/trade_history"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
36/192
[
{
"id": 564389,
"order_id": "ee060ab6-40ed-11e8-b4b9-3f2ce29cd280",
"side": "buy",
"fee_amount": "0.00001129",
"ecode": "B",
"quantity": 67.9,
"price": 0.00008272,
"symbol": "SNTBTC",
"timestamp": 1533700109811
}
]
HTTP Request
POST /exchange/v1/orders/trade_history
Parameters
37/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"side": "buy", # Toggle between a 'buy' or 'sell' order.
"market": "SNTBTC", # Replace 'SNTBTC' with your desired market pair.
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/orders/active_orders_count"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
38/192
HTTP Request
POST /exchange/v1/orders/active_orders_count
Parameters
side No buy
Cancel all
39/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"side": "buy", # Toggle between a 'buy' or 'sell' order.
"market": "SNTBTC", # Replace 'SNTBTC' with your desired market pair.
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/orders/cancel_all"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
Use this endpoint to cancel multiple active orders in a single API call
HTTP Request
POST /exchange/v1/orders/cancel_all
40/192
Parameters
side No buy
Sending side param is optional. You may cancel all the sell orders of SNTBTC by sending
{market: "SNTBTC", side : "sell"}
41/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"ids": ["8a2f4284-c895-11e8-9e00-5b2c002a6ff4", "8a1d1e4c-c895-11e8-9dff-
df1480546936"]
# "client_order_ids": ["2022.02.14-btcinr_1", "2022.02.14-btcinr_2"] # Array of
client_order_ids
}
url = "https://api.coindcx.com/exchange/v1/orders/cancel_by_ids"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
Use this endpoint to cancel multiple active orders in a single API call
HTTP Request
42/192
POST /exchange/v1/orders/cancel_by_ids
Parameters
Cancel
43/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from CoinDCX website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"id": "ead19992-43fd-11e8-b027-bb815bcb14ed", # Enter your Order ID here.
# "client_order_id": "2022.02.14-btcinr_1", # Enter your Client Order ID here.
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/orders/cancel"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
HTTP Request
POST /exchange/v1/orders/cancel
44/192
Parameters
Edit Price
45/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from CoinDCX website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", # Enter your Order ID here.
"timestamp": timeStamp,
"price_per_unit": 123.45 # Enter the new-price here
}
url = "https://api.coindcx.com/exchange/v1/orders/edit"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
46/192
{
"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"market": "TRXETH",
"order_type": "limit_order",
"side": "buy",
"status": "open",
"fee_amount": 0.0000008,
"fee": 0.1,
"total_quantity": 2,
"remaining_quantity": 2.0,
"avg_price": 0.0,
"price_per_unit": 123.45,
"created_at": "2020-12-12T18:17:28.022Z",
"updated_at": "2020-12-12T18:17:28.022Z"
}
HTTP Request
POST /exchange/v1/orders/edit
Parameters
Lend Order
Fetch Orders
This API supports Pagination Refer Pagination section for more details
47/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/funding/fetch_orders"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
48/192
[ { "id": "caa1e032-5763-42a5-9684-587bc1a846d8",
"currency_short_name": "USDT",
"amount": 0.01,
"title": "Tether",
"interest": 0.1,
"interest_type": "simple",
"duration": 8,
"side": "lend",
"expiry": 1564666811940,
"status": "close",
"created_at": 1563975611942,
"settled_at": 1565615166177 },
{ "id": "1212ad3d-8a5b-4965-9d21-151efc0c84d7",
"currency_short_name": "BTC",
"amount": 0.01,
"title": "Bitcoin",
"interest": 0.1,
"interest_type": "simple",
"duration": 8,
"side": "lend",
"expiry": 1564666764834,
"status": "close",
"created_at": 1563975564836,
"settled_at": 1563975597184 } ]
HTTP Request
POST /exchange/v1/funding/fetch_orders
Parameters
Lend
49/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"currency_short_name": "BTC",
"duration": 20,
"amount": 0.5,
"timestamp": timeStamp
}
json_body = json.dumps(body, separators = (',', ':'))
url = "https://api.coindcx.com/exchange/v1/funding/lend"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
50/192
[ { "id": "df7d9640-29e8-4731-9fc6-ec2f738507e2",
"currency_short_name": "XRP",
"amount": 11,
"interest": 0.05,
"title": "Ripple",
"interest_type": "simple",
"duration": 20,
"side": "lend",
"expiry": 1576069883995,
"status": "open",
"created_at": 1574341883998,
"settled_at": null } ]
HTTP Request
POST /exchange/v1/funding/lend
Parameters
Settle
51/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from CoinDCX website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"id": "ead19992-43fd-11e8-b027-bb815bcb14ed",
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/funding/settle"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
52/192
[ { "id": "df7d9640-29e8-4731-9fc6-ec2f738507e2",
"currency_short_name": "XRP",
"amount": 11,
"interest": 0.05,
"title": "Ripple",
"interest_type": "simple",
"duration": 20,
"side": "lend",
"expiry": 1576069883995,
"status": "exit",
"created_at": 1574341883998,
"settled_at": 1574342058493 } ]
HTTP Request
POST /exchange/v1/funding/settle
Parameters
Margin Order
Set ecode parameter to B for all the api calls wherever necessary
Enum definitions for the purpose of order are as follows:
Name Values
timestamp 1524211224
53/192
Name Values
ecode B
Place Order
54/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"side": "buy",
"order_type": "limit_order",
"market": "XRPBTC",
"price": 0.000025,
"quantity": 90,
"ecode": 'B',
"leverage": 1.0,
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/margin/create"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
55/192
[{
"id": "30b5002f-d9c1-413d-8a8d-0fd32b054c9c",
"side": "sell",
"status": "init",
"market": "XRPBTC",
"order_type": "limit_order",
"trailing_sl": false,
"trail_percent": null,
"avg_entry": 0,
"avg_exit": 0,
"fee": 0.02,
"entry_fee": 0,
"exit_fee": 0,
"active_pos": 0,
"exit_pos": 0,
"total_pos": 0,
"quantity": 200,
"price": 0.000026,
"sl_price": 0.00005005,
"target_price": 0,
"stop_price": 0,
"pnl": 0,
"initial_margin": 0.00520208,
"interest": 0.05,
"interest_amount": 0,
"leverage": 1,
"result": null,
"created_at": 1568122929782,
"updated_at": 1568122929782,
"orders":[{
"id": 164993,
"order_type": "limit_order",
"status": "initial",
"market": "XRPBTC",
"side": "sell",
"avg_price": 0,
"total_quantity": 200,
"remaining_quantity": 200,
"price_per_unit": 0.000026,
"timestamp": 1568122929880.75,
"fee": 0.02,
"fee_amount": 0,
"filled_quantity": 0,
"bo_stage": "stage_entry",
"cancelled_quantity": 0,
"stop_price": 0
}]
}]
You can only have a maximum of 10 open orders at a time for one specific market
HTTP Request
56/192
POST /exchange/v1/margin/create
Parameters
Cancel Order
Any order with order_status among the following can only be cancelled:
init, partial_entry, or triggered
57/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"id": "ead19992-43fd-11e8-b027-bb815bcb14ed",
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/margin/cancel"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
{
"message": "Cancellation accepted",
"status": 200,
"code": 200
}
58/192
HTTP Request
POST /exchange/v1/margin/cancel
Parameters
Exit
Any order with order_status among the following can only be exited:
open or partial_close
59/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from CoinDCX website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"id": "ead19992-43fd-11e8-b027-bb815bcb14ed",
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/margin/exit"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
{
"message": "Order exit accepted",
"status": 200,
"code": 200
}
60/192
HTTP Request
POST /exchange/v1/margin/exit
Parameters
Edit Target
You can update target price only if order has 0 or 1 target order. For the multiple open
targets refer- Edit Price of Target Order section
61/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"id": "8a2f4284-c895-11e8-9e00-5b2c002a6ff4",
"target_price": 0.6,
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/margin/edit_target"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
{
"message": "Target price updated",
"status": 200,
"code": 200
}
62/192
Use this endpoint to edit the target price of any order.
HTTP Request
POST /exchange/v1/margin/edit_target
Parameters
63/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"id": "",
"target_price": 0.00026,
"itpo_id": "",
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/margin/edit_price_of_target_order"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
{
"message": "Target price updated",
"status": 200,
"code": 200
}
64/192
Use this endpoint to edit price of internal target order.
HTTP Request
POST /exchange/v1/margin/edit_price_of_target_order
Parameters
Edit SL Price
Only for orders where trailing_sl is false
65/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"id" : "",
"sl_price": 0.06,
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/margin/edit_sl"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
{
"message": "SL price updated",
"status": 200,
"code": 200
}
HTTP Request
66/192
POST /exchange/v1/margin/edit_sl
Parameters
67/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"id" : "",
"sl_price": 0.06,
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/margin/edit_trailing_sl"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response
{
"message": "Trailing SL price updated",
"status": 200,
"code": 200
}
Use this endpoint to edit stop loss price of a trailing stop loss order.
HTTP Request
68/192
POST /exchange/v1/margin/edit_trailing_sl
Parameters
Add Margin
69/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"id" : "",
"amount": 0.06,
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/margin/add_margin"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response
{
"message": "Margin added successfully",
"status": 200,
"code": 200
}
Use this endpoint to add a particular amount to your margin order, decreasing the
effective leverage.
70/192
HTTP Request
POST /exchange/v1/margin/add_margin
Parameters
Remove Margin
71/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"id" : "",
"amount": 0.06, initial margin.
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/margin/remove_margin"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response
{
"message": "Margin removed successfully",
"status": 200,
"code": 200
}
Use this endpoint to remove a particular amount from your Margin order, increasing the
effective leverage.
72/192
HTTP Request
POST /exchange/v1/margin/remove_margin
Parameters
Fetch Orders
This API supports Pagination Refer Pagination section for more details
73/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"details": True,
"market": "LTCBTC",
"status":"close",
"size":20,
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/margin/fetch_orders"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
74/192
[{
"id": "30b5002f-d9c1-413d-8a8d-0fd32b054c9c",
"side": "sell",
"status": "rejected",
"market": "XRPBTC",
"order_type": "limit_order",
"trailing_sl": false,
"trail_percent": null,
"avg_entry": 0,
"avg_exit": 0,
"fee": 0.02,
"entry_fee": 0,
"exit_fee": 0,
"active_pos": 0,
"exit_pos": 0,
"total_pos": 0,
"quantity": 200,
"price": 0.000026,
"sl_price": 0.00005005,
"target_price": 0,
"stop_price": 0,
"pnl": 0,
"initial_margin": 0,
"interest": 0.05,
"interest_amount": 0,
"leverage": 1,
"result": null,
"created_at": 1568122929782,
"updated_at": 1568122930404,
"orders": [{
"id": 164993,
"order_type": "limit_order",
"status": "rejected",
"market": "XRPBTC",
"side": "sell",
"avg_price": 0,
"total_quantity": 200,
"remaining_quantity": 200,
"price_per_unit": 0.000026,
"timestamp": 1568122929880.75,
"fee": 0.02,
"fee_amount": 0,
"filled_quantity": 0,
"bo_stage": "stage_entry",
"cancelled_quantity": 0,
"stop_price": 0
}]
},
{
"id": "e45cd26a-32e9-4d20-b230-a8933046f4eb",
"side": "sell",
"status": "rejected",
"market": "XRPBTC",
"order_type": "limit_order",
"trailing_sl": false,
75/192
"trail_percent": null,
"avg_entry": 0,
"avg_exit": 0,
"fee": 0.02,
"entry_fee": 0,
"exit_fee": 0,
"active_pos": 0,
"exit_pos": 0,
"total_pos": 0,
"quantity": 200,
"price": 0.000026,
"sl_price": 0.00005005,
"target_price": 0,
"stop_price": 0,
"pnl": 0,
"initial_margin": 0,
"interest": 0.05,
"interest_amount": 0,
"leverage": 1,
"result": null,
"created_at": 1568122721421,
"updated_at": 1568122721905,
"orders": [{
"id": 164993,
"order_type": "limit_order",
"status": "rejected",
"market": "XRPBTC",
"side": "sell",
"avg_price": 0,
"total_quantity": 200,
"remaining_quantity": 200,
"price_per_unit": 0.000026,
"timestamp": 1568122929880.75,
"fee": 0.02,
"fee_amount": 0,
"filled_quantity": 0,
"bo_stage": "stage_entry",
"cancelled_quantity": 0,
"stop_price": 0
}]
}
]
Use this endpoint to fetch orders and optionally its details which include all buy/sell
related orders
HTTP Request
POST /exchange/v1/margin/fetch_orders
Parameters
76/192
Name Type Required Example Description
Query Order
77/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp.
timeStamp = int(round(time.time() * 1000))
body = {
"details": true,
"id": "30b5002f-d9c1-413d-8a8d-0fd32b054c9c",
"timestamp": timeStamp
}
url = "https://api.coindcx.com/exchange/v1/margin/order"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response:
78/192
[{
"id": "30b5002f-d9c1-413d-8a8d-0fd32b054c9c",
"side": "sell",
"status": "rejected",
"market": "XRPBTC",
"order_type": "limit_order",
"trailing_sl": false,
"trail_percent": null,
"avg_entry": 0,
"avg_exit": 0,
"fee": 0.02,
"entry_fee": 0,
"exit_fee": 0,
"active_pos": 0,
"exit_pos": 0,
"total_pos": 0,
"quantity": 200,
"price": 0.000026,
"sl_price": 0.00005005,
"target_price": 0,
"stop_price": 0,
"pnl": 0,
"initial_margin": 0,
"interest": 0.05,
"interest_amount": 0,
"leverage": 1,
"result": null,
"created_at": 1568122929782,
"updated_at": 1568122930404,
"orders": [{
"id": 164993,
"order_type": "limit_order",
"status": "rejected",
"market": "XRPBTC",
"side": "sell",
"avg_price": 0,
"total_quantity": 200,
"remaining_quantity": 200,
"price_per_unit": 0.000026,
"timestamp": 1568122929880.75,
"fee": 0.02,
"fee_amount": 0,
"filled_quantity": 0,
"bo_stage": "stage_entry",
"cancelled_quantity": 0,
"stop_price": 0
}]
}
]
Use this endpoint to query specific order and optionally its details.
HTTP Request
79/192
POST /exchange/v1/margin/order
Parameters
Pagination
Get the pagination details in the response header
Parameters
Name Description
Response Headers
Spot Sockets
There are two types of channels
PUBLIC
80/192
81/192
import socketio
def my_headers():
return {"origin": "*"}
socketEndpoint = 'https://stream.coindcx.com'
sio = socketio.Client()
# leave a channel
sio.emit('leave', { 'channelName' : channelName })
# Successfull connection
@sio.event
def connect():
sio.emit('join', { 'channelName': 'channelName' })
print("I'm connected!")
# Connection error
@sio.event
def connect_error(data):
print("The connection failed!")
Definitions
Response
id: Wallet Id
balance: usable balance
locked_balance: balance currently being used by an open order
currency_short_name: currency like LTC, BTC etc.
82/192
import socketio
import hmac
import hashlib
import json
socketEndpoint = 'wss://stream.coindcx.com'
sio = socketio.Client()
key = "xxx"
secret = "xxx"
@sio.event
def connect():
print("I'm connected!")
sio.emit('join', {'channelName': channelName, 'authSignature': signature,
'apiKey': key})
@sio.on('balance-update')
def on_message(response):
print("balance-update Response !!!")
print(response)
def main():
try:
sio.connect(socketEndpoint, transports='websocket')
while True:
sio.event('balance-update', {'channelName': channelName})
except Exception as e:
print(f"Error connecting to the server: {e}")
raise
[
{
"id":"102a7916-a622-11ee-bd36-479d3cf6751b",
"balance":"265.01745775027309",
"locked_balance":"258.600771",
"currency_id":"cfe01e2a-f1af-4e52-9696-9a19d9a8eb4f",
"currency_short_name":"INR"
}
]
83/192
Get Order Update
Definitions
Response
84/192
import socketio
import hmac
import hashlib
import json
socketEndpoint = 'wss://stream.coindcx.com'
sio = socketio.Client()
key = "xxx"
secret = "xxx"
@sio.event
def connect():
print("I'm connected!")
sio.emit('join', {'channelName': channelName, 'authSignature': signature,
'apiKey': key})
@sio.on('order-update')
def on_message(response):
print("order-update Response !!!")
print(response)
def main():
try:
sio.connect(socketEndpoint, transports='websocket')
while True:
sio.event('order-update', {'channelName': channelName})
except Exception as e:
print(f"Error connecting to the server: {e}")
raise
85/192
[
{
"id":"f6b68656-091c-11ef-92dc-67ec5900cddc",
"client_order_id":null,
"order_type":"market_order",
"side":"buy",
"status":"filled",
"fee_amount":1.286714,
"fee":0.5,
"maker_fee":0.5,
"taker_fee":0.5,
"total_quantity":2.86,
"remaining_quantity":0,
"source":"web",
"base_currency_name":"Indian Rupee",
"target_currency_name":"Tether",
"base_currency_short_name":"INR",
"target_currency_short_name":"USDT",
"base_currency_precision":2,
"target_currency_precision":2,
"avg_price":89.98,
"price_per_unit":89.97,
"stop_price":0,
"market":"USDTINR",
"time_in_force":"good_till_cancel",
"created_at":1714720547465,
"updated_at":1714720547805
}
]
Definitions
Response
86/192
e: exchange identifier
x: status
import socketio
import hmac
import hashlib
import json
socketEndpoint = 'wss://stream.coindcx.com'
sio = socketio.Client()
key = "xxx"
secret = "xxx"
@sio.event
def connect():
print("I'm connected!")
sio.emit('join', {'channelName': channelName, 'authSignature': signature,
'apiKey': key})
@sio.on('trade-update')
def on_message(response):
print("trade-update Response !!!")
print(response)
def main():
try:
sio.connect(socketEndpoint, transports='websocket')
while True:
sio.event('trade-update', {'channelName': channelName})
except Exception as e:
print(f"Error connecting to the server: {e}")
raise
87/192
[
{
"o":"f6b68656-091c-11ef-92dc-67ec5900cddc",
"c":null,
"t":"108263519",
"s":"USDTINR",
"p":"89.98",
"q":"2.86",
"T":1714720547635.6172,
"m":false,
"f":"1.286714",
"e":"I",
"x":"filled"
}
]
Definitions
Response
t: start timestamp
T: close timestamp
s: symbol
i: candle period
f : first trade ID
L: last trade ID
o: open
c: close
h: high
l: low
v: Base asset volume
n: number of trades
x: current candle has been completed Y/N
q: completed trade amount (in quote asset)
V: Taker buy base asset volume
Q: taker trade amount(in quote asset)
88/192
B: first trade ID
ecode: exchange code
channel: Channel Name
pr: product
import socketio
socketEndpoint = 'wss://stream.coindcx.com'
sio = socketio.Client()
@sio.event
def connect():
print("I'm connected!")
sio.emit('join', {'channelName': "B-BTC_USDT_1m"})
@sio.on('candlestick')
def on_message(response):
print("candlestick Response !!!")
print(response)
def main():
try:
sio.connect(socketEndpoint, transports='websocket')
while True:
sio.event('candlestick', {'channelName': "B-BTC_USDT_1m"})
except Exception as e:
print(f"Error connecting to the server: {e}")
raise
89/192
{
"t": 1717075560000,
"T": 1717075619999,
"s": "BTCUSDT",
"i": "1m",
"f": 3619173860,
"L": 3619175261,
"o": "68292.00000000",
"c": "68273.44000000",
"h": "68292.00000000",
"l": "68273.43000000",
"v": "10.37494000",
"n": 1402,
"x": false,
"q": "708461.81457520",
"V": "0.38858000",
"Q": "26534.68106390",
"B": "0",
"ecode": "B",
"channel": "B-BTC_USDT_1m",
"pr": "spot"
}
Definitions
Channel: {pair}@orderbook@20 ( Use 'pair' from Markets details API response. )
Event: depth-snapshot
Description: This event gives the changes in the orderbook data of the pair as a
snapshot.
Response
vs: version
ts: timestamp
pr: product
s: symbol(currency)
90/192
import socketio
socketEndpoint = 'wss://stream.coindcx.com'
sio = socketio.Client()
@sio.event
def connect():
print("I'm connected!")
sio.emit('join', {'channelName': "B-BTC_USDT@orderbook@20"})
@sio.on('depth-snapshot')
def on_message(response):
print("depth-snapshot Response !!!")
print(response)
def main():
try:
sio.connect(socketEndpoint, transports='websocket')
while True:
sio.event('depth-snapshot', {'channelName': "B-
BTC_USDT@orderbook@20"})
except Exception as e:
print(f"Error connecting to the server: {e}")
raise
91/192
{
"ts":1715885479864,
"vs":35623836,
"asks":{
"65110":"0.2561",
"65114":"0.0786",
"65109.99":"0.09215",
"65110.8":"0.00998",
"65110.91":"0.01037",
"65111.02":"0.00215",
"65111.24":"0.00461"
},
"bids":{
"65108":"0.0786",
"65109":"0.00008",
"65109.98":"12.5249",
"65109.84":"0.09215",
"65109.31":"0.00015",
"65109.29":"0.2"
},
"pr":"spot",
"s":"BTCUSDT"
}
Definitions
Channel: {pair}@orderbook@20 ( Use 'pair' from Markets details API response. )
Event: depth-update
Description: This Event gives the changes in the orderbook data of the pair when
the depth of the orderbook changes.
Response
vs: version
ts: timestamp
pr: product
E: Event time
s: symbol(currency)
92/192
import socketio
socketEndpoint = 'wss://stream.coindcx.com'
sio = socketio.Client()
@sio.event
def connect():
print("I'm connected!")
sio.emit('join', {'channelName': "B-BTC_USDT@orderbook@20"})
@sio.on('depth-update')
def on_message(response):
print("depth-update Response !!!")
print(response)
def main():
try:
sio.connect(socketEndpoint, transports='websocket')
while True:
sio.event('depth-update', {'channelName': "B-BTC_USDT@orderbook@20"})
except Exception as e:
print(f"Error connecting to the server: {e}")
raise
93/192
{
"ts":1714653301197,
"vs":10037615,
"asks":{
"0.10828":"260",
"0.10834":"9866.0606",
"0.1085":"23769.6456",
"0.10899":"347.2024",
"0.109":"133711.3629",
"0.10901":"32941.0265",
"0.10829":"0.0",
"0.10836":"0.0",
"0.10838":"0.0",
"0.10845":"0.0"
},
"bids":{
"0.10758":"38692.1224",
"0.10757":"23141",
"0.10747":"1731.4441",
"0.10736":"0.0"
},
"E":1714653301194,
"pr":"spot",
"s":"BTCUSDT"
}
Definitions
Channel: currentPrices@spot@10s
Event: currentPrices@spot#update
Description: This Event gives the current prices of the pairs whose price got
updated in the last 1s/10s.
Response
vs: version
ts: timestamp
pr: product
94/192
import socketio
socketEndpoint = 'wss://stream.coindcx.com'
sio = socketio.Client()
@sio.event
def connect():
print("I'm connected!")
sio.emit('join', {'channelName': "currentPrices@spot@10s"})
@sio.on('currentPrices@spot#update')
def on_message(response):
print("currentPrices@spot#update Response !!!")
print(response)
def main():
try:
sio.connect(socketEndpoint, transports='websocket')
while True:
sio.event('currentPrices@spot#update', {'channelName':
"currentPrices@spot@10s"})
except Exception as e:
print(f"Error connecting to the server: {e}")
raise
{
"vs":6114777,
"ts":1714653300622,
"pr":"spot",
"prices":{
"XAUTUSDT":2307.77,
"INJUSDT":23.35,
"ONGUSDT":0.5334,
"MOVRUSDT":12.335,
"TRACUSDT":0.8529,
"HIFLUFUSDT":0.001513,
"BEAMXUSDT":0.0237,
"BABYUSDT":0.002283,
"SAOUSDT":0.002034,
"CVXUSDT":2.478
}
}
95/192
Get Price Stats
priceStats@spot@60s, Here 60 denotes, the interval at which the prices can be fetched.
Definitions
Channel: priceStats@spot@60s
Event: priceStats@spot#update
Description: This Event gives the 24hrs price change of pairs whose price got
updated in the last 60s.
Response
vs: version
ts: timestamp
pr: product
pc: price change percent
v: volume 24h
import socketio
socketEndpoint = 'wss://stream.coindcx.com'
sio = socketio.Client()
@sio.event
def connect():
print("I'm connected!")
sio.emit('join', {'channelName': "priceStats@spot@60s"})
@sio.on('priceStats@spot#update')
def on_message(response):
print("priceStats@spot#update Response !!!")
print(response)
def main():
try:
sio.connect(socketEndpoint, transports='websocket')
while True:
sio.event('priceStats@spot#update', {'channelName':
"priceStats@spot@60s"})
except Exception as e:
print(f"Error connecting to the server: {e}")
raise
96/192
Get Price Stat response:
{
"vs":1006039,
"ts":1716358680710,
"pr":"spot",
"stats":{
"HISAND33USDT":{
"v":4074970.9761
},
"ENSUSDT":{
"pc":3.48,
"v":103333815.5488
},
"DOTBTC":{
"v":16.52801718,
"pc":2.647
},
"ISLMUSDT":{
"v":10588293.415
}
}
}
Definitions
Channel: {pair}@trades
Event: new-trade
Description: This Event gives the latest trade info of the given pair.
Response
97/192
import socketio
socketEndpoint = 'wss://stream.coindcx.com'
sio = socketio.Client()
@sio.event
def connect():
print("I'm connected!")
sio.emit('join', {'channelName': "B-BTC_USDT@trades"})
@sio.on('new-trade')
def on_message(response):
print("new-trade Response !!!")
print(response)
def main():
try:
sio.connect(socketEndpoint, transports='websocket')
while True:
sio.event('new-trade', {'channelName': "B-BTC_USDT@trades"})
except Exception as e:
print(f"Error connecting to the server: {e}")
raise
{
"T":"1714653304357",
"p":"0.10804",
"q":"1050.4254",
"m":0,
"s":"B-BTC_USDT",
"pr":"spot"
}
Definitions
Channel: {pair}@prices
Event: price-change
Description: This Event gives the latest price info of a pair whenever there is a
price change.
98/192
Response
p: trade price
T: timestamp of trade
pr: Product(spot)
import socketio
socketEndpoint = 'wss://stream.coindcx.com'
sio = socketio.Client()
@sio.event
def connect():
print("I'm connected!")
sio.emit('join', {'channelName': "B-BTC_USDT@prices"})
@sio.on('price-change')
def on_message(response):
print("price-change Response !!!")
print(response)
def main():
try:
sio.connect(socketEndpoint, transports='websocket')
while True:
sio.event('price-change', {'channelName': "B-BTC_USDT@prices"})
except Exception as e:
print(f"Error connecting to the server: {e}")
raise
{
"T":"1714653304357",
"p":"0.10804",
"pr":"spot"
}
Note
99/192
Only Private channels need authentication.
Python Packages Required : python-socketio[client]
APPLE MAC Issue : Certificate verify failed: unable to get local issuer certificate or
Mac OSX python ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate
verify failed (_ssl.c:749) -> Fix for the issue : Will be fixed by installing the
"Install Certificates.command"
100/192
import socketio
import hmac
import hashlib
import json
import time
import asyncio
from datetime import datetime
socketEndpoint = 'wss://stream.coindcx.com'
sio = socketio.AsyncClient(logger=True, engineio_logger=True)
key = "xxx"
secret = "xxx"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
channelName = "coindcx"
body = {"channel": channelName}
json_body = json.dumps(body, separators=(',', ':'))
signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()
@sio.event
async def connect():
print("I'm connected!")
# Get the current time
current_time = datetime.now()
@sio.on('balance-update')
async def on_message(response):
# Get the current time
current_time = datetime.now()
101/192
async def main():
try:
await sio.connect(socketEndpoint, transports='websocket')
# Wait for the connection to be established
asyncio.create_task(ping_task())
await sio.wait()
while True:
time.sleep(1)
sio.event('balance-update', {'channelName': "coindcx"})
except Exception as e:
print(f"Error connecting to the server: {e}")
raise # re-raise the exception to see the full traceback
Response:
Glossary
e - is the Event type
p - price (LTP)
q - quantity (trade quantity)
pr - product (futures)
f - futures
s - spot
T - timestamp
m - is maker. Boolean value that would be true if its maker and false if its taker
RT - range timestamp
ts - timestamp
vs - version
Ets - event timestamp as given by TPE (applicable to candlesticks data)
i - Interval
E - event timestamp (applicable to order book data)
pST - price sent time
v - volume 24h
ls - last price
pc - price change percent
btST - TPE Tick send time
mp - mark price
102/192
bmST - TPE mark price send time (The timestamp at which Third-Party exchange
sent this event)
HTTP Request
GET
https://api.coindcx.com/exchange/v1/derivatives/futures/data/active_instrum
ents?margin_currency_short_name[]={futures_margin_mode}
import json
response = requests.get(url)
data = response.json()
print(json.dumps(data, indent=2))
Response
[
"B-VANRY_USDT",
"B-BOME_USDT",
"B-BTCDOM_USDT",
"B-IOTX_USDT",
"B-LPT_USDT",
"B-ENA_USDT",
"B-GMT_USDT",
"B-APE_USDT",
"B-WOO_USDT",
"B-ASTR_USDT",
"B-GMX_USDT",
"B-TLM_USDT",
]
103/192
HTTP Request
GET
https://api.coindcx.com/exchange/v1/derivatives/futures/data/instrument?
pair={instrument}&margin_currency_short_name={futures_margin_mode}
Response Defnitions
Key Description
104/192
max_quantity Maximum quantity to enter the position
105/192
dynamic_position_leverage_details Sample response: { "5":15000000.0,
"8":5000000.0, "10":1000000.0, "15":500000.0,
"20":100000.0, "25":50000.0 } This gives you the
max allowed leverage for a given position size.
So for example if your positions size is 120K
which is higher than 100K and less than 500K
USDT, then max allowed leverage is 15x
Response
106/192
{
"instrument":{
"settle_currency_short_name":"USDT",
"quote_currency_short_name":"USDT",
"position_currency_short_name":"AAVE",
"underlying_currency_short_name":"AAVE",
"status":"active",
"pair":"B-AAVE_USDT",
"kind":"perpetual",
"settlement":"never",
"max_leverage_long":10.0,
"max_leverage_short":10.0,
"unit_contract_value":1.0,
"price_increment":0.01,
"quantity_increment":0.1,
"min_trade_size":0.1,
"min_price":4.557,
"max_price":2878.2,
"min_quantity":0.1,
"max_quantity":950000.0,
"min_notional":6.0,
"maker_fee":0.025,
"taker_fee":0.075,
"safety_percentage":2.0,
"quanto_to_settle_multiplier":1.0,
"is_inverse":false,
"is_quanto":false,
"allow_post_only":false,
"allow_hidden":false,
"max_market_order_quantity":1250.0,
"funding_frequency":8,
"max_notional":320000.0,
"expiry_time":2548162800000,
"exit_only":false,
"multiplier_up":8.0,
"multiplier_down":8.0,
"liquidation_fee": 1.0,
"margin_currency_short_name": "USDT",
"time_in_force_options":[
"good_till_cancel",
"immediate_or_cancel",
"fill_or_kill"
],
"order_types":[
"market_order",
"limit_order",
"stop_limit",
"take_profit_limit",
"stop_market",
"take_profit_market"
],
"dynamic_position_leverage_details":{
"5":15000000.0,
"8":5000000.0,
"10":1000000.0,
107/192
"15":500000.0,
"20":100000.0,
"25":50000.0
},
"dynamic_safety_margin_details":{
"50000":1.5,
"100000":2.0,
"500000":3.0,
"1000000":5.0,
"5000000":6.0,
"15000000":10.0
}
}
}
HTTP Request
GET https://api.coindcx.com/exchange/v1/derivatives/futures/data/trades?
pair={instrument_name}
Response Defnitions
KEY DESCRIPTION
Response
108/192
[
{
"price": 1.1702,
"quantity": 22000,
"timestamp": 1675037938736,
"is_maker": true
},
{
"price": 1.1702,
"quantity": 38000,
"timestamp": 1675037950130,
"is_maker": true
}
]
HTTP Request
GET https://public.coindcx.com/market_data/v3/orderbook/{instrument}-
futures/50
Response Defnitions
KEY DESCRIPTION
ts Epoch timestamp
vs Version
url = "https://public.coindcx.com/market_data/v3/orderbook/{instrument}-
futures/50"
#sample_url = "public.coindcx.com/market_data/v3/orderbook/B-MKR_USDT-futures/50"
#Here 50 denotes, the depth of the order book the other possible values are 10 and
20
response = requests.get(url)
data = response.json()
print(data)
Response
109/192
{
"ts": 1705483019891,
"vs": 27570132,
"asks": {
"2001": "2.145",
"2002": "4.453",
"2003": "2.997"
},
"bids": {
"1995": "2.618",
"1996": "1.55"
}
}
HTTP Request
GET https://public.coindcx.com/market_data/candlesticks?pair={pair}&from=
{from}&to={to}&resolution={resolution}&pcode=f
Request Defnitions
resolution String YES '1' OR '5' OR '60' OR '1D' for 1min, 5min, 1hour,
1day respectively
pcode String YES Static value “f” to be used here. It denotes product =
futures
Response Defnitions
KEY DESCRIPTION
s status
open The first recorded trading price of the pair within that particular timeframe.
110/192
high The highest recorded trading price of the pair within that particular timeframe.
low The lowest recorded trading price of the pair within that particular timeframe.
close The last recorded trading price of the pair within that particular timeframe.
import requests
url = "https://public.coindcx.com/market_data/candlesticks"
query_params = {
"pair": "B-MKR_USDT",
"from": 1704100940,
"to": 1705483340,
"resolution": "1D", # '1' OR '5' OR '60' OR '1D'
"pcode": "f"
}
response = requests.get(url, params=query_params)
if response.status_code == 200:
data = response.json()
# Process the data as needed
print(data)
else:
print(f"Error: {response.status_code}, {response.text}")
Response
{
"s":"ok",
"data":[
{
"open":1654.2,
"high":1933.5,
"low":1616.5,
"volume":114433.544,
"close":1831.9,
"time":1704153600000
},
{
"open":1832.2,
"high":1961,
"low":1438,
"volume":158441.387,
"close":1807.6,
"time":1704240000000
}
]
}
List Orders
111/192
Use this endpoint to fetch the list of orders based on the status ( open,filled,cancelled )
and side ( buy OR sell )
HTTP Request
POST https://api.coindcx.com/exchange/v1/derivatives/futures/orders
Request Defnitions
Response Defnitions
Note : fee_amount and ideal_margin values are in USDT for INR Futures.
KEY DESCRIPTION
id Order id
112/192
status Order status. Possible values are:
OPEN - The order has been accepted
and is in open status
PARTIALLY_FILLED - Order which is
partially filled and the remaining quantity
is open
FILLED - The order has been
completely filled
CANCELED - The order has been
canceled
PARTIALLY_CANCELED - Order which
is partially filled and the remaining
quantity has been cancelled
REJECTED - The order was not
accepted by the system
UNTRIGGERED - TP or SL orders
which are not triggered yet
113/192
taker_fee Fee charged when the order is executed as
taker
114/192
created_at Timestamp at which the order was created
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp , # EPOCH timestamp in seconds
"status": "open", # Comma separated statuses as open,filled,cancelled
"side": "buy", # buy OR sell
"page": "1", #// no.of pages needed
"size": "10", #// no.of records needed
"margin_currency_short_name": ["INR", "USDT"]
}
url = "https://api.coindcx.com/exchange/v1/derivatives/futures/orders"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
115/192
Response
116/192
[
{
"id":"714d2080-1fe3-4c6e-ba81-9d2ac9a46003",
"pair":"B-ETH_USDT",
"side":"buy",
"status":"open",
"order_type":"limit_order",
"stop_trigger_instruction":"last_price",
"notification":"no_notification",
"leverage":20.0,
"maker_fee":0.025,
"taker_fee":0.075,
"fee_amount":0.0,
"price":2037.69,
"stop_price":0.0,
"avg_price":0.0,
"total_quantity":0.019,
"remaining_quantity":0.019,
"cancelled_quantity":0.0,
"ideal_margin":1.93870920825,
"order_category":"None",
"stage":"default",
"group_id":"None",
"liquidation_fee": null,
"position_margin_type": "crossed",
"display_message":"ETH limit buy order placed!",
"group_status":"None",
"metatags": null,
"created_at":1705565256365,
"updated_at":1705565256940,
"margin_currency_short_name": "INR",
"settlement_currency_conversion_price": 89.0
},
{
"id":"ffb261ae-8010-4cec-b6e9-c111e0cc0c10",
"pair":"B-ID_USDT",
"side":"buy",
"status":"filled",
"order_type":"market_order",
"stop_trigger_instruction":"last_price",
"notification":"no_notification",
"leverage":10.0,
"maker_fee":0.025,
"taker_fee":0.075,
"fee_amount":0.011181375,
"price":0.3312,
"stop_price":0.0,
"avg_price":0.3313,
"total_quantity":45.0,
"remaining_quantity":0.0,
"cancelled_quantity":0.0,
"ideal_margin":1.4926356,
"order_category":"None",
"stage":"default",
"group_id":"None",
117/192
"liquidation_fee": null,
"position_margin_type": "crossed",
"display_message":"ID market buy order filled!",
"group_status":"None",
"metatags": null,
"created_at":1705565061504,
"updated_at":1705565062462,
"margin_currency_short_name": "INR",
"settlement_currency_conversion_price": 89.0
}
]
Create Order
Use this endpoint to create an order by passing the necessary parameters.
HTTP Request
POST https://api.coindcx.com/exchange/v1/derivatives/futures/orders/create
NOTE
*** "Do not include 'time_in _force' parameter for market orders."
Buy Orders:
Stop Limit:
Stop price must be greater than LTP.
Limit price must be greater than stop price.
Take Profit Limit:
Stop price must be less than LTP.
Limit price must be greater than stop price and less than LTP.
Sell Orders:
Stop Limit:
Stop price must be less than LTP.
Limit price must be less than stop price.
Take Profit Limit:
Stop price must be greater than LTP.
Limit price must be less than stop price and greater than LTP.
Request Defnitions
Note : Cross margin mode is only supported on USDT margined Futures at the moment.
118/192
timestamp Integer YES Latest epoch timestamp when
the order is placed. Orders
with a delay of more than 10
seconds will be rejected.
119/192
margin_currency_short_name String OPTIONAL Futures margin mode.
Default value - "USDT".
Possible values INR & USDT.
Status
Code Message Reason
422 Order leverage must be When the leverage specified for an order does
equal to position leverage not match the leverage of the current position.
422 Quantity for limit variant Total quantity for a limit order exceeds the
orders should be less than maximum allowed limit.
9500.0
422 Quantity for market variant Total quantity for a market order exceeds the
orders should be less than maximum allowed market order quantity.
9500.0
400 Price is out of permissible If limit price or stop price mentioned is out of
range range i.e. price > max_price || price < min_price
for the instrument
400 Please enter a value lower Price is greater than max limit price (i.e. ltp + ltp *
than x multiplier_up)
400 Please enter a value Price is lower than min limit price (i.e. ltp - ltp *
higher than x multiplier_down)
400 Price should be divisible Price isn't divisible by the tick size
by 0.01
422 Quantity should be greater Quantity isn't greater than min quantity
than y
400 Insufficient funds Wallet doesn't have sufficient funds for placing
the order
400 Minimum order value Order value must be greater than min notional
should be x USDT
120/192
Status
Code Message Reason
400 You've exceeded the max Current position size is greater than position size
allowed position of x threshold
USDT.
400 Order is exceeding the Position size + order value > position size
max allowed position of x threshold
USDT.
400 Trigger price should be buy order, trigger_price < current price
greater than the current
price
400 Limit price should be buy limit order, limit price < trigger price
greater than the trigger
price
400 Trigger price should be sell order, trigger price > current price
less than the current price
400 Limit price should be less sell order, limit price < trigger price
than the trigger price
Response Defnitions
KEY DESCRIPTION
id Order id
status Ignore this (It will be initial for all the newly
placed orders)
121/192
order_type Order type. Possible values are :
limit - a type of order where the
execution price will be no worse than the
order's set price. The execution price is
limited to be the set price or better.
market - A type of order where the user
buys or sells an asset at the best
available prices and liquidity until the
order is fully filled or the order book's
liquidity is exhausted.
stop_market - once the market price hits
the stopPrice, a market order is placed
on the order book.
stop_limit - once the market price hits
the stopPrice, a limit order is placed on
the order book at the limit price.
take_profit_market - once the market
price hits the stopPrice, a market order
is placed on the order book.
take_profit_limit - once the market price
hits the stopPrice, a limit order is placed
on the order book at the limit price.
fee_amount This will be the fee that has been charged for
the user till now. As soon as the order is
placed, this value will be zero until you start
receiving trades for the order
price Order Price (limit price for limit, stop limit and
take profit limit orders) Keep this NULL for
market orders. Else the order will be rejected.
122/192
total_quantity Total quantity of the order
123/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp":timeStamp , # EPOCH timestamp in seconds
"order": {
"side": "sell", # buy OR sell
"pair": "B-ID_USDT", # instrument.string
"order_type": "market_order", # market_order OR limit_order
"price": "0.2962", #numeric value
"stop_price": "0.2962", #numeric value
"total_quantity": 33, #numerice value
"leverage": 10, #numerice value
"notification": "email_notification", # no_notification OR
email_notification OR push_notification
"time_in_force": "good_till_cancel", # good_till_cancel OR fill_or_kill OR
immediate_or_cancel
"hidden": False, # True or False
"post_only": False # True or False
}
}
url = "https://api.coindcx.com/exchange/v1/derivatives/futures/orders/create"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
124/192
Response
[
{
"id":"c87ca633-6218-44ea-900b-e86981358cbd",
"pair":"B-ID_USDT",
"side":"sell",
"status":"initial",
"order_type":"market_order",
"notification":"email_notification",
"leverage":10.0,
"maker_fee":0.025,
"taker_fee":0.075,
"fee_amount":0.0,
"price":0.2966,
"avg_price":0.0,
"total_quantity":33.0,
"remaining_quantity":33.0,
"cancelled_quantity":0.0,
"ideal_margin":0.98024817,
"order_category":"None",
"stage":"default",
"group_id":"None",
"liquidation_fee": null,
"position_margin_type": "crossed",
"display_message":"None",
"group_status":"None",
"margin_currency_short_name" : "INR",
"settlement_currency_conversion_price": 89.0,
"created_at":1705647376759,
"updated_at":1705647376759
}
]
Cancel Order
Use this endpoint to cancel an order by passing the order id.
HTTP Request
POST https://api.coindcx.com//exchange/v1/derivatives/futures/orders/cancel
Request Defnitions
125/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp":timeStamp , # EPOCH timestamp in seconds
"id": "c87ca633-6218-44ea-900b-e86981358cbd" # order.id
}
url = "https://api.coindcx.com/exchange/v1/derivatives/futures/orders/cancel"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response
{
"message":"success",
"status":200,
"code":200
}
List Positions
126/192
Use this endpoint to fetch positions by passing timestamp.
HTTP Request
POST https://api.coindcx.com/exchange/v1/derivatives/futures/positions
Request Defnitions
Response Defnitions
Note : All the margin values are in USDT for INR Futures.
KEY DESCRIPTION
127/192
locked_user_margin Margin (in USDT) that was initially invested in the
futures position excluding fees and funding.
take_profit_trigger Trigger price set for Full Position take profit order.
stop_loss_trigger Trigger price set for Full position stop loss order.
mark_price Mark price at the time when the position was last
updated. Note that this value is not real-time and is
only for reference purpose.
128/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp":timeStamp , # EPOCH timestamp in seconds
"page": "1", #no. of pages needed
"size": "10",
"margin_currency_short_name": ["USDT"]
}
url = "https://api.coindcx.com/exchange/v1/derivatives/futures/positions"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response
129/192
[
{
"id": "571eae12-236a-11ef-b36f-83670ba609ec",
"pair": "B-BNB_USDT",
"active_pos": 0.0,
"inactive_pos_buy": 0.0,
"inactive_pos_sell": 0.0,
"avg_price": 0.0,
"liquidation_price": 0.0,
"locked_margin": 0.0,
"locked_user_margin": 0.0,
"locked_order_margin": 0.0,
"take_profit_trigger": null,
"stop_loss_trigger": null,
"leverage": 10.0,
"maintenance_margin": 0.0,
"mark_price": 0.0,
"margin_type": "crossed",
"settlement_currency_avg_price": 0.0,
"margin_currency_short_name": "USDT",
"updated_at": 1717754279737
}
]
HTTP Request
POST https://api.coindcx.com/exchange/v1/derivatives/futures/positions
Request Defnitions
130/192
margin_currency_short_name Array OPTIONAL Futures margin mode.
Default value - ["USDT"].
Possible values INR & USDT.
NOTE : Based on the requirement use the “ pairs “ or “ position_ids “ parameter. You
need to use either one of the 2 parameters
Response Defnitions
Note : All the margin values are in USDT for INR Futures.
KEY DESCRIPTION
take_profit_trigger Trigger price set for Full Position take profit order.
stop_loss_trigger Trigger price set for Full position stop loss order.
131/192
maintenance_margin The amount of margin required to be maintained in
the account to avoid liquidation. For cross margined
positions, the maintenance margin required is equal
to the sum of the maintenance margins of all the
positions.
mark_price Mark price at the time when the position was last
updated. Note that this value is not real-time and is
only for reference purpose.
132/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "xxx"
secret = "xxx"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp, # EPOCH timestamp in seconds
"page": "1",
"size": "10",
"pairs": "B-BTC_USDT,B-ETH_USDT",
#"position_ids": "7830d2d6-0c3d-11ef-9b57-0fb0912383a7"
"margin_currency_short_name": ["USDT"]
url = "https://api.coindcx.com/exchange/v1/derivatives/futures/positions"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response
133/192
[
{
"id": "c7ae392e-5d70-4aaf-97dc-8e6b0076e391",
"pair": "B-BTC_USDT",
"active_pos": 0.0,
"inactive_pos_buy": 0.0,
"inactive_pos_sell": 0.0,
"avg_price": 0.0,
"liquidation_price": 0.0,
"locked_margin": 0.0,
"locked_user_margin": 0.0,
"locked_order_margin": 0.0,
"take_profit_trigger": 0.0,
"stop_loss_trigger": 0.0,
"leverage": null,
"maintenance_margin": null,
"mark_price": null,
"margin_type": "crossed",
"settlement_currency_avg_price": 0.0,
"margin_currency_short_name": "USDT",
"updated_at": 1709548678689
}
]
HTTP Request
POST
https://api.coindcx.com/exchange/v1/derivatives/futures/positions/update_le
verage
Request Defnitions
134/192
NOTE : Based on the requirement use the “ pairs “ or “ position_ids “ parameter. You
need to use either one of the 2 parameters
Status
Code Message Reason
400 Leverage cannot be less than When leverage specified is less than the
1x minimum allowed leverage of 1x.
400 Max allowed leverage for User leverage exceeds the maximum allowed
current position size = 5x leverage based on tiered limits.
422 Liquidation will be triggered Condition where liquidation of the position will
instantly occur immediately.
135/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "xxx"
secret = "xxx"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp, # EPOCH timestamp in seconds
"leverage": "5", # leverage value
"pair": "B-LTC_USDT" # instrument.pair
#"id": "7830d2d6-0c3d-11ef-9b57-0fb0912383a7",
#"margin_currency_short_name": "INR"
}
url =
"https://api.coindcx.com/exchange/v1/derivatives/futures/positions/update_leverage
"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response
{
"message": "success",
"status": 200,
"code": 200
}
136/192
Add Margin
Use this endpoint to add the margin to the position.
HTTP Request
POST
https://api.coindcx.com/exchange/v1/derivatives/futures/positions/add_margi
n
Request Defnitions
137/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp , // EPOCH timestamp in seconds
"id": "434dc174-6503-4509-8b2b-71b325fe417a", // position.id
"amount":1
}
url =
"https://api.coindcx.com/exchange/v1/derivatives/futures/positions/add_margin"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
response = requests.post(url, data = json_body, headers = headers)
data = response.json()
print(data)
Response
{
"message":"success",
"status":200,
"code":200
}
138/192
Remove Margin
Use this endpoint to remove the margin for the position.
HTTP Request
POST
https://api.coindcx.com/exchange/v1/derivatives/futures/positions/remove_ma
rgin
Request Defnitions
Status
Code Message Reason
422 Cannot remove margin as exit Attempting to modify margin while an exit or
or liquidation is already in liquidation process is ongoing.
process
422 Cannot change margin for an Trying to adjust margin for a position that is
inactive position currently inactive.
400 Insufficient funds Wallet doesn't have sufficient funds for the
requested action.
139/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp , # EPOCH timestamp in seconds
"id": "434dc174-6503-4509-8b2b-71b325fe417a", # position.id
"amount": 10
}
url =
"https://api.coindcx.com/exchange/v1/derivatives/futures/positions/remove_margin"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response
{
"message":"success",
"status":200,
"code":200
}
140/192
Cancel All Open Orders
Use this endpoint to cancel all the open orders till time.
HTTP Request
POST
https://api.coindcx.com/exchange/v1/derivatives/futures/positions/cancel_al
l_open_orders
Request Defnitions
141/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp, # EPOCH timestamp in seconds
"margin_currency_short_name": ["USDT"],
}
url =
"https://api.coindcx.com/exchange/v1/derivatives/futures/positions/cancel_all_open
_orders"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response
142/192
{
"message":"success",
"status":200,
"code":200
}
HTTP Request
POST
https://api.coindcx.com/exchange/v1/derivatives/futures/positions/cancel_al
l_open_orders_for_position
Request Defnitions
143/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp":timeStamp , # EPOCH timestamp in seconds
"id": "434dc174-6503-4509-8b2b-71b325fe417a" # position.id
}
url =
"https://api.coindcx.com/exchange/v1/derivatives/futures/positions/cancel_all_open
_orders_for_position"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response
144/192
{
"message":"success",
"status":200,
"code":200
}
Exit Position
Use this endpoint to exit position by passing position id.
HTTP Request
POST https://api.coindcx.com/exchange/v1/derivatives/futures/positions/exit
Request Defnitions
Response Defnitions
KEY DESCRIPTION
message
status
code
group_id Group id is an id which is used whenever a large order is split into smaller
parts. System auto-splits the exit order into smaller parts if the order size is
huge. All the split parts will have the same group id.
145/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp , # EPOCH timestamp in seconds
"id": "434dc174-6503-4509-8b2b-71b325fe417a" # position.id
}
url = "https://api.coindcx.com/exchange/v1/derivatives/futures/positions/exit"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response
146/192
{
"message":"success",
"status":200,
"code":200,
"data":{
"group_id":"baf926e6B-ID_USDT1705647709"
}
}
HTTP Request
POST
https://api.coindcx.com/exchange/v1/derivatives/futures/positions/create_tp
sl
Request Defnitions
take_profit - String YES Stop price is the trigger price of the take
stop_price profit order
take_profit - String NO Limit price - Ignore this for now. This is not
limit_price supported.
stop_loss - String YES Stop price is the trigger price of the stop
stop_price loss order
stop_loss - String NO Limit price - Ignore this for now. This is not
limit_price supported.
Response Defnitions
KEY DESCRIPTION
147/192
id
pair
side
order_type
notification
leverage
maker_fee
taker_fee
fee_amount
price
stop_price
avg_price
total_quantity
remaining_quantity
cancelled_quantity
ideal_margin
order_category
stage
group_id
148/192
created_at
updated_at
149/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp, # EPOCH timestamp in seconds
"id": "e65e8b77-fe7c-40c3-ada1-b1d4ea40465f", # position.id
"take_profit": {
"stop_price": "1",
"limit_price": "0.9", # required for take_profit_limit orders
"order_type": "take_profit_limit" # take_profit_limit OR take_profit_market
},
"stop_loss": {
"stop_price": "0.271",
"limit_price": "0.270", # required for stop_limit orders
"order_type": "stop_limit" # stop_limit OR stop_market
}
}
url =
"https://api.coindcx.com/exchange/v1/derivatives/futures/positions/create_tpsl"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
150/192
Response
{
"stop_loss":{
"id":"8f8ee959-36cb-4932-bf3c-5c4294f21fec",
"pair":"B-ID_USDT",
"side":"sell",
"status":"untriggered",
"order_type":"stop_limit",
"stop_trigger_instruction":"last_price",
"notification":"email_notification",
"leverage":1.0,
"maker_fee":0.025,
"taker_fee":0.075,
"fee_amount":0.0,
"price":0.27,
"stop_price":0.271,
"avg_price":0.0,
"total_quantity":0.0,
"remaining_quantity":0.0,
"cancelled_quantity":0.0,
"ideal_margin":0.0,
"order_category":"complete_tpsl",
"stage":"tpsl_exit",
"group_id":"None",
"display_message":"None",
"group_status":"None",
"margin_currency_short_name" : "INR",
"settlement_currency_conversion_price": 89.0,
"created_at":1705915027938,
"updated_at":1705915028003
},
"take_profit":{
"success":false,
"error":"TP already exists"
}
}
Get Transactions
Use this endpoint to get the list of transactions by passing the position ids and stage ( all
OR default )
HTTP Request
POST
https://api.coindcx.com/exchange/v1/derivatives/futures/positions/transacti
ons
Request Defnitions
151/192
Name Type Mandatory Description
Response Defnitions
Note : "amount", "fee_amount", "settlement_amount" will show in INR for INR margined
Futures and in USDT for USDT margined Futures.
KEY DESCRIPTION
pair
stage
amount This represents the PnL (Profit and Loss) from this
particular transaction.
source Source will be “user” for the orders placed by the users
and will be “system” for the orders placed by the
system. Liquidation orders are placed by the system.
parent_type
152/192
parent_id
position_id
created_at
updated_at
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp, # EPOCH timestamp in seconds
"stage": "all", # all OR default OR funding
"page": "1", #no. of pages needed
"size": "10" #no. of records needed
}
json_body = json.dumps(body, separators = (',', ':'))
url =
"https://api.coindcx.com/exchange/v1/derivatives/futures/positions/transactions"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
153/192
Response
[
{
"pair": "B-BTC_USDT",
"stage": "default",
"amount": 0.0,
"fee_amount": 8.899963104,
"price_in_inr": 1.0,
"price_in_btc": 1.85407055628e-07,
"price_in_usdt": 0.011572734637194769,
"source": "user",
"parent_type": "Derivatives::Futures::Order",
"parent_id": "061a7f36-daaf-4349-97c0-47bad7d08f5e",
"settlement_amount": 0.0,
"margin_currency_short_name": "INR",
"position_id": "beecde3c-7fe6-11ef-bd3a-5b8a901688d3",
"created_at": 1728459094499,
"updated_at": 1728459094499
}
]
Get Trades
Use this endpoint to all the trades information by passing the pair, order id and from and
to date.
HTTP Request
POST https://api.coindcx.com/exchange/v1/derivatives/futures/trades
Request Defnitions
154/192
margin_currency_short_name Array YES Futures margin mode.
Default value - ["USDT"].
Possible values INR & USDT.
Response Defnitions
Note : fee_amount value is in USDT for INR Futures.
KEY DESCRIPTION
price
quantity
is_maker
fee_amount
pair
side
timestamp
order_id
155/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp":timeStamp, # EPOCH timestamp in seconds
"pair": "B-ID_USDT", # instrument.pair
"order_id": "9b37c924-d8cf-4a0b-8475-cc8a2b14b962", # order.id
"from_date": "2024-01-01", # format YYYY-MM-DD
"to_date": "2024-01-22", # format YYYY-MM-DD
"page": "1", #no. of pages needed
"size": "10" #no. of records needed
}
json_body = json.dumps(body, separators = (',', ':'))
url = "https://api.coindcx.com/exchange/v1/derivatives/futures/trades"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response
156/192
[
{
"price":0.2962,
"quantity":33.0,
"is_maker":false,
"fee_amount":0.00733095,
"pair":"B-ID_USDT",
"side":"buy",
"timestamp":1705645534425.8374,
"order_id":"9b37c924-d8cf-4a0b-8475-cc8a2b14b962",
"settlement_currency_conversion_price": 0.0,
"margin_currency_short_name": "USDT"
}
]
HTTP Request
GET https://public.coindcx.com/market_data/v3/current_prices/futures/rt
Response Defnitions
KEY DESCRIPTION
fr
h high
l low
v volume
ls
mkt
ctRT
skw
mp
efr
157/192
bmST TPE mark price send time (The timestamp at which Third-Party exchange sent
this event)
cmRT
Response
158/192
{
"ts": 1720429586580,
"vs": 54009972,
"prices": {
"B-NTRN_USDT": {
"fr": 5e-05,
"h": 0.4027,
"l": 0.3525,
"v": 18568384.9349,
"ls": 0.4012,
"pc": 4.834,
"mkt": "NTRNUSDT",
"btST": 1720429583629,
"ctRT": 1720429584517,
"skw": -207,
"mp": 0.40114525,
"efr": 5e-05,
"bmST": 1720429586000,
"cmRT": 1720429586117
},
"B-1000SHIB_USDT": {
"fr": -0.00011894,
"h": 0.017099,
"l": 0.014712,
"v": 358042914.374195,
"ls": 0.016909,
"pc": 2.578,
"mkt": "1000SHIBUSDT",
"btST": 1720429586359,
"ctRT": 1720429586517,
"skw": -207,
"mp": 0.01691261,
"efr": -9.115e-05,
"bmST": 1720429586000,
"cmRT": 1720429586117
}
}
}
HTTP Request
POST https://api.coindcx.com/api/v1/derivatives/futures/data/stats?pair=B-
ETH_USDT
Request Defnitions
159/192
Name Type Mandatory Description
Response Defnitions
KEY DESCRIPTION
price_change_percent
high_and_low
1H Hour
1D Day
1W Week
1M Month
position
count_percent
long
short
value_percent
160/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "xxx"
secret = "yyy"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp, # EPOCH timestamp in seconds
}
json_body = json.dumps(body, separators=(',', ':'))
signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()
url = "https://api.coindcx.com/api/v1/derivatives/futures/data/stats?pair=B-
ETH_USDT"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
response = requests.get(url, data=json_body, headers=headers)
data = response.json()
print(json.dumps(data, indent=2))
Response
161/192
{
"price_change_percent": {
"1H": -0.15,
"1D": 1.41,
"1W": -11.95,
"1M": -17.34
},
"high_and_low": {
"1D": {
"h": 3098.0,
"l": 2821.26
},
"1W": {
"h": 3498.91,
"l": 2800.0
}
},
"position": {
"count_percent": {
"long": 93.2,
"short": 6.8
},
"value_percent": {
"long": 91.48,
"short": 8.52
}
}
}
HTTP Request
POST
https://api.coindcx.com/exchange/v1/derivatives/futures/positions/cross_mar
gin_details
Request Defnitions
Response Defnitions
KEY DESCRIPTION
162/192
pnl This is gives your unrealised PnL in cross
margin positions
163/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "xxx"
secret = "yyy"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
# secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp
}
json_body = json.dumps(body, separators=(',', ':'))
signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()
url =
"https://api.coindcx.com/exchange/v1/derivatives/futures/positions/cross_margin_de
tails"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
response = requests.get(url, data=json_body, headers=headers)
data = response.json()
print(json.dumps(data, indent=2))
Response
{
"pnl": -0.0635144,
"maintenance_margin": 0.10170128,
"available_wallet_balance": 7.16966176,
"total_wallet_balance": 7.16966176,
"total_initial_margin": 0.68534648,
"total_initial_margin_isolated": 0.0,
"total_initial_margin_crossed": 0.68534648,
"total_open_order_initial_margin_crossed": 0.0,
"available_balance_cross": 6.42080088,
"available_balance_isolated": 6.42080088,
"margin_ratio_cross": 0.01431173,
"withdrawable_balance": 6.42080088,
"total_account_equity": 7.10614736,
"updated_at": 1720526407542
}
164/192
Wallet Transfer
Use this endpoint to transfer money from spot to futures wallet and vice-versa
HTTP Request
POST
https://api.coindcx.com/exchange/v1/derivatives/futures/wallets/transfer
Request Defnitions
Response Defnitions
KEY DESCRIPTION
id Transaction id
NOTE :
To calculate total wallet balance, use this formulae:
Total wallet balance = balance + locked_balance
165/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "xxx"
secret = "yyy"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
# secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp,
"transfer_type": "withdraw", # "deposit" OR "withdraw" (to/from DF wallet)
"amount": 1,
"currency_short_name": "USDT"
}
json_body = json.dumps(body, separators=(',', ':'))
signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()
url = "https://api.coindcx.com/exchange/v1/derivatives/futures/wallets/transfer"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
response = requests.post(url, data=json_body, headers=headers)
data = response.json()
print(json.dumps(data, indent=2))
Response
[
{
"id": "c5f039dd-4e11-4304-8f91-e9c1f62d754d",
"currency_short_name": "USDT",
"balance": "6.1693226",
"locked_balance": "0.0",
"cross_order_margin": "0.0",
"cross_user_margin": "0.68534648"
}
]
Wallet Details
Use this endpoint to fetch the wallet details for both INR & USDT Futures Wallet.
166/192
HTTP Request
GET https://api.coindcx.com/exchange/v1/derivatives/futures/wallets
Request Defnitions
Response Defnitions
KEY DESCRIPTION
id Futures wallet id
167/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "xxx"
secret = "yyy"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
# secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp
}
json_body = json.dumps(body, separators=(',', ':'))
signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()
url = "https://api.coindcx.com/exchange/v1/derivatives/futures/wallets"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
response = requests.get(url, data=json_body, headers=headers)
data = response.json()
print(json.dumps(data, indent=2))
Response
[
{
"id": "c5f039dd-4e11-4304-8f91-e9c1f62d754d",
"currency_short_name": "USDT",
"balance": "6.1693226",
"locked_balance": "0.0",
"cross_order_margin": "0.0",
"cross_user_margin": "0.68534648"
}
]
Wallet Transactions
Use this endpoint to fetch the list of wallet transactions for both INR & USDT Futures
Wallet.
HTTP Request
168/192
GET
https://api.coindcx.com/exchange/v1/derivatives/futures/wallets/transaction
s?page=1&size=1000
Request Defnitions
Response Defnitions
KEY DESCRIPTION
169/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "xxx"
secret = "yyy"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
# secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp
}
json_body = json.dumps(body, separators=(',', ':'))
signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()
url =
"https://api.coindcx.com/exchange/v1/derivatives/futures/wallets/transactions?
page=1&size=1000"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
response = requests.get(url, data=json_body, headers=headers)
data = response.json()
print(json.dumps(data, indent=2))
Response
[
{
"derivatives_futures_wallet_id": "c5f039dd-4e11-4304-8f91-e9c1f62d754d",
"transaction_type": "debit",
"amount": 1.0,
"currency_short_name": "USDT",
"currency_full_name": "Tether",
"reason": "by_universal_wallet",
"created_at": 1720547024000
}
]
Edit Order
170/192
Use this endpoint to edit the order which is in open status.
Note : Edit order is only supported on USDT margined Futures at the moment.
HTTP Request
POST https://api.coindcx.com/exchange/v1/derivatives/futures/orders/edit
Request Defnitions
Response Defnitions
KEY DESCRIPTION
id Order id
status Ignore this (It will be initial for all the newly placed orders)
stop_trigger_instruction
171/192
notification no_notification OR email_notification. If property is set as
email_notification then you will get an email once the order is
filled
leverage This is the leverage at which you want to take a position. This
has to be the same as the leverage of the position. Else the
order will be rejected. You should preferably set the leverage
before placing the order to avoid order rejection. Leverage
needs to be set only once post which it will be saved in the
system for that particular pair.
maker_fee Applicable fee if the trade received for the order is a maker
trade
taker_fee Applicable fee if the trade received for the order is a taker
trade
liquidation_fee Applicable fee if the trade received for the order is a trade for
the liquidation order
fee_amount This will be the fee that has been charged for the user till
now. As soon as the order is placed, this value will be zero
until you start receiving trades for the order
price Order Price (limit price for limit, stop limit and take profit limit
orders). Keep this NULL for market orders. Else the order will
be rejected.
stop_price
avg_price It will be zero for the newly placed orders. You can check the
latest fill price from the list orders endpoint
ideal_margin This is the margin that is required for placing this order. You
will see the ideal margin as non-zero even for reduce orders
but the actual margin locked for reduce orders will be 0. This
number is only for reference purpose.
locked_margin
position_margin_type “crossed” if the order was placed for cross margin position.
“Isolated” if the order is placed for isolated margin position.
Please consider NULL also as isolated.
172/192
stage default - Standard limit, market, stop limit, stop market, take
profit limit or take profit market order
exit - Quick exit which closes the entire position
liquidate - Order which was created by the system to liquidate
a futures position
tpsl_exit - Take profit or stop loss order which was placed to
close the entire futures position
trades
metatags
173/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "xxx"
secret = "xxx"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
# secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp,
"id": "dd456ab4-4a7d-11ef-a287-bf3cd92be693",
"total_quantity": 12,
"price": 0.999501
}
url = "https://api.coindcx.com/exchange/v1/derivatives/futures/orders/edit"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response
174/192
[
{
"id": "dd456ab4-4a7d-11ef-a287-bf3cd92be693",
"pair": "B-USDC_USDT",
"side": "buy",
"status": "open",
"order_type": "limit_order",
"stop_trigger_instruction": "last_price",
"notification": "email_notification",
"leverage": 5.0,
"maker_fee": 0.025,
"taker_fee": 0.074,
"liquidation_fee": null,
"fee_amount": 0.0,
"price": 0.999501,
"stop_price": 0.0,
"avg_price": 0.0,
"total_quantity": 12.0,
"remaining_quantity": 12.0,
"cancelled_quantity": 0.0,
"ideal_margin": 2.402352627552,
"locked_margin": 2.402352627552,
"order_category": null,
"position_margin_type": "isolated",
"stage": "default",
"created_at": 1721908991520,
"updated_at": 1721909127960,
"trades": [],
"display_message": "Order edited successfully",
"group_status": null,
"group_id": null,
"metatags": null
}
]
Note : Cross margin mode is only supported on USDT margined Futures at the moment.
HTTP Request
POST
https://api.coindcx.com/exchange/v1/derivatives/futures/positions/margin_ty
pe
Request Defnitions
175/192
Name Type Mandatory Description
Response Defnitions
KEY DESCRIPTION
id Position id
liquidation_price Price at which the position will get liquidated. This is applicable
only for positions with isolated margin. Ignore this for cross
margined positions.
locked_margin Margin (in USDT) locked in the position after debiting fees and
adjusting funding from the initial investment.
locked_user_margin Margin (in USDT) that was initially invested in the futures
position excluding fees and funding.
take_profit_trigger Trigger price set for Full Position take profit order.
stop_loss_trigger Trigger price set for Full position stop loss order.
176/192
maintenance_margin The amount of margin required to be maintained in the account
to avoid liquidation. For cross margined positions, the
maintenance margin required is equal to the sum of the
maintenance margins of all the positions
mark_price Mark price at the time when the position was last updated. Note
that this value is not real-time and is only for reference purpose.
177/192
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "xxx"
secret = "yyy"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
# secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp,
"pair": "B-JTO_USDT",
"margin_type": "isolated", # "isolated" or "crossed"
}
url =
"https://api.coindcx.com/exchange/v1/derivatives/futures/positions/margin_type"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response
178/192
[
{
"id": "6bcb26f8-4a7d-11ef-b553-6bef92793bf4",
"pair": "B-JTO_USDT",
"active_pos": 0.0,
"inactive_pos_buy": 0.0,
"inactive_pos_sell": 0.0,
"avg_price": 0.0,
"liquidation_price": 0.0,
"locked_margin": 0.0,
"locked_user_margin": 0.0,
"locked_order_margin": 0.0,
"take_profit_trigger": null,
"stop_loss_trigger": null,
"margin_type": "isolated",
"leverage": 5.0,
"mark_price": 0.0,
"maintenance_margin": 0.0,
"updated_at": 1721978237197
}
]
HTTP Request
POST https://api.coindcx.com/api/v1/derivatives/futures/data/conversions
Request Defnitions
Response Defnitions
KEY DESCRIPTION
margin_currency_short_name INR
target_currency_short_name USDT
179/192
conversion_price When using INR margin, CoinDCX notionally converts
INR to USDT & vice-versa at this conversion rate. This
conversion rate may change periodically due to
extreme market movements.
import hmac
import hashlib
import base64
import json
import time
import requests
# Enter your API Key and Secret here. If you don't have one, you can generate it
from the website.
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
# secret_bytes = bytes(secret)
# Generating a timestamp
timeStamp = int(round(time.time() * 1000))
body = {
"timestamp": timeStamp,
}
url = "https://api.coindcx.com/api/v1/derivatives/futures/data/conversions"
headers = {
'Content-Type': 'application/json',
'X-AUTH-APIKEY': key,
'X-AUTH-SIGNATURE': signature
}
Response
180/192
[
{
"symbol": "USDTINR",
"margin_currency_short_name": "INR",
"target_currency_short_name": "USDT",
"conversion_price": 89.0,
"last_updated_at": 1728460492399
}
]
Futures Sockets
Glossary
e - is the Event type
p - price (LTP)
q - quantity (trade quantity)
pr - product (futures)
f - futures
s - spot
T - timestamp
m - is maker. Boolean value that would be true if its maker and false if its taker
RT - range timestamp
ts - timestamp
vs - version
Ets - event timestamp as given by TPE (applicable to candlesticks data)
i - Interval
E - event timestamp (applicable to order book data)
pST - price sent time
v - volume 24h
ls - last price
pc - price change percent
btST - TPE Tick send time
mp - mark price
bmST - TPE mark price send time (The timestamp at which Third-Party exchange
sent this event)
ACCOUNT
181/192
import socketio
import hmac
import hashlib
import json
socketEndpoint = 'wss://stream.coindcx.com'
sio = socketio.Client()
key = "XXXX"
secret = "YYYY"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
# python2
secret_bytes = bytes(secret)
body = {"channel":"coindcx"}
json_body = json.dumps(body, separators = (',', ':'))
signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()
# Join channel
sio.emit('join', { 'channelName': 'coindcx', 'authSignature': signature, 'apiKey'
: key })
@sio.on(<eventName>)
def on_message(response):
print(response["data"])
# leave a channel
sio.emit('leave', { 'channelName' : 'coindcx' })
Definitions
Channel: coindcx
Event: df-position-update
@sio.on('df-position-update')
def on_message(response):
print(response["data"])
Response:
182/192
[
{
"id":"571eae12-236a-11ef-b36f-83670ba609ec",
"pair":"B-BNB_USDT",
"active_pos":0,
"inactive_pos_buy":0,
"inactive_pos_sell":0,
"avg_price":0,
"liquidation_price":0,
"locked_margin":0,
"locked_user_margin":0,
"locked_order_margin":0,
"take_profit_trigger":null,
"stop_loss_trigger":null,
"leverage":10,
"mark_price":0,
"maintenance_margin":0,
"updated_at":1717754279737,
"margin_type": "isolated",
"margin_currency_short_name" : "INR",
"settlement_currency_avg_price" : 89.0,
}
]
Definitions
Channel: coindcx
Event: df-order-update
@sio.on('df-order-update')
def on_message(response):
print(response["data"])
Response:
183/192
[
{
"id":"ff5a645f-84b7-4d63-b513-9e2f960855fc",
"pair":"B-ID_USDT",
"side":"sell",
"status":"cancelled",
"order_type":"take_profit_limit",
"stop_trigger_instruction":"last_price",
"notification":"email_notification",
"leverage":1,
"maker_fee":0.025,
"taker_fee":0.075,
"fee_amount":0,
"price":0.9,
"stop_price":1,
"avg_price":0,
"total_quantity":0,
"remaining_quantity":0,
"cancelled_quantity":0,
"ideal_margin":0,
"order_category":"complete_tpsl",
"stage":"tpsl_exit",
"created_at":1705915012812,
"updated_at":1705999727686,
"trades":[
],
"display_message":null,
"group_status":null,
"group_id":null,
"metatags": null,
"margin_currency_short_name" : "INR",
"settlement_currency_conversion_price" : 89.0,
}
]
Definitions
Channel: coindcx
Event: balance-update
@sio.on('balance-update')
def on_message(response):
print(response["data"])
Response:
184/192
[
{
"id":"026ef0f2-b5d8-11ee-b182-570ad79469a2",
"balance":"1.0221449",
"locked_balance":"0.99478995",
"currency_id":"c19c38d1-3ebb-47ab-9207-62d043be7447",
"currency_short_name":"USDT"
}
]
Definitions
The set of candlestick resolutions available are ["1m", "5m", "15m", "30m", "1h", "4h",
"8h", "1d", "3d", "1w", "1M"]. For example for 15 minute candle please connect to channel
[instrument_name]_15m-futures
@sio.on('candlestick')
def on_message(response):
print(response["data"])
Response:
185/192
{
"data":[
{
"open":"0.3524000",
"close":"0.3472000",
"high":"0.3531000",
"low":"0.3466000",
"volume":"5020395",
"open_time":1705514400,
"close_time":1705517999.999,
"pair":"B-ID_USDT",
"duration":"1h",
"symbol":"IDUSDT",
"quote_volume":"1753315.2309000"
}
],
"Ets":1705516366626,
"i":"1h",
"channel":"B-ID_USDT_1h-futures",
"pr":"futures"
}
Get Orderbook
Definitions
@sio.on('depth-snapshot')
def on_message(response):
print(response["data"])
Response:
186/192
{
"ts":1705913767265,
"vs":53727235,
"asks":{
"2410":"112.442",
"2409.77":"55.997",
"2409.78":"5.912"
},
"bids":{
"2409.76":"12.417",
"2409.75":"1.516",
"2409.74":"15.876"
},
"pr":"futures"
}
Definitions
Channel: currentPrices@futures@rt
Example to join channel : ['join', {'channelName':"currentPrices@futures@rt"}]
Event: currentPrices@futures#update
@sio.on('currentPrices@futures#update')
def on_message(response):
print(response["data"])
Response:
{
"vs":29358821,
"ts":1707384027242,
"pr":"futures",
"pST":1707384027230,
"prices":{
"B-UNI_USDT":{
"bmST":1707384027000,
"cmRT":1707384027149
},
"B-LDO_USDT":{
"mp":2.87559482,
"bmST":1707384027000,
"cmRT":1707384027149
}
}
}
187/192
Definitions
@sio.on('new-trade')
def on_message(response):
print(response["data"])
Response:
{
"T":1705516361108,
"RT":1705516416271.6133,
"p":"0.3473",
"q":"40",
"m":1,
"s":"B-ID_USDT",
"pr":"f"
}
Definitions
@sio.on('price-change')
def on_message(response):
print(response["data"])
Response:
{
"T":1705516361108,
"p":"0.3473",
"pr":"f"
}
Definitions
188/192
Websocket connection implementation with ping check
189/192
import socketio
import hmac
import hashlib
import json
import time
import asyncio
from datetime import datetime
from socketio.exceptions import TimeoutError
socketEndpoint = 'wss://stream.coindcx.com'
sio = socketio.AsyncClient()
key = "xxx"
secret = "xxx"
# python3
secret_bytes = bytes(secret, encoding='utf-8')
channelName = "coindcx"
body = {"channel": channelName}
json_body = json.dumps(body, separators=(',', ':'))
signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()
@sio.event
async def connect():
print("I'm connected!")
current_time = datetime.now()
print("Connected Time:", current_time.strftime("%Y-%m-%d %H:%M:%S"))
@sio.on('price-change')
async def on_message(response):
current_time = datetime.now()
print("Price Change Time:", current_time.strftime("%Y-%m-%d %H:%M:%S"))
print("Price Change Response !!!")
print(response)
190/192
await sio.wait()
while True:
time.sleep(1)
sio.event('price-change', {'channelName': "B-ID_USDT@prices-futures"})
except Exception as e:
print(f"Error connecting to the server: {e}")
raise # re-raise the exception to see the full traceback
Response:
FAQ
From where to start
Authentication
General API
Markets
Orders
Sockets
User Data
Handling Errors
Errors
The CoinDCX API uses the following error codes:
Error
Code Meaning
429 Too Many Requests -- You're making too many API calls
500 Internal Server Error -- We had a problem with our server. Try again later.
503 Service Unavailable -- We're temporarily offline for maintenance. Please try
again later.
High-Frequency Trading
191/192
CoinDCX’s API for High-Frequency Trading (HFT)
To receive this access, kindly contact our support team. Our team members will request
you for a static IP address which we will keep as our Trusted IPs for HFT. Once your IP
address has been added as ‘Trusted’, you will receive the required access to our HFT API
services.
192/192