NAV

Introduction

Welcome to Darico API document for developers.

This file provides the related API application introduction. Open-API includes the port to acquire balance, all orders ,and all transaction record. Ws-API response for the port of K line functions.

Getting Started

REST, a.k.a Representational State Transfer, is an architectural style that defines a set of constraints and properties based on HTTP. REST is known for its clear structure, readability, standardization and scalability. Its advantages are as follows:

Developers are recommended to use REST API to proceed spot trading and withdrawals.

Encrypted Verification of API

Generate an API Key

Before signing any request, you must generate an API key via Darico’s official website 【User Center】-【API】. After generating the key, there are three things you must bear in mind:

API Key and Secret are randomly generated and provided, Passphrase is set by user.

Initiate a Request

All REST requests must include the following headings:

Signature

Generate a string to be signed - open-api Demo

  1. Sort the parameters in ascending order of their parameter names in lexicographic order
  2. Traversing the sorted dictionary, splicing all parameters together in "keyvalue" format (non-null parameters)
  3. Use MD5 to treat signature strings

For example:

api_key = 1234567

time = 12312312312137

secret_key = 789654

sign = md5(api_key1234567time12312312312137789654)

Request Process

The root URL for REST access:https://api.darico.io

Request

All requests are based on Https protocol, contentType in the request header must be uniformly set as: ‘application/x-www-form-urlencoded’.

Request Process Descriptions

  1. Request parameter: parameter encapsulation based on the port request.

  2. Submitting request parameter: submit the encapsulated parameter request to the server via POST/GET/PUT/DELETE or other methods.

  3. Server response: the server will first perform a security validation, then send back the requested data to the client in JSON format.

  4. Data processing: processing server response data.

Success

HTTP status code 200 indicates a successful response and may contain content. If the response contains content, it will appear in the corresponding returned content.

Common Error Code

We had a problem with our server

Pagination

All REST requests that return datasets use cursor-based pagination.

Cursor-based pagination allows results to be obtained before and after the current page of the result and is well suited for real-time data. The subsequent requests can specify the direction of the requested data based on the current returned results, before and/or after it. The before and after cursors can be used by the response headers CB-BEFORE and CB-AFTER.

For example:

GET /orders?before=2&limit=30

Standards and Specification

Timestamp

Unless otherwise specified, all timestamps in APIs are returned in microseconds.

The ACCESS-TIMESTAMP header must be the number of seconds since UTC's time Unix Epoch. Decimal values are allowed. Your timestamp must be within 30 seconds of the API service time, otherwise your request will be considered expired and rejected. If you think there is a large time difference between your server and the API server, then we recommend that you use the time point to check the API server time.

For example

1524801032573

Numbers

In order to maintain the accuracy of cross-platform, decimal numbers are returned as strings. We suggest that you might be better to convert the number to string when issuing the request to avoid truncation and precision errors. Integers (such as transaction number and sequence) do not need quotation marks.

Rate Limits

When a rate limit is exceeded, a status of 429 Too Many Requests will be returned.

REST API

API Reference

Balance of assets

  1. Interface address: /open/api/user/account
  2. Interface specification: (get request)Balance of the assets
parameter Fill in type Explain
api_key Must fill api_key
time Must fill time stamp
sign Must fill autograph

Return value:

field Example explain
code 0
msg "suc" code>0fail
data {
"total_asset":432323.23,
"coin_list":[
{"coin":"btc","normal":32323.233,"locked":32323.233,"btcValuatin":112.33},
{"coin":"ltc","normal":32323.233,"locked":32323.233,"btcValuatin":112.33},
{"coin":"bch","normal":32323.233,"locked":32323.233,"btcValuatin":112.33},
]
}
total_asset:total assets
normal:Balance account
locked:Frozen accounts
btcValuatin:BTCValuation

Acquire full delegation

  1. Interface address:/open/api/v2/all_order
  2. Interface specification:(getrequest)Acquire full delegation
  3. startDate,endDate interval cannot exceed ten minutes
  4. No startDate, endDate, default first 10 minutes

you can use /open/api/order_info interface and check it

parameter Fill in type Explain
symbol Must fill Market mark,btcusdt,See below for details
startDate Selective filling (Added) Start time, accurate to seconds“yyyy-MM-dd mm:hh:ss”
endDate Selective filling (Added) End time, accurate to seconds“yyyy-MM-dd mm:hh:ss”
pageSize Selective filling Page size
page Selective filling Page number
api_key Must fill api_key
time Must fill time stamp
sign Must fill autograph
{
    "count":10,
    "orderList":[
        {
            "side":"BUY",
            "total_price":"0.10000000",
            "created_at":1510993841000,
            "avg_price":"0.10000000",
            "countCoin":"btc",
            "source":1,
            "type":1,
            "side_msg":"Purchase",
            "volume":"1.000",
            "price":"0.10000000",
            "source_msg":"WEB",
            "status_msg":"Full deal",
            "deal_volume":"1.00000000",
            "id":424,
            "remain_volume":"0.00000000",
            "baseCoin":"eth",
            "status":2
        },
        {
            "side":"SELL",
            "total_price":"0.09900000",
            "created_at":1510993715000,
            "avg_price":"0.10000000",
            "countCoin":"btc",
            "source":1,
            "type":1,
            "side_msg":"Sell out",
            "volume":"1.000",
            "price":"0.09900000",
            "source_msg":"WEB",
            "status_msg":"Full deal",
            "deal_volume":"1.00000000",
            "id":423,
            "remain_volume":"0.00000000",
            "baseCoin":"eth",
            "status":2
        }
    ]
}

