NAV
python javascript

Terms and Conditions

These API License Terms and Conditions (“Terms”) shall govern the use of any ‘Market Data’ and Application Programming Interface (API) of CoinDCX by you, either an individual, association of persons, company, or any legal entity and its respective affiliates (hereinafter referred to as “User”). For the purpose of these Terms, ‘Market Data’ shall mean and include all data related to the trading activity on any website, applications or platform owned and operated by Primestack Pte. Limited and/or Neblio Technologies Private Limited or any of their parent company, subsidiaries, or affiliates (collectively referred to as “CoinDCX”) including any data, information made available to the User through the application programming interface of CoinDCX (“CoinDCX API”). The Market Data may include, without limitation, the prices and quantities of orders and transactions executed on any platform/ application of CoinDCX.

The User hereby agrees and acknowledges that upon accessing any CoinDCX API (defined hereinafter), Market Data and/or any other information, service, feature governed by terms contained herein, the User shall be bound by these Terms, as updated, modified, and/or replaced from time to time. The User is required to check for any such amendment, replacement or changes to the terms contained herein and any future use or access to any services covered herein.

1. DEFINITIONS

2. LICENSE GRANT AND AUTHORISED USE

3. FEES AND CHARGES

4. OWNERSHIP AND RIGHTS

5. TERM AND TERMINATION

6. REPRESENTATIONS AND WARRANTIES OF THE USER

7. DISCLAIMER

THE COINDCX API, MARKET DATA (INCLUDING DATA PACKAGES) AND ANY OTHER SERVICE/ SOFTWARE PROVIDED BY COINDCX TO THE USER IS PROVIDED ON AN “AS IS'' AND “AS AVAILABLE” BASIS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED. COINDCX DOES NOT WARRANT THAT THE COINDCX API OR ANY SERVICES PROVIDED HEREUNDER WILL BE SAFE, UNINTERRUPTED, ERROR FREE, OR PROTECT AGAINST ANY HACK, CYBER CRIME OR OTHER THREATS. COINDCX DISCLAIMS ALL OTHER WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE FITNESS, QUALITY, PERFORMANCE, NON-INFRINGEMENT, PURPOSE OF THE COINDCX API OR MARKET DATA OR ANY SOFTWARE OR SERVICE PROVIDED TO THE USER. ACCESS ANY USE OF ANY COINDCX API OR MARKET DATA IS AT THE SOLE RISK OF THE USER AND COINDCX SHALL NOT BE RESPONSIBLE FOR ANY ACTIONS TAKEN BASED ON ANY SOFTWARE OR SERVICE PROVIDED HEREUNDER.

8. SECURITY

The user shall ensure that the information received through APIs, including personally identifiable information is protected from unauthorized access or use and shall promptly report to CoinDCX of any unauthorized access or use of such information to the extent required by applicable law. The User must ensure secure operation of CoinDCX APIs by employing reasonable security measures. The Users shall report any security deficiencies or intrusions at [email protected].

9. LIMITATION OF LIABILITY

In no event, whether in tort, contract or otherwise, shall CoinDCX or its Affiliates be liable towards the User for any indirect, special, consequential, incidental, punitive, business loss. Under no circumstances or event shall the maximum aggregate liability of CoinDCX towards the User or any of its Affiliates shall exceed INR 1,00,000/- (Rupees One lakh only).

10. INDEMNITY

11. ARBITRATION

12. GOVERNING LAW AND JURISDICTION

Subject to the Arbitration clause above, these Terms shall be governed by the laws of India and the courts at Mumbai, India shall have exclusive jurisdiction.

13. MISCELLANEOUS

Introduction

Welcome to the CoinDCX API!

CoinDCX Public APIs can be used for placing different orders like Spot, Margin, Lend
and also for getting data related to different markets, candles, user balances etc.

Whereas Sockets can be used to get continues data related to trades, user balance, Orderbook, Bracket Order Trades, Order updates.

The python version used for API samples is 3.8 and 3.10.6

Terminology

Common

Orders

Among these, the open-equivalent status' includes:
init, open, partially_filled
Orders having any these status can undergo further change (like when they get filled or cancelled).

And settled or closed-equivalent status' includes:
filled, partially_cancelled, cancelled, rejected
Orders having any of these status could not undergo any change.

Margin Orders



Margin Internal Orders

Setup

To access CoinDCX Public APIs and Sockets you will need

  • Key and Secret
  • Programming and Scripting language (Python and Javascript)
  • Few Libraries (Socket.io, request module, Crypto module)

Follow below mentioned steps for completing the pre-requisite

1. You can get your API key and Secret as follows

  • Go to your CoinDCX profile section
  • Click API dashboard
  • Click Create API key button and enter label name and check Bind IP Address to API key only if you wanna bind the API key with your IP
  • Enter email and SMS OTP
  • Store the Key and Secret visible on the screen

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.

2. For Public APIs

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:

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

You can install the specific version by using the command

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

SPOT API Rate Limits

API Name Rate Limit Period
Create Order Multiple 2000 60s
Create Order 2000 60s
Cancel All 30 60s
Multiple Order Status 2000 60s
Order Status 2000 60s
Cancel Multiple by ID 300 60s
Cancel 2000 60s
Active Order 300 60s
Edit Price 2000 60s

Public endpoints

Ticker

HTTP Request

GET /exchange/ticker

const request = require('request')

const baseurl = "https://api.coindcx.com"

request.get(baseurl + "/exchange/ticker",function(error, response, body) {
    console.log(body);
})
import requests # Install requests module first.

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

Markets

HTTP Request

GET /exchange/v1/markets

const request = require('request')

const baseurl = "https://api.coindcx.com"

request.get(baseurl + "/exchange/v1/markets",function(error, response, body) {
    console.log(body);
})
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"
  .
  .
]

Returns an array of strings of currently active markets.

Markets details

HTTP Request

GET /exchange/v1/markets_details

const request = require('request')

const baseurl = "https://api.coindcx.com"

request.get(baseurl + "/exchange/v1/markets_details",function(error, response, body) {
    console.log(body);
})
import requests # Install requests module first.

url = "https://api.coindcx.com/exchange/v1/markets_details"

response = requests.get(url)
data = response.json()
print(data)

Response:

[
  {
    "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"
  }
]

Response Param Definitions

Parameter Definitions
min_quantity It is the minimum quantity of target currency (SNT) for which an order may be placed
max_quantity It is the maximum quantity of target currency (SNT) for which an order may be placed
min_notional It is the minimum amount of base currency (BTC) for which an order may be placed
base_currency_precision Number of decimals accepted for the base currency
target_currency_precision Number of decimals accepted for the target currency
step It is the minimum increment accepted for the target currency
ecode (Exchange code) It is the unique identifier for exchanges available on CoinDCX. For example: B(Binance), HB(HITBTC), KC(KuCoin)
pair It is a string created by (ecode, target_currency_short_name, base_currency_short_name). It can be used to connect to DcxStreams socket for API trading. For example: B-BTC_USDT, I-BTC_INR, KC-XYZ_USDT
min_price It is the minimum Price for which an order may be placed
max_price It is the maximum Price for which an order may be placed
order_types Different type of orders that can be placed for the market. For example: limit_order, market_order etc
max_leverage It is the max leverage for long positions that is available in this market for margin trading
max_leverage_short It is the max leverage for short positions that is available in this market for margin trading
status This states if a market can be used for trading. Possible values could be active or inactive

Trades

HTTP request

GET /market_data/trade_history

import requests # Install requests module first.

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)
const request = require('request')

const baseurl = "https://public.coindcx.com"

// Replace the "B-BTC_USDT" with the desired market pair.
request.get(baseurl + "/market_data/trade_history?pair=B-BTC_USDT&limit=50",function(error, response, body) {
    console.log(body);
})

Response

[
  {
    "p": 11603.88,
    "q": 0.023519,
    "s": "BTCUSDT",
    "T": 1565163305770,
    "m": false
  }
]

Query parameters

Name Required Example
pair Yes B-SNT_BTC (pair from Market Details API)
limit No Default: 30; Max: 500

This API provides with a sorted list of most recent 30 trades by default if limit parameter is not passed.

Definitions

Order book

const request = require('request')