Return value:

field Example explain
code 0
msg "suc" code>0fail
data as follows:
Virtual Currency Number xxx-cny xxx-btc xxx-usdt
btc btccny - btcusdt
eth ethcny ethbtc ethusdt
ltc ltccny ltcbtc ltcusdt
bcc bcccny bccbtc bccusdt
etc etccny etcbtc etcusdt
usdt usdtcny - -

Obtain all transaction records

  1. Interface address:/open/api/all_trade
  2. Interface Description: (get request) Get all transaction records
parameter Fill in type Explain
symbol Must fill Market mark,btcusdt,See below for details
startDate Selective filling (Added) Start time, accurate to seconds“yyyy-MM-dd HH:mm:ss”
endDate Selective filling (Added) End time, accurate to seconds“yyyy-MM-dd HH:mm:ss”
pageSize Selective filling Page size
page Selective filling Page number
api_key Must fill api_key
time Must fill time stamp
sort Selective filling 1Representing reverse order
sign Must fill autograph
{
    "count":22,
    "resultList":[
        {
            "volume":"1.000",
            "side":"BUY",
            "feeCoin":"YLB",
            "price":"0.10000000",
            "fee":"0.16431104",
            "ctime":1510996571195,
            "deal_price":"0.10000000",
            "id":306,
            "type":"Purchase",
            "bid_id":1001,
            "ask_id":1002,
            "bid_user_id":10001,
            "ask_user_id":10001

        },
        {
            "volume":"0.850",
            "side":"BUY",
            "feeCoin":"YLB",
            "price":"0.10000000",
            "fee":"0.13966438",
            "ctime":1510996571190,
            "deal_price":"0.08500000",
            "id":305,
            "type":"Purchase",
            "bid_id":1001,
            "ask_id":1002,
            "bid_user_id":10001,
            "ask_user_id":10001
        },
        {
            "volume":"0.010",
            "side":"BUY",
            "feeCoin":"YLB",
            "price":"0.10000000",
            "fee":"0.00164311",
            "ctime":1510995560344,
            "deal_price":"0.00100000",
            "id":291,
            "type":"Purchase",
            "bid_id":1001,
            "ask_id":1002,
            "bid_user_id":10001,
            "ask_user_id":10001
        }
    ]
}

Return value:

field Example explain
code 0
msg "suc" code>0fail
data as follows:
Virtual Currency Number xxx-cny xxx-btc xxx-usdt
btc btccny - btcusdt
eth ethcny ethbtc ethusdt
ltc ltccny ltcbtc ltcusdt
bcc bcccny bccbtc bccusdt
etc etccny etcbtc etcusdt
usdt usdtcny - -

Cancellation of the order

  1. Interface address:/open/api/cancel_order
  2. Interface specification:(post Request) Cancellation of the Power of Attorney
parameter Fill in type Explain
order_id Must fill OrderID
symbol Must fill Market mark,ethbtc,See below for details
api_key Must fill api_key
time Must fill time stamp
sign Must fill autograph

Return value:

field Example explain
code 0
msg "suc" code>0fail
data “”
Virtual Currency Number xxx-cny(xxx101) xxx-btc(xxx201)
btc btccny -
eth ethcny ethbtc
ltc ltccny ltcbtc
bcc bcccny bccbtc
etc etccny etcbtc

Cancellation of all orders of attorney according to currency pair

  1. Interface address:/open/api/cancel_order_all
  2. Interface specification:(postrequest)Cancellation of all orders of attorney according to currency pair(Up to 2,000 cancellations, more than 2,000 please revoke)
parameter Fill in type Explain
symbol Must fill Market mark,ethbtc,See below for details
api_key Must fill api_key
time Must fill time stamp
sign Must fill autograph

Return value:

field Example explain
code 0
msg "suc" code>0fail
data “”
Virtual Currency Number xxx-cny(xxx101) xxx-btc(xxx201)
btc btccny -
eth ethcny ethbtc
ltc ltccny ltcbtc
bcc bcccny bccbtc
etc etccny etcbtc

Create order

  1. Interface address:/open/api/create_order
  2. Interface specification:(post Request) Create an order
parameter Fill in type Explain
side Must fill Direction of businessBUY、SELL
type Must fill Type of list,1:limit order、2:market order
volume Must fill Purchase quantity(Polysemy, multiplexing fields)
type=1:Represents the quantity of sales and purchases
type=2:Buy means the total price,Selling represents the total number
Trading restrictions user/me-User information
price Selective filling Authorized unit price:type=2:No need for this parameter
symbol Must fill Market mark,ethbtc
fee_is_user_darico_coin Selective filling (Redundant fields, ignored)0,When the Darico has the platform currency, this parameter indicates whether to use the platform currency to pay the handling fee, 0 no, 1 yes.
api_key Must fill api_key
time Must fill time stamp
sign Must fill autograph

Return value:

field Example explain
code 0
msg "suc" code>0fail
data {"order_id":34343} Successful return to the transactionID
Virtual Currency Number xxx-cny(xxx101) xxx-btc(xxx201)
btc btccny -
eth ethcny ethbtc
ltc ltccny ltcbtc
bcc bcccny bccbtc
etc etccny etcbtc
{
   "date": 1534335607859,
   "ticker": [
     {
       "symbol": "btcusdt",
       "high": 7408.35984546,
       "vol": 0.01,
       "last": 1,
       "low": 7408.35984546,
       "buy": "3700.00000000",
       "sell": "7408.35984546",
       "rose": 0
     },
     {
       "symbol": "ethusdt",
       "high": 535.96,
       "vol": 6366.8591,
       "last": 20,
       "low": 279.57,
       "rose": -0.44564773
     },
     {
       "symbol": "bchusdt",
       "high": 12,
       "vol": 100,
       "last": 1,
       "low": 12,
       "buy": "11.00",
       "sell": "9.00",
       "rose": 0
     },
     {
       "symbol": "ethbtc",
       "high": 1,
       "vol": 281261,
       "last": 0.1,
       "low": 0.044039,
       "buy": "0.044049",
       "sell": "0.044049",
       "rose": -0.00022701
     },
     {
       "symbol": "nobbtc",
       "high": 0.007419,
       "vol": 1998,
       "last": 1,
       "low": 0.007419,
       "sell": "0.00741900",
       "rose": 0
     },
     {
       "symbol": "ltceth",
       "last": 0.18519949,
       "buy": "1.00000000",
       "sell": "0.18328001"
     }
   ]
 }

Get all trading pairs quotations on the market

  1. Interface address:/open/api/get_allticker
  2. Interface specification:(get Request) Get all trading pairs quotations on the market
field Example explain
code 0
msg "suc" code>0fail
data as follows: Return Value Description
date: Server time when data is returned
symbol: Transaction pairs(Transaction pairs1(base)Abbreviation_Transaction pairs2(quote)Abbreviation)
buy: Buy one price
high: Highest price
last: Latest Transaction Price
low: Minimum price
sell: Selling price
vol: Volume (latest 24 hours)
rose:Ups and downs

Getting K-line data

  1. Interface address:/open/api/get_records
  2. Interface specification:(get request)Getting K-line data
parameter Fill in type Explain
symbol Must fill Market mark,bchbtc,See below for details
period Must fill In minutes,The analogy is 1 in a minute,One day is1440
Virtual Currency Number xxx-cny xxx-btc xxx-usdt
bch bcccny bchbtc bchusdt
btc btccny - btcusdt
etc etccny etcbtc etcusdt
eth ethcny ethbtc ethusdt
ltc ltccny ltcbtc ltcusdt
[
        [
            1514445780,  //time stamp
            1.12,        //Opening price
            1.12,        //Highest
            1.12,        //minimum
            1.12,        //Closing price
            0            //volume

        ],
        [
            1514445840,
            1.12,
            1.12,
            1.12,
            1.12,
            0
        ],
        [
            1514445900,
            1.12,
            1.12,
            1.12,
            1.12,
            0
        ]
]

Return value:

field Example explain
code 0
msg "suc" code>0fail
data as follows:

Get the current market quotations

  1. Interface address:/open/api/get_ticker
  2. Interface specification:(get Request) to get the current market quotations
parameter Fill in type Explain
symbol Must fill Market mark,btcusdt,See below for details
{
    "high": 1,//Maximum value
    "vol": 10232.26315789,//Trading volume
    "last": 173.60263169,//Latest Transaction Price
    "low": 0.01,//Minimum value
    "buy": "0.01000000",//Buy one price
    "sell": "1.12345680",//Selling price
    "rose": -0.44564773,//Ups and downs
    "time": 1514448473626
}

Return value:

field Example explain
code 0
msg "suc" code>0fail
data as follows:
Virtual Currency Number xxx-cny xxx-btc xxx-usdt
bcc bcccny bccbtc bccusdt
btc btccny - btcusdt
etc etccny etcbtc etcusdt
eth ethcny ethbtc ethusdt
ltc ltccny ltcbtc ltcusdt