const baseurl = "https://public.coindcx.com"

// Replace the "B-BTC_USDT" with the desired market pair.
request.get(baseurl + "/market_data/orderbook?pair=B-BTC_USDT",function(error, response, body) {
    console.log(body);
})
import requests # Install requests module first.

url = "https://public.coindcx.com/market_data/orderbook?pair=B-BTC_USDT" # Replace 'SNTBTC' with the desired market pair.

response = requests.get(url)
data = response.json()
print(data)

Response

{
  "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

Name Required Example
pair Yes B-BTC_USDT (pair from Market Details API)

Candles

const request = require('request')

const baseurl = "https://public.coindcx.com"

// Replace the "B-BTC_USDT" with the desired market pair.
request.get(baseurl + "/market_data/candles?pair=B-BTC_USDT&interval=1m",function(error, response, body) {
    console.log(body);
})
import requests # Install requests module first.

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

[
  {
        "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

Name Required Example
pair Yes B-BTC_USDT (pair from Market Details API)
interval Yes any of the valid intervals given below
startTime No timestamp in ms, eg: 1562855417000
endTime No timestamp in ms, eg: 1562855417000
limit No Default: 500; Max: 1000

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

Authentication

To authorize, use this code:

  require 'net/http'
  require 'uri'
  require 'json'
  require 'openssl'



  secret = "Your secret key"
  key = "Your API key"


  payload = {
    "side" : "buy",
    "order_type" : "limit_order",
    "price_per_unit": 0.00001724,
    "market" : "SNTBTC",
    "total_quantity" : 100,
    "timestamp": 1524211224
  }.to_json

  signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), secret, payload)


  headers = {
    'Content-Type' => 'application/json',
    'X-AUTH-APIKEY' => key,
    'X-AUTH-SIGNATURE' => signature
  }

  uri = URI.parse("https://api.coindcx.com/exchange/v1/orders/create")

  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  request = Net::HTTP::Post.new(uri.path, headers)

  request.body = payload

  response = https.request(request)

Sample order creation with auth

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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/orders/create"

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)


const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const   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
    }

    const payload = new Buffer(JSON.stringify(body)).toString();
    const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

    const options = {
        url: baseurl + "/exchange/v1/orders/create",
        headers: {
            'X-AUTH-APIKEY': key,
            'X-AUTH-SIGNATURE': signature
        },
        json: true,
        body: body
    }

    request.post(options, function(error, response, body) {
        console.log(body);
    })

Make sure to replace API key and API secret with your own.

The authentication procedure is as follows:


After this, You will have to add following headers into all the authenticated requests

Header Name Value
X-AUTH-APIKEY your-api-key
X-AUTH-SIGNATURE signature

User

Get 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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/users/balances"

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);

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = ""


const body = {
    "timestamp": timeStamp
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/users/balances",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})

Response:

[
  {
    "currency": "BTC",
    "balance": 1.167,
    "locked_balance": 2.1
  }
]

Locked balance is the balance currently being used by an open order

This endpoint retrieves account's balances.

HTTP Request

POST /exchange/v1/users/balances

Get user info


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/users/info"

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);

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = ""


const body = {
  "timestamp": timeStamp
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
  url: baseurl + "/exchange/v1/users/info",
  headers: {
    'X-AUTH-APIKEY': key,
    'X-AUTH-SIGNATURE': signature
  },
  json: true,
  body: body
}

request.post(options, function(error, response, body) {
  console.log(body);
})

Response:

[
  {
    "coindcx_id": "fda259ce-22fc-11e9-ba72-ef9b29b5db2b",
    "first_name": "First name",
    "last_name": "Last name",
    "mobile_number": "000000000",
    "email": "[email protected]"
  }
]

coindcx_id is the user id

This endpoint retrieves user info.

HTTP Request

POST /exchange/v1/users/info

Order

Enum definitions for the purpose of order are as follows:

Name Values
side buy, sell
order_type market_order, limit_order
order_status open, partially_filled, filled, cancelled, rejected, partially_cancelled, init
ecode I, B, HB, KC

New order


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/orders/create"

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)

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const 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.
    "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
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/orders/create",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})

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"
     }
   ]
}

Use this endpoint to place a new order on the exchange

HTTP Request

POST /exchange/v1/orders/create

Request Parameters

Name Required Example Description
market Yes SNTBTC The trading pair
total_quantity Yes 1.101 Quantity to trade
price_per_unit No 0.082 Price per unit (not required for market order)
side Yes buy Specify buy or sell
order_type Yes market_order Order Type
client_order_id No 2022.02.14-btcinr_1 Client order id of the order
timestamp Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Response Parameters

Name Description
id It's system generated order id
client_order_id It's provided while placing order by the user
market Market for which order has been placed
side Side provided while placing order
order_type Order Type provided while placing order
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
fee This is a Fee in percentage that is used to calculate fee_amount
total_quantity Quantity provided while placing order
remaining_quantity Quantity remaining to be filled
avg_price The price on which the user's order gets executed, it's 0.0 when order is in open status
price_per_unit price_per_unit provided while placing order
created_at It's a time when order was placed
updated_at It's a time when anything related to the order was updated. For example avg_price, total_quantity, status etc

Create multiple orders


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"
    }
  ]
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/orders/create_multiple"

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)

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {"orders": [{
          "side": "buy",  //Toggle between 'buy' or 'sell'.
          "order_type": "limit_order", //Toggle between a 'market_order' or 'limit_order'.
          "market": "BTCINR", //Replace 'SNTBTC' with your desired market.
          "price_per_unit": "466330", //This parameter is only required for a 'limit_order'
          "total_quantity": 0.01, //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": "BTCINR", //Replace 'SNTBTC' with your desired market.
          "price_per_unit": "466330", //This parameter is only required for a 'limit_order'
          "total_quantity": 0.01, //Replace this with the quantity you want
          "timestamp": timeStamp,
          "ecode": "I"
        }
      ]}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
  url: baseurl + "/exchange/v1/orders/create_multiple",
  headers: {
    'X-AUTH-APIKEY': key,
    'X-AUTH-SIGNATURE': signature
  },
  json: true,
  body: body
}

request.post(options, function(error, response, body) {
  console.log(body);
})

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"
     }
   ]
}

Use this endpoint to place a multiple orders on the exchange

HTTP Request

POST /exchange/v1/orders/create_multiple

Parameters in an array of objects

Name Required Example Description
market Yes SNTBTC The trading pair
total_quantity Yes 1.101 Quantity to trade
price_per_unit No 0.082 Price per unit (not required for market order)
side Yes buy Specify buy or sell
order_type Yes market_order Order Type
ecode Yes I Exchange code
client_order_id No 2022.02.14-btcinr_1 Client order id of the order
timestamp Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Order status


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/orders/status"

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)

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
    // "id": "qwd19992-43fd-14e8-b027-bb815bnb14ed", //Replace it with your Order ID.
    "client_order_id": "2022.02.14-btcinr_1", //Replace it with your Client Order ID.
    "timestamp": timeStamp
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/orders/status",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})

Response:

{
  "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"
}

Use this endpoint to fetch status of any order

HTTP Request

POST /exchange/v1/orders/status

Parameters

Name Required Example Description
id No ead19992-43fd-11e8-b027-bb815bcb14ed The ID of the order
client_order_id No 2022.02.14-btcinr_1 The Client Order ID of the order
timestamp Yes 1524211224 When was the request generated (see 'Common Notes' under 'Authentication' heading to read more)

Note: id or client_order_id one of the paramter is required.

Multiple order status


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/orders/status_multiple"

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)

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const 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
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
  url: baseurl + "/exchange/v1/orders/status_multiple",
  headers: {
    'X-AUTH-APIKEY': key,
    'X-AUTH-SIGNATURE': signature
  },
  json: true,
  body: body
}

request.post(options, function(error, response, body) {
  console.log(body);
})

Response:

[
  {
    "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"
  }
]

Use this endpoint to fetch status of any order

HTTP Request

POST /exchange/v1/orders/status_multiple

Parameters

Name Required Example Description
ids No ["ead19992-43fd-11e8-b027-bb815bcb14ed", "8a1d1e4c-c895-11e8-9dff-df1480546936"] Array of order IDs
client_order_ids No ["2022.02.14-btcinr_1", "2022.02.14-btcinr_2"] Array of client order IDs
timestamp Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Note: id or client_order_id one of the paramter is required.