Acquisition of Trading Records

  1. Interface address:/open/api/get_trades
  2. Interface specification:(get Request) to obtain market transaction records
parameter Fill in type Explain
symbol Must fill Market mark,bchbtc,See below for details
[
        {
            "amount": 0.55,//volume
            "price": 0.18519949,//Transaction price
            "id": 447121,
            "type": "buy"//Businesstype,Buy asbuy,buysell
        },
        {
            "amount": 16.45,
            "price": 0.18335468,
            "id": 447120,
            "type": "buy"
        },
        {
            "amount": 2,
            "price": 0.18335468,
            "id": 447119,
            "type": "buy"
        },
        {
            "amount": 2.92,
            "price": 0.183324003,
            "id": 447118,
            "type": "sell"
        }
]

Return value:

field Example explain
code 0
msg "suc" code>0fail
data as follows:
Virtual Currency Number xxx-cny xxx-btc xxx-usdt
bch bcccny bchbtc bchusdt
btc btccny - btcusdt
etc etccny etcbtc etcusdt
eth ethcny ethbtc ethusdt
ltc ltccny ltcbtc ltcusdt

Get the latest transaction price of each pair of currencies

  1. Interface address:/open/api/market
  2. Interface specification:(getRequest) Get the latest transaction price of each pair of currencies
parameter Fill in type Explain
api_key Must fill api_key
time Must fill time stamp
sign Must fill autograph

Return value:

field Example explain
code 0
msg "suc" code>0fail
data {"btcusdt":15000,"ethusdt":800}
Virtual Currency Number xxx-cny xxx-btc xxx-usdt
btc btccny - btcusdt
eth ethcny ethbtc ethusdt
ltc ltccny ltcbtc ltcusdt
bcc bcccny bccbtc bccusdt
etc etccny etcbtc etcusdt

Search the depth of buying and selling

  1. Interface address:/open/api/market_dept
  2. Interface specification:(getrequest)Search the depth of buying and selling
parameter Fill in type Explain
symbol Must fill Market mark,ethbtc,See below for details
type Must fill Depth type,step0, step1, step2(Merger depth0-2);step0time,The highest accuracy
{  
    "tick":{
        "asks":[//Selling
            {22112.22,0.9332},
            {22112.21,0.2},
            {22112.21,0.2},
            {22112.21,0.2},
            {22112.21,0.2},
        ],
        "bids":[//Bid
            {22111.22,0.9332},
            {22111.21,0.2},
            {22112.21,0.2},
            {22112.21,0.2},
            {22112.21,0.2},
        ]
    }
}

Return value:

field Example explain
code 0
msg "suc" code>0fail
data as follows:

Batch order,Simultaneous bulk withdrawal of designated orders

  1. Interface address:/open/api/mass_replace
  2. Interface specification:(postrequest)Place orders in batches and withdraw designated orders in batches
parameter Fill in type Explain
api_key Must fill api_key
time Must fill time stamp
sign Must fill autograph
symbol Must fill currency ,example btcusdt
mass_cancel Selective filling [1234,234....] Withdrawal parameters,Orderid
mass_place Selective filling [{side:"BUY",type:"1",volume:"0.01",price:"6400",fee_is_user_darico_coin:"0"}, {}, …]
Meaning:
symbol:currency,example btcusdt
mass_place:Order parameter。side:direction(Direction of businessBUY、SELL),
--------------------------------type:type(1:limit order、2:market order)
--------------------------------volume:Purchase quantity(Polysemy,Multiplex field) type=1:Represents the quantity of sales and purchasestype=2:Buy means the total price,Selling represents the total number
--------------------------------price:Authorized unit price:type=2:No need for this parameter
--------------------------------fee_is_user_darico_coin:(Redundant fields) When the darico has a platform currency,This parameter indicates whether to use platform currency to pay handling fee, 0 no, 1 yes.

Return value:

field Example explain
code 0
msg "suc" code>0fail
data "mass_place": [{"order_id":"1234","code":"0", "msg":"suc"},...]
"mass_cancel": [{"order_id":"1234","code":"0", "msg":"suc"},.......]
Order return:Orderid,Status code,Success or Failure Information。
Withdrawal of returns:Orderid,Status code,c
0Express success。

Place orders in batches and withdraw designated orders in batches - V2

  1. Interface address:/open/api/mass_replaceV2
  2. Interface specification:(postrequest)Place orders in batches and withdraw designated orders in batches
parameter Fill in type Explain
api_key Must fill api_key
time Must fill time stamp
sign Must fill autograph
symbol Must fill currency ,example btcusdt
mass_cancel Selective filling [1234,234....] Withdrawal parameters,Orderid
mass_place Selective filling [{side:"BUY",type:"1",volume:"0.01",price:"6400",fee_is_user_Darico_coin:"0"}, {}, …]
Meaning:
symbol:currency,example btcusdt
mass_place:Order parameter。side:direction(Direction of businessBUY、SELL),
--------------------------------type:type(1:limit order、2:market order)
--------------------------------volume:Purchase quantity(Polysemy,Multiplex field) type=1:Represents the quantity of sales and purchasestype=2:Buy means the total price,Selling represents the total number
--------------------------------price:Authorized unit price:type=2:No need for this parameter
--------------------------------fee_is_user_Darico_coin:(Redundant fields) When the Darico has a platform currency,This parameter indicates whether to use platform currency to pay handling fee, 0 no, 1 yes.

Return value:

field Example explain
code 0
msg "suc" code>0fail
data "mass_place": [{"msg": "Success","code": "0","order_id": [504,505]},{"msg": "Order cancellation failed","code": "8","order_id": [504,505]}]
"mass_cancel": [{"msg": "Success","code": "0","order_id": [572,573,574,626,629]}]
Order return:Orderid,Status code,Success or Failure Information。
Withdrawal of returns:Orderid,Status code,c
0Express success。

Get the current delegation

  1. Interface address:/open/api/v2/new_order
  2. Interface specification:(getrequest)Get the current delegation(Including uncompleted and ongoing commissions)
parameter Fill in type Explain
symbo l Must fill Market mark,btcusdt,See below for details
pageSize Selective filling Page size
page Selective filling Page number
api_key Must fill api_key
time Must fill time stamp
sign Must fill autograph
{
    "count":10,
    "resultList":[
        {
            "side":"BUY",
            "total_price":"0.10000000",
            "created_at":1510993841000,
            "avg_price":"0.10000000",
            "countCoin":"btc",
            "source":1,
            "type":1,
            "side_msg":"Purchase",
            "volume":"1.000",
            "price":"0.10000000",
            "source_msg":"WEB",
            "status_msg":"Full deal",
            "deal_volume":"1.00000000",
            "id":424,
            "remain_volume":"0.00000000",
            "baseCoin":"eth",
            "status":2
        },
        {
            "side":"SELL",
            "total_price":"0.09900000",
            "created_at":1510993715000,
            "avg_price":"0.10000000",
            "countCoin":"btc",
            "source":1,
            "type":1,
            "side_msg":"Sell out",
            "volume":"1.000",
            "price":"0.09900000",
            "source_msg":"WEB",
            "status_msg":"Full deal",
            "deal_volume":"1.00000000",
            "id":423,
            "remain_volume":"0.00000000",
            "baseCoin":"eth",
            "status":2
        }
    ]
}

Return value:

field Example explain
code 0
msg "suc" code>0fail
data as follows: Order status(status)Explain:
INIT(0,"Initial order,No deal has not entered the handicap"),
NEW_(1,"New order,Unfinished business enters the market"),
FILLED(2,"Full deal"),
PART_FILLED(3,"Partial transaction"),
CANCELED(4,"Withdrawal of documents"),
PENDING_CANCEL(5,"Withdrawal of order"),
EXPIRED(6,"Abnormal order");
Virtual Currency Number xxx-cny xxx-btc xxx-usdt
btc btccny - btcusdt
eth ethcny ethbtc ethusdt
ltc ltccny ltcbtc ltcusdt
bcc bcccny bccbtc bccusdt
etc etccny etcbtc etcusdt
usdt usdtcny - -/web/new_order-Get the current delegate

Obtain order details

  1. Interface address:/open/api/order_info
  2. Interface specification:(getrequest)Obtain order details
parameter Fill in type Explain
order_id Must fill Order ID
symbol Must fill Market mark,ethbtc,See below for details
api_key Must fill api_key
time Must fill time stamp
sign Must fill autograph
{
    "order_info":{
        "id":343,
        "side":"sell",
        "side_msg":"Sell out",
        "created_at":"09-22 12:22",
        "price":222.33,
        "volume":222.33,
        "deal_volume":222.33,
        "total_price":222.33,
        "fee":222.33,
        "avg_price":222.33}
    }
    "trade_list":[
        {
            "id":343,
            "created_at":"09-22 12:22",
            "price":222.33,
            "volume":222.33,
            "deal_price":222.33,
            "fee":222.33
        },
        {
            "id":345,
            "created_at":"09-22 12:22",
            "price":222.33,
            "volume":222.33,
            "deal_price":222.33,
            "fee":222.33
        }
    ]
}

Return value:

field Example explain
code 0
msg "suc" code>0fail
data as follows:

All Transaction Pairs and Accuracy Supported by Query System

  1. Interface address:/open/api/common/symbols
  2. Interface specification:(get request) query all transaction pairs and accuracy supported by the system
{
"code": "0",
"msg": "suc",
"data": [
{
"symbol": "ethbtc",
"count_coin": "btc",
"amount_precision": 3,
"base_coin": "eth",
"price_precision": 8
},
{
"symbol": "ltcbtc",
"count_coin": "btc",
"amount_precision": 2,
"base_coin": "ltc",
"price_precision": 8
},
{
"symbol": "bchbtc",
"count_coin": "btc",
"amount_precision": 3,
"base_coin": "bch",
"price_precision": 8
},
{
"symbol": "etcbtc",
"count_coin": "btc",
"amount_precision": 2,
"base_coin": "etc",
"price_precision": 8
},
{
"symbol": "ltceth",
"count_coin": "eth",
"amount_precision": 2,
"base_coin": "ltc",
"price_precision": 8
},
{
"symbol": "etceth",
"count_coin": "eth",
"amount_precision": 2,
"base_coin": "etc",
"price_precision": 8
}
]
}