Active orders


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/orders/active_orders"

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)

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
    "side": "buy", //Toggle between 'buy' or 'sell'.
    "market": "SNTBTC", //Replace 'SNTBTC' with your desired market pair.
    "timestamp": timeStamp
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/orders/active_orders",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})

Response:

[
  {
    "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"
  }
]

Use this endpoint to fetch active orders

HTTP Request

POST /exchange/v1/orders/active_orders

Parameters

Name Required Example Description
market Yes SNTBTC
side No buy
timestamp Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Account Trade history


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/orders/trade_history"

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)
const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const 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
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
  url: baseurl + "/exchange/v1/orders/trade_history",
  headers: {
    'X-AUTH-APIKEY': key,
    'X-AUTH-SIGNATURE': signature
  },
  json: true,
  body: body
}

request.post(options, function(error, response, body) {
  console.log(body);
})

Response:

[
  {
    "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
  }
]

Use this endpoint to fetch trades associated with your account

HTTP Request

POST /exchange/v1/orders/trade_history

Parameters

Name Required Example Description
limit No 100 Default: 500, Min: 1, Max: 5000
from_id No 28473 Trade ID after which you want the data. If not supplied, trades in ascending order will be returned
sort No asc Specify asc or desc to get trades in ascending or descending order, default: asc
timestamp Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)
from_timestamp No 1514745000000 Timestamp after which you want the data. If not supplied, all trades from starting will be returned
to_timestamp No 1514745000000 Timestamp before which you want the data. If not supplied, all trades till now will be returned
symbol No SNTBTC Symbol for which you want the data. If not supplied, trades from all symbols will be returned

Active orders count


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

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 = requests.post(url, data = json_body, headers = headers)
data = response.json()
print(data)

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
    "side": "buy", //Toggle between 'buy' or 'sell'.
    "market": "SNTBTC", //Replace 'SNTBTC' with your desired market pair.
    "timestamp": timeStamp
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/orders/active_orders_count",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})

Response:

 { count: 1, status: 200 }

Use this endpoint to fetch active orders count

HTTP Request

POST /exchange/v1/orders/active_orders_count

Parameters

Name Required Example Description
market Yes SNTBTC
side No buy
timestamp Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Cancel all


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/orders/cancel_all"

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)

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const   body = {
        "side": "buy", //Toggle between 'buy' or 'sell'. Not compulsory
        "market": "SNTBTC", //Replace 'SNTBTC' with your desired market pair.
        "timestamp": timeStamp
    }

    const payload = new Buffer(JSON.stringify(body)).toString();
    const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

    const options = {
        url: baseurl + "/exchange/v1/orders/cancel_all",
        headers: {
            'X-AUTH-APIKEY': key,
            'X-AUTH-SIGNATURE': signature
        },
        json: true,
        body: body
    }

    request.post(options, function(error, response, body) {
        console.log(body);
    })

Response:


Use this endpoint to cancel multiple active orders in a single API call

HTTP Request

POST /exchange/v1/orders/cancel_all

Parameters

Name Required Example Description
market Yes SNTBTC
side No buy
timestamp Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Sending side param is optional. You may cancel all the sell orders of SNTBTC by sending
{market: "SNTBTC", side : "sell"}

Or you may cancel all your orders in SNTBTC market by sending
{market: "SNTBTC"}

Cancel multiple By Ids


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

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 = requests.post(url, data = json_body, headers = headers)
data = response.json()
print(data)

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const 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
  }

  const payload = new Buffer(JSON.stringify(body)).toString();
  const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

  const options = {
    url: baseurl + "/exchange/v1/orders/cancel_by_ids",
    headers: {
      'X-AUTH-APIKEY': key,
      'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
  }

  request.post(options, function(error, response, body) {
    console.log(body);
  })

Response:


Use this endpoint to cancel multiple active orders in a single API call

HTTP Request

POST /exchange/v1/orders/cancel_by_ids

Parameters

Name Required Example Description
ids No ["8a2f4284-c895-11e8-9e00-5b2c002a6ff4", "8a1d1e4c-c895-11e8-9dff-df1480546936"] Array of order IDs
client_order_ids No ["2022.02.14-btcinr_1", "2022.02.14-btcinr_2"] Array of Client Order IDs

Note: id or client_order_id one of the paramter is required.

Cancel


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/orders/cancel"

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)

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
    "id": "ead19992-43fd-11e8-b027-bb815bcb14ed", // Replace this with your Order ID.
    // "client_order_id": "2022.02.14-btcinr_1", // Replace this with your Client Order ID.
    "timestamp": timeStamp
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/orders/cancel",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})

Response:


Use this endpoint to cancel an active orders

HTTP Request

POST /exchange/v1/orders/cancel

Parameters

Name Required Example Description
id No ead19992-43fd-11e8-b027-bb815bcb14ed The ID of the order
client_order_id No 2022.02.14-btcinr_1 The Client Order ID of the order
timestamp Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Note: id or client_order_id one of the paramter is required.

Edit Price

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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/orders/edit"

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)
const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "XXXX";
const secret = "YYYY";

const body = {
  "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", // Enter your Order ID here.
  // "client_order_id": "2022.02.14-btcinr_1", // Replace this with your Client Order ID.
  "timestamp": timeStamp,
  "price_per_unit": 123.45 // Enter the new-price here
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/orders/edit",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})

Response:

{
  "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"
}

Use this endpoint to edit the price of an active order

HTTP Request

POST /exchange/v1/orders/edit

Parameters

Name Required Example Description
id No ead19992-43fd-11e8-b027-bb815bcb14ed The ID of the order
client_order_id No 2022.02.14-btcinr_1 The Client Order ID of the order
price_per_unit Yes 123.45 New Price for the order
timestamp Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Note: id or client_order_id one of the paramter is required.

Lend Order

Fetch Orders


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/funding/fetch_orders"

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)

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
  "timestamp": timeStamp
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/funding/fetch_orders",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})

Response:


[ { "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 } ]

Use this endpoint to fetch orders and its details

HTTP Request

POST /exchange/v1/funding/fetch_orders

Parameters

Name Type Required Example Description
timestamp number Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Lend


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 = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/funding/lend"

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)

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
  "currency_short_name": "BTC",
  "duration": 20,
  "amount": 0.5,
  "timestamp": timeStamp
},


const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/funding/lend",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})

Response:


[ { "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 } ]

Use this endpoint to lend specified currency on the exchange.

HTTP Request

POST /exchange/v1/funding/lend

Parameters

Name Type Required Example Description
currency_short_name string Yes XRP The lending currency
amount number Yes 11 Quantity to lend
duration number Yes 20 The Time period for which you want to lend the currency in days
timestamp number Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Settle


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/funding/settle"

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)

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
  "id": "ead19992-43fd-11e8-b027-bb815bcb14ed",
  "timestamp": timeStamp
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/funding/settle",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})

Response:


[ { "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 } ]


Use this endpoint to settle lend order.

HTTP Request

POST /exchange/v1/funding/settle

Parameters

Name Type Required Example Description
id string Yes ead19992-43fd-11e8-b027-bb815bcb14ed The ID of the order
timestamp number Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Margin Order

Enum definitions for the purpose of order are as follows:

Name Values
side buy, sell
order_type market_order, limit_order, stop_limit, take_profit
order_status init, partial_entry, open, partial_close, close, cancelled, rejected, triggered
timestamp 1524211224
ecode B

Place Order


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/margin/create"

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)

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
  "side": "buy",
  "order_type": "limit_order",
  "market": "XRPBTC",
  "price": 0.000025,
  "quantity": 90,
  "ecode": 'B',
  "leverage": 1,
  "timestamp": timeStamp
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/margin/create",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(JSON.stringify(body, null, 2));
})

Response:

[{
  "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
  }]
}]

Use this endpoint to place a new order on the exchange.

HTTP Request

POST /exchange/v1/margin/create

Parameters