Return value:

field Example explain
code 0
msg "suc" code>0fail
data as follows: symbol Transaction pairs
base_coin Base currency
count_coin Money of Account
price_precision Price Precision Number(0 is a single digit)
amount_precision Quantitative precision digits (0 is a single digit)

Get user assets and recharge records

  1. Interface address:/open/api/user_balance_info
  2. Interface Description:(postRequest) Get user assets and recharge records
parameter Fill in type Explain
uid Selective filling useruid(useruid,mobile_number,emailOne of the three must be filled in)
mobile_number Selective filling Inquiry user number, mobile phone number or mailbox
email Selective filling email
api_key Must fill api_key
time Must fill time stamp
sign Must fill autograph
{
"balance_info":[
    {
        "symbol":"BTC",
        "balance":124.12
    },...
],
"deposit_list":[
    {
        "uid":17203,
        "symbol":"BTC",
        "fee":0.00005,
        "amount":12.02,
        "created_at":"2018-11-14 15:37:51"
    },...
]
}

Return value:

field Example explain
code 0 “0” - > Success
“100004” ->Illegal parameters
“100005” -> Signature error
“100007” -> illegalIP
"110032" -> Users do not have query privileges
“110020” -> The user to query does not exist
msg "suc" code>0fail
data as follows: balance_info Asset information in various currencies
deposit_list Filling Pipeline Information

Subscription - K Line Market

{"event":"sub","params":{"channel":"market_$base$quote_kline_[1min/5min/15min/30min/60min/1day/1week/1month]","cb_id":"custom"}}

{"event_rep":"subed","channel":"market_$base$quote_kline_[1min/5min/15min/30min/60min/1day/1week/1month]","cb_id":"Please Return by the Way You Came","ts":1506584998239,"status":"ok"}

{
    "channel":"market_$base$quote_kline_[1min/5min/15min/30min/60min/1day/1week/1month]",//Subscription transactions versus market$base$quoteExpressbtckrwetc.

    "ts":1506584998239,//Request time
    "tick":{
        "id":1506602880,//Time scale starting value
        "amount":123.1221,//A turnover
        "vol":1212.12211,//Trading volume
        "open":2233.22,//Opening price
        "close":1221.11,//Closing price
        "high":22322.22,//Highest price
        "low":2321.22//Minimum price
    }
}

Subscription - market quotations in the last 24 hours

{"event":"sub","params":{"channel":"market_$base$quote_ticker","cb_id":"custom"}}

{"event_rep":"subed","channel":"market_$base$quote_ticker","cb_id":"Please Return by the Way You Came","ts":1506584998239,"status":"ok","lower_frame":"0"} // lower_frame: 0 No coin pair off the shelf、 1 Coin pair

{
    "channel":"market_$base$quote_ticker",//Subscription transactions versus market$base$quoteExpress btckrw etc.
    "ts":1506584998239,//Request time
    "tick":{
        "id":1506584998,//Redundancy, no practical significance, timestamp
        "amount":123.1221,//A turnover
        "vol":1212.12211,//Trading volume
        "open":2233.22,//Opening price
        "close":1221.11,//Closing price
        "high":22322.22,//Highest price
        "low":2321.22,//Minimum price
        "rose":-0.2922,//Gain
        "ts":1506584998239,//Data generation time
        "lower_frame":"0"
    }
}

Subscription - Deep Port (High Frequency)

{"event":"sub","params":{"channel":"market_$base$quote_depth_step[0-2]","cb_id":"custom","asks":150,"bids":150}}

{"event_rep":"subed","channel":"market_$base$quote_depth_step[0-2]","cb_id":"Please Return by the Way You Came","asks":150,"bids":150,"ts":1506584998239,"status":"ok"}

{
    "channel":"market_$base$quote_depth_step[0-2]",//$base$quoteExpressbtckrwetc.,Depth has three dimensions012
    "ts":1506584998239,//Request time
    "tick":{
        "asks":[//Selling
            [22112.22,0.9332],
            [22112.21,0.2],
        ],
        "buys":[//Bid
            [22111.22,0.9332],
            [22111.21,0.2],
        ]
    }
}
{
    "channel":"market_$base$quote_depth_step[0-2]",//$base$quoteExpressbtckrwetc.,Depth has 3 dimensions012
    "ts":1506584998239,//Request time
    "tick":{
        "side": "asks", Trading Direction  asksSelling  buys: Bid  
        "price" : 133.55,  A price segment corresponding to the opening
        "volume" : 44.22   Quantity corresponding to price segment
    }
}

Subscription - Deep Port

{"event":"sub","params":{"channel":"market_$base$quote_depth_step[0-2]","cb_id":"custom","asks":150,"bids":150}}

{"event_rep":"subed","channel":"market_$base$quote_depth_step[0-2]","cb_id":"Please Return by the Way You Came","asks":150,"bids":150,"ts":1506584998239,"status":"ok"}

{
    "channel":"market_$base$quote_depth_step[0-2]",//$base$quoteRepresents btckrw, etc.,Depth has 3 dimensions012
    "ts":1506584998239,//Request time
    "tick":{
        "asks":[//Selling
            [22112.22,0.9332],
            [22112.21,0.2]
        ],
        "buys":[//Bid
            [22111.22,0.9332],
            [22111.21,0.2]
        ]
    }
}

Subscription-Real-time Transaction Information

{"event":"sub","params":{"channel":"market_$base$quote_trade_ticker","cb_id":"custom"}}

{"event_rep":"subed","channel":"market_$base$quote_trade_ticker","cb_id":"Please Return by the Way You Came","ts":1506584998239,"status":"ok"}

{
    "channel":"market_$base$quote_trade_ticker",//Subscription transactions versus market$base$quoteExpressbtckrwetc.
    "ts":1506584998239,//Request time
    "tick":{
        "id":12121,//dataThe biggest deal ID
        "ts":1506584998239,//dataThe biggest deal
        "data":[
            {
                "id":12121,//transaction ID
                "side":"buy",//Direction of business buy,sell
                "price":32.233,//Unit Price
                "vol":232,//Number
                "amount":323,//Total
                "ts":1506584998239,//Data generation time
                "ds":'2017-09-10 23:12:21'
            },
            {
                "id":12120,//Transaction ID
                "side":"buy",//Direction of business buy,sell
                "price":32.233,//Unit Price
                "vol":232,//Number
                "amount":323,//Total
                "ts":1506584998239,//Data generation time
                "ds":'2017-09-10 23:12:21'
            }
        ]
    }
}

Request-K Line History Data

{"event":"req","params":{"channel":"market_$base$quote_kline_[1min/5min/15min/30min/60min/1day/1week/1month]","cb_id":"custom","since":"1506602880"}}//since The default is to return the latest 300, a return value greater than since for up to 1 hours of data, since has strong check, not earlier than the current 1 hours to 59 since

{
    "event_rep":"rep","channel":"market_$base$quote_kline_[1min/5min/15min/30min/60min/1day/1week/1month]","cb_id":"Please Return by the Way You Came",
    "since":"1506602880",//since Return the latest 300 items by default, return the maximum 1 hour data larger than since when it has value, and since has strong check, not earlier than the current 1 hour.
    "ts":1506584998239,//Request time
    "data":[//300 article
        {
            "id":1506602880,//Time scale starting value
            "amount":123.1221,//A turnover
            "vol":1212.12211,//Trading volume
            "open":2233.22,//Opening price
            "close":1221.11,//Closing price
            "high":22322.22,//Highest price
            "low":2321.22//Minimum price
        },
        {
            "id":1506602880,//Time scale starting value
            "amount":123.1221,//A turnover
            "vol":1212.12211,//Trading volume
            "open":2233.22,//Opening price
            "close":1221.11,//Closing price
            "high":22322.22,//Highest price
            "low":2321.22//Minimum price
        }
    ]
}

Request-transaction history data

{"event":"req","params":{"channel":"market_$base$quote_trade_ticker","cb_id":"custom","top":200}}

{
    "event_rep":"rep","channel":"market_$base$quote_trade_ticker","cb_id":"Please Return by the Way You Came","ts":1506584998239,"status":"ok",
    "top":200,//Maximum support 200
    "data":[
        {
            "id":12121,//Transaction ID
            "side":"buy",//Direction of businessbuy,sell
            "price":32.233,//Unit Price
            "vol":232,//Number
            "amount":323,//Total
            "ts":1506584998239//Data generation time
        },
        {
            "id":12120,//Transaction ID
            "side":"buy",//Direction of business buy,sell
            "price":32.233,//Unit Price
            "vol":232,//Number
            "amount":323,//Total
            "ts":1506584998239,//Data generation time
            "ds":'2017-09-10 23:12:21'
        }
    ]
}

Request - 24 Market Data on Home Page-

{"event":"req","params":{"channel":"review"}}

{
   event_rep: "rep",
   channel: "review",
   data: {
          bchbtc:  {amount: "115.968833484"close: "0.07956"high: "0.086323"low: "0.079251"open: "0.086323"rose: "-0.07834528"vol: "1393.247"}
          bchusdt: {amount: "416316.164145661", close: "513.56", high: "556.42", low: "510.85", open: "555.71", }
          btcusdt: {amount: "999341.34124", close: "6450.18", high: "6486.39", low: "6359.63", open: "6435.79", }
   }
}