Name Type Required Example Description
market string Yes XRPBTC The trading pair
quantity number Yes 1.101 Quantity to trade
price number No 0.082 Price per unit (not required for market order, mandatory for rest)
leverage number No 1 Borrowed capital to increase the potential returns
side string Yes buy Specify buy or sell
stop_price number No 0.082 Price to stop the order at(mandatory in case of stop_limit & take_profit)
order_type string Yes market_order Order Type
trailing_sl boolean No true To place order with Trailing Stop Loss
target_price number No 0.082 The price to buy/sell or close the order position
ecode string Yes B Exchange code in which the order will be placed
timestamp number Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Cancel Order


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/margin/cancel"

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)

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
  "id": "qwd19992-43fd-14e8-b027-bb815bnb14ed",
  "timestamp": timeStamp
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/margin/cancel",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})

Response:

{
  "message": "Cancellation accepted",
  "status": 200,
  "code": 200
}

Use this endpoint to cancel any order.

HTTP Request

POST /exchange/v1/margin/cancel

Parameters

Name Type Required Example Description
id string Yes ead19992-43fd-11e8-b027-bb815bcb14ed The ID of the order
timestamp number Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Exit


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/margin/exit"

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)

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
  "id": "ead19992-43fd-11e8-b027-bb815bcb14ed",
  "timestamp": timeStamp
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/margin/exit",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})

Response:

{
  "message": "Order exit accepted",
  "status": 200,
  "code": 200
}

Use this endpoint to exit any order.

HTTP Request

POST /exchange/v1/margin/exit

Parameters

Name Type Required Example Description
id string Yes ead19992-43fd-11e8-b027-bb815bcb14ed The ID of the order
timestamp number Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Edit Target


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/margin/edit_target"

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)

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
  "id": "8a2f4284-c895-11e8-9e00-5b2c002a6ff4",
  "target_price": 0.6,
  "timestamp": timeStamp
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
  url: baseurl + "/exchange/v1/margin/edit_target",
  headers: {
    'X-AUTH-APIKEY': key,
    'X-AUTH-SIGNATURE': signature
  },
  json: true,
  body: body
}

request.post(options, function(error, response, body) {
  console.log(body);
})

Response:

{
  "message": "Target price updated",
  "status": 200,
  "code": 200
}

Use this endpoint to edit the target price of any order.

HTTP Request

POST /exchange/v1/margin/edit_target

Parameters

Name Type Required Example Description
id string Yes 8a2f4284-c895-11e8-9e00-5b2c002a6ff4 ID of the order to edit
target_price number Yes 0.082 The new price to buy/sell or close the order position at
timestamp number Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Edit Price of Target Order


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

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 = requests.post(url, data = json_body, headers = headers)
data = response.json()
print(data)

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
  "id": "",
  "target_price": 0.00026,
  "itpo_id": "",
  "timestamp": timeStamp
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/margin/edit_price_of_target_order",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})

Response:

{
  "message": "Target price updated",
  "status": 200,
  "code": 200
}

Use this endpoint to edit price of internal target order.

HTTP Request

POST /exchange/v1/margin/edit_price_of_target_order

Parameters

Name Type Required Example Description
id string Yes ead19992-43fd-11e8-b027-bb815bcb14ed
target_price number Yes 0.082 The new price to buy/sell or close the order position at
itpo_id string Yes 164968 ID of internal order to edit
timestamp number Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Edit SL Price


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/margin/edit_sl"

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)
const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
  "id" : "",
  "sl_price": 0.06,
  "timestamp": timeStamp
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
  url: baseurl + "/exchange/v1/margin/edit_sl",
  headers: {
    'X-AUTH-APIKEY': key,
    'X-AUTH-SIGNATURE': signature
  },
  json: true,
  body: body
}

request.post(options, function(error, response, body) {
  console.log(body);
})

Response:

{
  "message": "SL price updated",
  "status": 200,
  "code": 200
}

Use this endpoint to edit stop loss price of a bracket order.

HTTP Request

POST /exchange/v1/margin/edit_sl

Parameters

Name Type Required Example Description
id string Yes ead19992-43fd-11e8-b027-bb815bcb14ed ID of Margin Order
sl_price number Yes 0.082 The price to Stop Loss at
timestamp number Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Edit SL Price of Trailing Stop Loss


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

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 = requests.post(url, data = json_body, headers = headers)
data = response.json()
print(data)
const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
  "id" : "",
  "sl_price": 0.06,
  "timestamp": timeStamp
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
  url: baseurl + "/exchange/v1/margin/edit_trailing_sl",
  headers: {
    'X-AUTH-APIKEY': key,
    'X-AUTH-SIGNATURE': signature
  },
  json: true,
  body: body
}

request.post(options, function(error, response, body) {
  console.log(body);
})

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

POST /exchange/v1/margin/edit_trailing_sl

Parameters

Name Type Required Example Description
id string Yes ead19992-43fd-11e8-b027-bb815bcb14ed ID of Margin Order
sl_price number Yes 0.082 The new price to Stop Loss at
timestamp number Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Add Margin


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/margin/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)
const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
  "id" : "",
  "amount": 0.06,
  "timestamp": timeStamp
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
  url: baseurl + "/exchange/v1/margin/add_margin",
  headers: {
    'X-AUTH-APIKEY': key,
    'X-AUTH-SIGNATURE': signature
  },
  json: true,
  body: body
}

request.post(options, function(error, response, body) {
  console.log(body);
})

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.

HTTP Request

POST /exchange/v1/margin/add_margin

Parameters

Name Type Required Example Description
id string Yes ead19992-43fd-11e8-b027-bb815bcb14ed ID of Margin Order
amount number Yes 0.06 Amount to add in the margin to decrease effective leverage
timestamp number Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Remove Margin


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/margin/remove_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)
const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
  "id" : "",
  "amount": 0.06,
  "timestamp": timeStamp
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
  url: baseurl + "/exchange/v1/margin/remove_margin",
  headers: {
    'X-AUTH-APIKEY': key,
    'X-AUTH-SIGNATURE': signature
  },
  json: true,
  body: body
}

request.post(options, function(error, response, body) {
  console.log(body);
})

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.

HTTP Request

POST /exchange/v1/margin/remove_margin

Parameters

Name Type Required Example Description
id string Yes ead19992-43fd-11e8-b027-bb815bcb14ed ID of Margin Order
amount number Yes 0.06 Amount to remove from the margin to increase effective leverage
timestamp number Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Fetch Orders


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/margin/fetch_orders"

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)
const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
  "details": true,
  "market": "LTCBTC",
  "status":"open",
  "size":20,
  "timestamp": timeStamp
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/margin/fetch_orders",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(JSON.stringify(body, null, 2));
})

Response:

[{
    "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,
    "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

Name Type Required Example Description
market string No XRPBTC The trading pair, default: Orders for all market
details boolean No false Whether you want detailed information or not, default: false
status string No init,open,close,rejected,cancelled,

partial_entry,partial_close,triggered
The status of the order, default: All orders
size number No 20 Number of records per page, default: 10
timestamp number Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Query Order


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
}

json_body = json.dumps(body, separators = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/margin/order"

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)
const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
  "details": true,
  "id": "30b5002f-d9c1-413d-8a8d-0fd32b054c9c",
  "timestamp": timeStamp
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/margin/order",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(JSON.stringify(body, null, 2));
})

Response:

[{
    "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

POST /exchange/v1/margin/order

Parameters

Name Type Required Example Description
id string Yes 30b5002f-d9c1-413d-8a8d-0fd32b054c9c Id of the order
details boolean No false Whether you want detailed information or not, default: false
timestamp number Yes 1524211224 Timestamp at which the request was generated (see 'Common Notes' under 'Authentication' heading to read more)

Pagination

Get the pagination details in the response header

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
  "details": true,
  "market": "LTCBTC",
  "page": 2,
  "size": 5,
  "timestamp": timeStamp
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/margin/fetch_orders",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})

Parameters

Name Description
page Page number to fetch. Pagination starts at page 1
size Number of records per page; Default: 100, Max: 1000

Response Headers

{
  date: 'Wed, 11 Sep 2019 09:38:19 GMT',
  'content-type': 'application/json; charset=utf-8',
  'transfer-encoding': 'chunked',
  connection: 'close',
  status: '200 OK',
  'x-frame-options': 'SAMEORIGIN',
  'x-xss-protection': '1; mode=block',
  'x-content-type-options': 'nosniff',
  'x-pagination': '{"total":29,"total_pages":6,"first_page":false,"last_page":false,"previous_page":1,"next_page":3,"out_of_bounds":false,"offset":5}',
  .
  .
  .
  .
}

Sockets

PUBLIC

To connect to public socket

Refer to the right panel.

Below chart states the channel to event flow

Socket channel flow

import socketio

def my_headers():
    return {"origin": "*"}

socketEndpoint = 'https://stream.coindcx.com'
sio = socketio.Client()

sio.connect(socketEndpoint, transports = 'websocket')

# Listen update on channelName
@sio.on('channelName')
def on_message(response):
    print(response.data)

# 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!")

import io from 'socket.io-client';

const socketEndpoint = "https://stream.coindcx.com";

const socket = io.connect(socketEndpoint, {
  transports: ['websocket'],
  origin: '*',
});


//Listen update on channelName
socket.on('eventName', (response) => {
  console.log(response.data);
});

socket.connect();

// client-side
socket.on("connect", () => {
  console.log(socket.id,'coindcx'); // x8WIv7-mJelg7on_ALbx
  //Join Channel
  socket.emit('join', {
    'channelName': "channelName",
  });
});

// leave a channel
socket.emit('leave', {
  'channelName': "channelName"
});

//These examples has been tested on the following socket.io versions :
// 1. socket.io-2.3.1.js
// 2. socket.io-2.3.0.js
// 3. socket.io-2.2.0.js 
// 4. socket.io-1.0.0.js 

Order book

Definitions

Response

@sio.on('depth-update')
def on_message(response):
    print(response['data'])
socket.on("depth-update", (response) => {
  console.log(response.data);
});

Order book response:

{
  "e": "depthUpdate",
  "E": 1634554090549,
  "s": "BTCUSDT",
  "U": 14413233916,
  "u": 14413233992,
  "b": [
    [
      "61139.63000000",
      "0.02000000"
    ]
  ],
  "a": [
    [
      "61181.01000000",
      "2.52715000"
    ]
  ],
  "type": "depth-update",
  "channel": "B-BTC_USDT"
}

Trades

Definitions

Response

@sio.on('new-trade')
def on_message(response):
  print(response.data)
socket.on("new-trade", (response) => {
  console.log(response.data);
});

Trade response:

{
  "T": 1545896665076,
  "p": 0.9634e-4,
  "q": 0.1e1,
  "s": "XRPBTC",
  "m": true,
  "type":"new-trade",
  "channel":"B-BTC_USDT"
}

ACCOUNT

To connect to the account socket

Get your API key and Secret by simply following these steps:

Refer to the right panel.


import socketio
import hmac
import hashlib
import json
socketEndpoint = 'wss://stream.coindcx.com'
sio = socketio.Client()

sio.connect(socketEndpoint, transports = 'websocket')

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 })

# Listen update on eventName
@sio.on('eventName')
def on_message(response):
    print(response["data"])

# leave a channel
sio.emit('leave', { 'channelName' : 'coindcx' })


//For commonJS(NPM)
const io = require("socket.io-client");
const crypto = require('crypto');

/// ES6 import or TypeScript
import io from 'socket.io-client';
import crypto from 'crypto';


const socketEndpoint = "wss://stream.coindcx.com";

//connect to server.
const socket = io(socketEndpoint, {
  transports: ['websocket']
});

const secret = "secret";
const key = "key";