ws-api Demo (java)


package test;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.HashMap;
import java.util.Map;
import java.util.zip.GZIPInputStream;

import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

import org.java_websocket.client.DefaultSSLWebSocketClientFactory;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft;
import org.java_websocket.drafts.Draft_17;
import org.java_websocket.handshake.ServerHandshake;

/**
 * @author Squid DateTime:November 22, 2018, 9:25:20 PM 
 * Suggested use websocket client Edition 
 * <dependency> 
 * <groupId>org.java-websocket</groupId> 
 * <artifactId>Java-WebSocket</artifactId> 
 * <version>1.3.0</version> 
 * </dependency> 
 *
 */
public class WsTest {

    public static void main(String[] args) {
        try {
//wsurl 
            String url = "wss://ws.Darico.com/kline-api/ws";
//Historical data request parameters 
            String reqParam = "{"event":"req","params":{"channel":"market_btcusdt_trade_ticker","cb_id":"btcusdt","top":150}}";
//Subscription parameters 
            String subParam = "{"event":"sub","params":{"channel":"market_btcusdt_trade_ticker","cb_id":"btcusdt","top":150}}";

//Initialization request history data 
            WebSocketUtils wsc = WebSocketUtils.executeWebSocket(url, reqParam);

//Subscribe to real-time data 
            wsc.send(subParam);

//Thread does not end, waiting for new messageswww.darico.io Generally, a new deal will return in about a minute
            while (true) {
                Thread.sleep(1000);
            }

        }catch (Exception e) {
            e.printStackTrace();
        }
    }

    static class WebSocketUtils extends WebSocketClient {
        private static WebSocketUtils wsclient = null;
        private String msg = "";

        public WebSocketUtils(URI serverURI) {
            super(serverURI);
        }

        public WebSocketUtils(URI serverUri, Draft draft) {
            super(serverUri, draft);
        }

        public WebSocketUtils(URI serverUri, Map<String, String> headers, int connecttimeout) {
            super(serverUri, new Draft_17(), headers, connecttimeout);
        }

        @Override
        public void onOpen(ServerHandshake serverHandshake) {
            System.out.println("Links have been established");

        }

        @Override
        public void onMessage(String s) {
            System.out.println("Receive a string message");
        }

        @Override
        public void onClose(int i, String s, boolean b) {
            System.out.println("Link closed");
        }

        @Override
        public void onError(Exception e) {
            System.out.println("Wrong report");
        }

        @Override
        public void onMessage(ByteBuffer socketBuffer) {
            try {
                String marketStr = byteBufferToString(socketBuffer);
                String market = uncompress(marketStr).toLowerCase();
                if (market.contains("ping")) {
                    System.out.println("Receive messageping:"+market);
                    String tmp = market.replace("ping", "pong");
                    wsclient.send(market.replace("ping", "pong"));
                } else {
                    msg = market;
                    System.out.println("Receive message:"+msg);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        public static Map<String, String> getWebSocketHeaders() throws IOException {
            Map<String, String> headers = new HashMap<String, String>();
            return headers;
        }

        private static void trustAllHosts(WebSocketUtils appClient) {
            TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
                public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                    return new java.security.cert.X509Certificate[] {};
                }

                public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
                }

                public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
                }
            } };

            try {
                SSLContext sc = SSLContext.getInstance("TLS");
                sc.init(null, trustAllCerts, new java.security.SecureRandom());
                appClient.setWebSocketFactory(new DefaultSSLWebSocketClientFactory(sc));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        public static WebSocketUtils executeWebSocket(String url,String sendMsg) throws Exception {
            wsclient = new WebSocketUtils(new URI(url), getWebSocketHeaders(), 1000);
            trustAllHosts(wsclient);
            wsclient.connectBlocking();
            wsclient.send(sendMsg);
            return wsclient;
        }

        // buffer turn String 
        public String byteBufferToString(ByteBuffer buffer) {
            CharBuffer charBuffer = null;
            try {
                Charset charset = Charset.forName("ISO-8859-1");
                CharsetDecoder decoder = charset.newDecoder();
                charBuffer = decoder.decode(buffer);
                buffer.flip();
                return charBuffer.toString();
            } catch (Exception ex) {
                ex.printStackTrace();
                return null;
            }
        }

        // decompression 
        public String uncompress(String str) throws IOException {
            if (str == null || str.length() == 0) {
                return str;
            }
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            ByteArrayInputStream in = new ByteArrayInputStream(str.getBytes("ISO-8859-1"));
            GZIPInputStream gunzip = new GZIPInputStream(in);
            byte[] buffer = new byte[256];
            int n;
            while ((n = gunzip.read(buffer)) >= 0) {
                out.write(buffer, 0, n);
            }
            return out.toString();
        }

    }
}