const body = { channel: "coindcx" };
const payload = Buffer.from(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

socket.on("connect", () => {
  //Join channel
  socket.emit('join', {
    'channelName': "coindcx",
    'authSignature': signature,
    'apiKey' : key
  });
});


//Listen update on eventName
socket.on("eventName", (response) => {
  console.log(response.data);
});


// In order to leave a channel
socket.emit('leave', {
  'channelName': 'coindcx'
});

// NOTE : Need to use V2 Socket.io-client

Balances

Definitions

Response

@sio.on('balance-update')
def on_message(response):
  if response["event"] == 'balance-update':
    print(response["data"])
socket.on("balance-update", (response) => {
  if (response.event == "balance-update") {
    console.log(response.data);
  }
});

Balance update response:

{
  "balance": "1000.00000000",
  "locked_balance": "1.00000000",
  "currency": "XRP"
}

Trades

Definitions

Response

@sio.on('trade-update')
def on_message(response):
    print(response["data"])
socket.on("trade-update", (response) => {
  console.log(response.data);
});

Trade update response:

[{
  "o": "28c58ee8-09ab-11e9-9c6b-8f2ae34ea8b0",
  "c": "2022.02.14-btcinr_1",
  "t": "17105",
  "s": "XRPBTC",
  "p": "0.00009634",
  "q": "1.0",
  "T": 1545896665076,
  "m": true,
  "f": "0.000000009634",
  "e": "I",
  "x": "filled"
}]

Order Updates

Definitions

Response

@sio.on('order-update')
def on_message(response):
  print(response["data"])
socket.on("order-update", (response) => {
  console.log(response.data);
});

Order update response:

[
  {
    "id": "axxxxxxa-axxa-axxa-axxa-axxxxxxxxxxa",
    "client_order_id": "2022.02.14-btcinr_1",
    "order_type": "limit_order",
    "side": "buy",
    "status": "open",
    "fee_amount": 0,
    "fee": 0.1,
    "maker_fee": 0.1,
    "taker_fee": 0.1,
    "total_quantity": 0.0005,
    "remaining_quantity": 0.0005,
    "source": "web",
    "base_currency_name": "Indian Rupee",
    "target_currency_name": "Bitcoin",
    "base_currency_short_name": "INR",
    "target_currency_short_name": "BTC",
    "base_currency_precision": 2,
    "target_currency_precision": 5,
    "avg_price": 0,
    "price_per_unit": 3015016.03,
    "stop_price": 0,
    "market": "BTCINR",
    "time_in_force": "good_till_cancel",
    "created_at": 1647418697307,
    "updated_at": 1647418697307
  }
]

Bracket Order Trades

Definitions

Response

@sio.on('bo-trade-update')
def on_message(response):
    print(response.data)
socket.on("bo-trade-update", (response) => {
  console.log(response.data);
});

Bracket Order Trade update response:

[{
  "id": "dbbce8e2-48e6-4aa2-a7af-15463120e241",
  "side": "sell",
  "status": "open",
  "market": "XRPBTC",
  "order_type": "market_order",
  "trailing_sl": false,
  "trail_percent": null,
  "avg_entry": 0.00003414,
  "avg_exit": 0,
  "fee": 0.02,
  "entry_fee": 4.8e-7,
  "exit_fee": 0,
  "active_pos": 70,
  "exit_pos": 0,
  "total_pos": 70,
  "quantity": 70,
  "price": 0.00003415,
  "sl_price": 0.00004866,
  "target_price": 0,
  "stop_price": 0,
  "pnl": 0,
  "initial_margin": 0.0011962062,
  "interest": 0.05,
  "interest_amount": 0,
  "leverage": 2,
  "result": null,
  "created_at": 1570620552918,
  "updated_at": 1570620553456,
  "orders": [{
    "id": 165059,
    "order_type": "market_order",
    "status": "filled",
    "market": "XRPBTC",
    "side": "sell",
    "avg_price": 0.00003414,
    "total_quantity": 70,
    "remaining_quantity": 0,
    "price_per_unit": 0,
    "timestamp": 1570620552975.75,
    "fee": 0.02,
    "fee_amount": 4.8e-7,
    "filled_quantity": 70,
    "bo_stage": "stage_entry",
    "cancelled_quantity": 0,
    "stop_price": 0
  }]
}]

Futures End Points

Glossary

Get active instruments

HTTP Request

GET /exchange/v1/derivatives/futures/data/active_instruments

const request = require('request')

const baseurl = "https://api.coindcx.com"

request.get(baseurl + "/exchange/v1/derivatives/futures/data/active_instruments",function(error, response, body) {
    console.log(body);
})
import requests # Install requests module first.

url = "https://api.coindcx.com/exchange/v1/derivatives/futures/data/active_instruments"

response = requests.get(url)
data = response.json()
print(data)

Response

[
    "B-MKR_USDT",
    "B-JTO_USDT",
    "B-1000SATS_USDT",
    "B-SFP_USDT",
    "B-POLYX_USDT",
    "B-BADGER_USDT",
    "B-CYBER_USDT",
    "B-MTL_USDT",
    "B-MDT_USDT",
    "B-BEAMX_USDT",
    "B-AUCTION_USDT",
    "B-ANKR_USDT",
   ]

Get instrument details

HTTP Request

GET https://api.coindcx.com/exchange/v1/derivatives/futures/data/instrument?pair={instrument}

const request = require('request')
const url = "https://api.coindcx.com/exchange/v1/derivatives/futures/data/instrument?pair={instrument}"
//const sample_url = "https://api.coindcx.com/exchange/v1/derivatives/futures/data/instrument?pair=B-MKR_USDT"
request.get(url ,function(error, response, body) {
    console.log(body);})
import requests  # Install requests module first.
url = "https://api.coindcx.com/exchange/v1/derivatives/futures/data/instrument?pair={instrument}"
#sample_url = "https://api.coindcx.com/exchange/v1/derivatives/futures/data/instrument?pair=B-MKR_USDT"
response = requests.get(url)
data = response.json()
print(data)

Response

{
    "instrument": {
        "settle_currency_short_name": "USDT",
        "quote_currency_short_name": "USDT",
        "position_currency_short_name": "MATIC",
        "underlying_currency_short_name": "MATIC",
        "status": "inactive",
        "pair": "BM-MATIC_USDT",
        "kind": "perpetual",
        "settlement": "never",
        "max_leverage_long": 12,
        "max_leverage_short": 12,
        "unit_contract_value": 0.01,
        "price_increment": 0.0001,
        "quantity_increment": 1000,
        "min_trade_size": 1000,
        "min_price": 0.05,
        "max_price": 1000,
        "min_quantity": 1000,
        "max_quantity": 1000000000,
        "min_notional": null,
        "maker_fee": 0.01,
        "taker_fee": 0.075,
        "safety_percentage": 2.5,
        "quanto_to_settle_multiplier": 1,
        "is_inverse": false,
        "is_quanto": false,
        "allow_post_only": true,
        "allow_hidden": false,
        "max_market_order_quantity": null,
        "funding_frequency": null,
        "max_notional": 1000000,
        "expiry_time": 2524651260000,
        "time_in_force_options": [
            "good_till_cancel",
            "immediate_or_cancel",
            "fill_or_kill"
        ],
        "order_types": [
            "limit_order",
            "market_order",
            "stop_limit"
        ]
    }
}

Get instrument Real-time trade history

HTTP Request

GET https://api.coindcx.com/exchange/v1/derivatives/futures/data/trades?pair={instrument_name}

const request = require('request')
const url = "https://api.coindcx.com/exchange/v1/derivatives/futures/data/trades?pair={instrument_name}"
//const sample_url = "https://api.coindcx.com/exchange/v1/derivatives/futures/data/trades?pair=B-MKR_USDT"
request.get(url ,function(error, response, body) {
    console.log(body);})
import requests  # Install requests module first.
url = "https://api.coindcx.com/exchange/v1/derivatives/futures/data/trades?pair={instrument_name}"
#sample_url = "https://api.coindcx.com/exchange/v1/derivatives/futures/data/trades?pair=B-MKR_USDT"
response = requests.get(url)
data = response.json()
print(data)

Response

[
    {
        "price": 1.1702,
        "quantity": 22000,
        "timestamp": 1675037938736,
        "is_maker": true
    },
    {
        "price": 1.1702,
        "quantity": 38000,
        "timestamp": 1675037950130,
        "is_maker": true
    }
]

Get instrument orderbook

HTTP Request

GET https://public.coindcx.com/market_data/v3/orderbook/{instrument}-futures/50

const request = require('request')
const url = "https://public.coindcx.com/market_data/v3/orderbook/{instrument}-futures/50"
//const 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
request.get(url ,function(error, response, body) {
    console.log(body);})
import requests  # Install requests module first.

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

{
    "ts": 1705483019891,
    "vs": 27570132,
    "asks": {
        "2001": "2.145",
        "2002": "4.453",
        "2003": "2.997"
    },
    "bids": {
        "1995": "2.618",
        "1996": "1.55"
    }
}

Get instrument candlesticks

HTTP Request

GET https://public.coindcx.com/market_data/candlesticks?pair={pair}&from={from}&to={to}&resolution={resolution}&pcode=f

const request = require('request')
const url = "https://public.coindcx.com/market_data/candlesticks?pair={pair}&from={from}&to={to}&resolution={resolution}&pcode=f"
request.get(url ,function(error, response, body) {
    console.log(body);})
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

HTTP Request

POST https://api.coindcx.com/exchange/v1/derivatives/futures/orders

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const 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
}
const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')
const options = {
    url: baseurl + "/exchange/v1/derivatives/futures/orders",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}
request.post(options, function(error, response, body) {
    console.log(body);
})

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
        }

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/orders"

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

[
   {
      "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",
      "display_message":"ETH limit buy order placed!",
      "group_status":"None",
      "created_at":1705565256365,
      "updated_at":1705565256940
   },
   {
      "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",
      "display_message":"ID market buy order filled!",
      "group_status":"None",
      "created_at":1705565061504,
      "updated_at":1705565062462
   }
]


Create Order

HTTP Request

POST https://api.coindcx.com/exchange/v1/derivatives/futures/orders/create

Note : "Do not include 'time_in _force' parameter for market orders."

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
"timestamp": timeStamp , // EPOCH timestamp in seconds
"order": {
"side": "enum", // buy OR sell
"pair": "string", // instrument.string
"order_type": "enum", // market_order OR limit_order 
"price": "numeric",
"total_quantity": "numeric",
"leverage": "integer",
"notification": "enum", // no_notification OR email_notification OR push_notification
"time_in_force": "enum", // good_till_cancel OR fill_or_kill OR immediate_or_cancel
"hidden": "boolean",
"post_only": "boolean"
}
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/derivatives/futures/orders/create",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})

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
        "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
        }
        }

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/orders/create"

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

[
   {
      "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",
      "display_message":"None",
      "group_status":"None",
      "created_at":1705647376759,
      "updated_at":1705647376759
   }
]

Cancel Order

HTTP Request

POST https://api.coindcx.com//exchange/v1/derivatives/futures/orders/cancel

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
    "timestamp": timeStamp , // EPOCH timestamp in seconds
    "id": "string" // order.id
    }

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/derivatives/futures/orders/cancel",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})



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
        }


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/orders/cancel"

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
}

List Positions

HTTP Request

POST https://api.coindcx.com/exchange/v1/derivatives/futures/positions

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
        "timestamp": timeStamp , // EPOCH timestamp in seconds
        "page": "1", //no . of pages needed
        "size": "10" //no. of records needed
        }
const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/derivatives/futures/positions",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})
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" #no. of records needed
        }


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"

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

[
   {
      "id":"434dc174-6503-4509-8b2b-71b325fe417a",
      "pair":"B-ETH_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":"None",
      "stop_loss_trigger":"None",
      "updated_at":1705644363791
   },
   {
      "id":"e65e8b77-fe7c-40c3-ada1-b1d4ea40465f",
      "pair":"B-ID_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,
      "updated_at":1705565210793
   }
]


Add Margin

HTTP Request

POST https://api.coindcx.com/exchange/v1/derivatives/futures/positions/add_margin

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
    "timestamp": timeStamp , // EPOCH timestamp in seconds
    "id": "434dc174-6503-4509-8b2b-71b325fe417a", // position.id
    "amount": 1
    }

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/derivatives/futures/positions/add_margin",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})

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
        }   


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/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
}


Remove Margin

HTTP Request

POST https://api.coindcx.com/exchange/v1/derivatives/futures/positions/remove_margin

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"
const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
        "timestamp": timeStamp , // EPOCH timestamp in seconds
        "id": "434dc174-6503-4509-8b2b-71b325fe417a", // position.id
        "amount": 10
        }
const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')
const options = {
    url: baseurl + "/exchange/v1/derivatives/futures/positions/remove_margin",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})


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
        }



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/remove_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
}


Cancel All Open Orders

HTTP Request

POST https://api.coindcx.com/exchange/v1/derivatives/futures/positions/cancel_all_open_orders

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
            "timestamp": timeStamp  // EPOCH timestamp in seconds
            }



const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/derivatives/futures/positions/cancel_all_open_orders",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})



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
}




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/cancel_all_open_orders"

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
}


Cancel All Open Orders for Position

HTTP Request

POST https://api.coindcx.com/exchange/v1/derivatives/futures/positions/cancel_all_open_orders_for_position

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
        "timestamp":timeStamp , // EPOCH timestamp in seconds
        "id": "434dc174-6503-4509-8b2b-71b325fe417a" // position.id
        }



const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/derivatives/futures/positions/cancel_all_open_orders_for_position",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})

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
    }




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/cancel_all_open_orders_for_position"

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
}


Exit Position

HTTP Request

POST https://api.coindcx.com/exchange/v1/derivatives/futures/positions/exit

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
        "timestamp": timeStamp , // EPOCH timestamp in seconds
        "id": "434dc174-6503-4509-8b2b-71b325fe417a" // position.id
        }


const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/derivatives/futures/positions/exit",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})


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
    }




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/exit"

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,
   "data":{
      "group_id":"baf926e6B-ID_USDT1705647709"
   }
}


Create Take Profit and Stop Loss Orders

HTTP Request

POST https://api.coindcx.com/exchange/v1/derivatives/futures/positions/create_tpsl

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const 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
  }
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/derivatives/futures/positions/create_tpsl",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})



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
  }
}




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/create_tpsl"

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

{
   "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",
      "created_at":1705915027938,
      "updated_at":1705915028003
   },
   "take_profit":{
      "success":false,
      "error":"TP already exists"
   }
}



Get Transactions

HTTP Request

POST https://api.coindcx.com/exchange/v1/derivatives/futures/positions/transactions

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const body = {
        "timestamp": timeStamp, // EPOCH timestamp in seconds
        "position_ids": "e65e8b77-fe7c-40c3-ada1-b1d4ea40465f", // Comma separated position.id
        "stage": "all", // all OR default OR funding
        "page": "1", //no. of pages needed
        "size": "10" //no. of records needed
        }

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/derivatives/futures/positions/transactions",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})




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
  "position_ids": "e65e8b77-fe7c-40c3-ada1-b1d4ea40465f", # Comma separated position.id
  "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 = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/derivatives/futures/positions/transactions"

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

[
   {
      "pair":"B-ID_USDT",
      "stage":"default",
      "amount":0.0495,
      "fee_amount":0.007368075,
      "price_in_inr":88.21,
      "price_in_btc":2.4085979238367e-05,
      "price_in_usdt":1.0,
      "source":"user",
      "parent_type":"Derivatives::Futures::Order",
      "parent_id":"34527a16-8238-4aca-a3b4-08950dc9ac90",
      "position_id":"e65e8b77-fe7c-40c3-ada1-b1d4ea40465f",
      "created_at":1705647710699,
      "updated_at":1705647710734
   }
]




Get Trades

HTTP Request

POST https://api.coindcx.com/exchange/v1/derivatives/futures/trades

const request = require('request')
const crypto = require('crypto')

const baseurl = "https://api.coindcx.com"

const timeStamp = Math.floor(Date.now());
// To check if the timestamp is correct
console.log(timeStamp);

// Place your API key and secret below. You can generate it from the website.
const key = "";
const secret = "";


const 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
}

const payload = new Buffer(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

const options = {
    url: baseurl + "/exchange/v1/derivatives/futures/trades",
    headers: {
        'X-AUTH-APIKEY': key,
        'X-AUTH-SIGNATURE': signature
    },
    json: true,
    body: body
}

request.post(options, function(error, response, body) {
    console.log(body);
})





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 = (',', ':'))

signature = hmac.new(secret_bytes, json_body.encode(), hashlib.sha256).hexdigest()

url = "https://api.coindcx.com/exchange/v1/derivatives/futures/trades"

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

[
  {
     "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"
  }
]

Futures Sockets

Glossary

ACCOUNT

import socketio
import hmac
import hashlib
import json
socketEndpoint = 'wss://stream.coindcx.com'
sio = socketio.Client()

sio.connect(socketEndpoint, transports = 'websocket')

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 })

### Listen update on eventName
### Replace the <eventName> with the df-position-update, df-order-update, ###balance-update

@sio.on(<eventName>) 
def on_message(response):
    print(response["data"])

# leave a channel
sio.emit('leave', { 'channelName' : 'coindcx' })

//For commonJS(NPM)
const io = require("socket.io-client");
const crypto = require('crypto');

/// ES6 import or TypeScript
import io from 'socket.io-client';
import crypto from 'crypto';


const socketEndpoint = "wss://stream.coindcx.com";

//connect to server.
const socket = io(socketEndpoint, {
  transports: ['websocket']
});

const secret = "secret";
const key = "key";


const body = { channel: "coindcx" };
const payload = Buffer.from(JSON.stringify(body)).toString();
const signature = crypto.createHmac('sha256', secret).update(payload).digest('hex')

socket.on("connect", () => {
  //Join channel
  socket.emit('join', {
    'channelName': "coindcx",
    'authSignature': signature,
    'apiKey' : key
  });
});


//Listen update on eventName
//Replace the <eventName> with the df-position-update, df-order-update, //balance-update
socket.on(<eventName>, (response) => {
  console.log(response.data);
});


// In order to leave a channel
socket.emit('leave', {
  'channelName': 'coindcx'
});

// NOTE : Need to use V2 Socket.io-client

Get Position Update

Definitions

@sio.on('df-position-update')
def on_message(response):
  print(response["data"])
socket.on("df-position-update", (response) => {
  console.log(response.data);
});

Response:

[
   {
      "id":"e65e8b77-fe7c-40c3-ada1-b1d4ea40465f",
      "pair":"B-ID_USDT",
      "active_pos":35,
      "inactive_pos_buy":0,
      "inactive_pos_sell":0,
      "avg_price":0.2839,
      "liquidation_price":0.261452618175,
      "locked_margin":0.984388363875,
      "locked_user_margin":0.99478995,
      "locked_order_margin":0,
      "take_profit_trigger":0,
      "stop_loss_trigger":0.271,
      "updated_at":1705999727738
   }
]

Get Order Update

Definitions

@sio.on('df-order-update')
def on_message(response):
  print(response["data"])
socket.on("df-order-update", (response) => {
  console.log(response.data);
});

Response:

[
   {
      "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
   }
]

Get Balance Update

Definitions

@sio.on('balance-update')
def on_message(response):
  print(response["data"])
socket.on("balance-update", (response) => {
  console.log(response.data);
});

Response:

[
   {
      "id":"026ef0f2-b5d8-11ee-b182-570ad79469a2",
      "balance":"1.0221449",
      "locked_balance":"0.99478995",
      "currency_id":"c19c38d1-3ebb-47ab-9207-62d043be7447",
      "currency_short_name":"USDT"
   }
]

Get Candlestick Data

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"])
socket.on("candlestick", (response) => {
  console.log(response.data);
});


Response:

{
   "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"])
socket.on("depth-snapshot", (response) => {
  console.log(response.data);
});

Response:

{
   "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"
}

Get Current Prices

Definitions

@sio.on('currentPrices@futures#update')
def on_message(response):
  print(response["data"])
socket.on("currentPrices@futures#update", (response) => {
  console.log(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
      }
   }
}

Get New Trade

Definitions

@sio.on('new-trade')
def on_message(response):
  print(response["data"])
socket.on("new-trade", (response) => {
  console.log(response.data);
});

Response:

{
  "T":1705516361108,
  "RT":1705516416271.6133,
  "p":"0.3473",
  "q":"40",
  "m":1,
  "s":"B-ID_USDT",
  "pr":"f"
}

Get LTP Data

Definitions

@sio.on('price-change')
def on_message(response):
  print(response["data"])
socket.on("price-change", (response) => {
  console.log(response.data);
});

Response:

{
  "T":1705516361108,
  "p":"0.3473",
  "pr":"f"
}

Sample code for Socket Connection

Definitions

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()


async def ping_task():
    while True:
        await asyncio.sleep(25)
        try:
            await sio.emit('ping', {'data': 'Ping message'})
        except Exception as e:
            print(f"Error sending ping: {e}")


@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"))

    await sio.emit('join', {'channelName': "coindcx", 'authSignature': signature, 'apiKey': key})
    await sio.emit('join', {'channelName': "B-ID_USDT@prices-futures"})


@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)


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('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


# Run the main function
if __name__ == '__main__':
    asyncio.run(main())

Response:


FAQ

From where to start

Refer Setup section for the details

Authentication
1. How to generate Key and Secret for a user

Refer Setup section for the details

2. Can a user have multiple Key and Secret

Yes, there are no restriction on creating Key and Secret.

3. Are there Read Only APIs available for CoinDCX Public APIs

No, we currently don't have Read Only APIs.

4. Can the same API Key be regenerated once it gets deleted

No, you’ll need to generate a new API key and secret for security purposes.

5. Can I use the same API key secret everytime also can I share them with someone else

Since all API users have the same level of permissions, API keys are interchangeable. However in case
you choose to bind API keys with IP addresses, you might need to create a different API key for every user.

General API
1. What are the rate limits applicable on CoinDCX APIs

16/sec, 960/min

2. In the case of an API failure what is the HTTP status code returned by the CoinDCX APIs?

In the case of API failure you get a 5xx error. The 2 applicable errors are:

  • 500: Internal Server Error. This is a one-off error that happens due to internal issues on CoinDCX’s side
  • 503: Service Unavailable. This error is thrown when there is a downtime at CoinDCX. These should get resolved fairly quickly.

For scheduled downtimes, you would receive prior notification over e-mail from the email ID [email protected] among other CoinDCX email IDs.
Please add us to your address-book so as to not miss such important emails.

3. What is High Frequency Trading

High frequency trading refers to trading activity done through automated programs that generally take advantage of market inefficiencies to make money.

4. What's the maximum size of a trade that can be executed via APIs

This can be found from the max_quantity key from Market Details API.This detail is available at a per pair/market level and depends on the Exchange that you are trading on.

5. Is there any API that's available to list all the trading transactions of the account

Yes, you can use the Account Trade History API for the same.
API keys are different for master and sub account and so are the trade history APIs.

6. How do sub accounts work with APIs

API keys are different for master and sub accounts and so are the trades and trade histories.

7. Is any data available without authentication through API Key and Secret

The following data is available without authentication:

  • In REST APIs here’s a list of public endpoints that don’t need an authentication
  • In Websockets, the order book and market data is available without authentication

8. Is Futures trading available through Public APIs

No, currently this feature is not available.

Markets
1. How to evaluate order quantity with the combination of min_quantity / max_quantity and precision

To derive quantity value for an order both min_quantity and precision condition should meet.
So as example shared by user when min_quantity = 0.001 and target precision = 2 in this case
order quantity cannot be less than 0.01 this satisfy both the condition of min_quantity and target precision.

2. How to get Market specific data (Ex: status, min_quantity, max_quantity, target precision etc)

GET /exchange/v1/markets_details API can be use to fetch this data, the response of this API contains
parameter related to specific market.
For example base_currency_precision, target_currency_precision, min_quantity, max_quantity etc. API Link

3. How to get Candles data for a market

GET /market_data/candles?pair=B-BTC_USDT&interval=1m API can be use to fetch candle data. API Link

4. Is there a place, where I can get the full report of 52 week high, 52 week low, 24hr, 1week,1hr data.

Yes, this can be fetched from the Candles API.

5. What is the difference between fee and fee_amount that is received in the response of New Order and Multiple Orders API

The parameter fee returns the fee percentage charged on the transaction whereas the fee_amount parameter returns the absolute amount of fee charged in the base currency.

6. How can the prices for a particular market be fetched

You can fetch the OHLC (Open, High, Low and Close) data for various intervals from the Candles API for a particuar market.

7. How should we determine the minimum quantity for a particular market

Please use the following steps to determine the minimum quantity that can be traded for a particular market:
  1. Please fetch the min_quantity from Market Details API.
  2. Please fetch the target_currency_precision from Market Details API. If the       target currency precision is 2 that can be interpreted as the minimum       quantity available to be 0.01.
  3. The maximum of the above 2 values would give you the minimum quantity       that you can order for a particular market.
Hence if the min_quantity returns 0.0001 and the target_currency_precision is 2, then the min quantity allowed is actually 0.01 and not 0.0001.

Orders
1. How to find available order types for a market

The available order types for a particular pair/market can be obtained from order_types param of the Market Details API. These can then used accordingly while creating Orders

2. What are the meanings of the different kinds of orders available?

Please refer to this article for more information on this topic

3. How can one calculate the tentative order value before placing an order

This would depend on the kind of order that you’d like to place.

  • In case of limit value this can be calculated with the price and quantity you’d like to set.
  • In case of market value, this can be calculated by fetching the latest prices from the Candles API and multiplying with the quantity you’d like to order. The final price will however depend on the market conditions.
  • In case of stop limit order, the price you’d set would determine the

4. For a failed transaction will there be a fee charged

No fee would be applicable on a failed transaction.

5. How can the total open orders for a particular pair be found

This can be done in 2 ways:

6. What is the max length of the client order id

The maximum allowed length is 36 characters

7. What are the various reasons for which orders could not be placed

There could be several reasons because of which an order could not be placed. Some of these are listed below:

  • There isn’t enough balance present in the user's wallet
  • Rate limits have been hit
  • The order type sent is not present for the market
  • The mandatory fields needed to execute the order are not sent

8. What are the various reasons for which orders could be rejected after getting placed

There could be several edge cases because of which an order could be placed but rejected at a later stage. One of them is that in case of market orders, the order value could go below the min notional value of the market.

Sockets
1. On websockets for orderbooks, are the updates a snapshot or an incremental update

On orderbook related data on CoinDCX Websockets are snapshot updates only. This applies to all exchange including CoinDCX, Binance, Huobi, KuCoin etc

2. On websockets, what is the depth of orderbook updates available

Every new update event will have upto 50 recent orders

3. Can I only get the order book upto a certain depth (for ex: top 10 only)

This functionality is not available. Every order book update event will give a update of upto 50 recent orders

4. Are there private channels on CoinDCX Websockets? How do I access them?

Publicly available data like market data and order book are available on public channels. On private channels, user specific information like New orders, order updates,user balance update are available. These can be accessed post authentication via API key and secret. Please see the following for more details

5. Is there a way to use CoinDCX websockets without socket.io.

CoinDCX Websockets are currently implemented via Socket.io. This is the only officially supported library for our websockets.

User Data
1. How can I get my balances and update in balance via APIs

There are 2 ways to fetch this data:

  • You can use our REST APIs here
  • You can also get this data via our websockets by following the steps here

2. Can I get my fee tier via APIs

We currently don't have this available on our APIs

Handling Errors
1. “Invalid Request”

This happens when there is something incorrect in the request body. These could be:

  • Not sending all mandatory params
  • Not sending the right values in the query params
  • Not using the right JSON structure in the request body

Please re-check the request params and values you are passing in the request.

2. “Order type not allowed”

This happens when particular order type is not allowed for the market For example: BTCINR market has only limit and market type orders, so user won’t be able to place stop_limit orders for BTCINR market. Allowed order type for a market can be checked from Market Details API.

3. “Too Many Requests”

This happens when user makes too many API calls which leads to rate limit for a user.

4. “This order cannot be cancelled”

This happens when the order id passed in the request body is in filled, cancelled or rejected status. Order can be cancelled only when its in open or partially_filled status. Order status of an order can be checked using Order Status API.

5. “packet queue is empty, aborting”

This happens when connection with the socket is lost. In this case please connect with the socket again and re-join the channel.

Errors

The CoinDCX API uses the following error codes:

Error Code Meaning
400 Bad Request -- Your request is invalid.
401 Unauthorized -- Your API key is wrong.
404 Not Found -- The specified link could not be found.
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

CoinDCX’s API for High-Frequency Trading (HFT)

CoinDCX provides special access to our HFT APIs for enterprise and specialized clients. These APIs will enable our clients to trade and receive market data with faster API responses and higher API rate limits.

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.