Trade API(http)

HTTP API

BW provides users with a simple yet powerful API designed to help users quickly and efficiently integrate BW trading functions into their own applications. If you have any problems during the use, please contact our technical discussion QQ group, we will make the most authoritative answer for you. We have provided a complete demo of the Java and Python versions (GitHub) , please add them.

Inventor Quantification (FMZ.COM) is China's largest digital currency quantitative trading platform. It supports Javascript/Python/C++/Mc Language/Visualization. Five programming languages, platform strategy fully supports all currencies of BW.COM, and can quickly get started to quantify transactions.

API Address Domain Name address

Domain name address:https://www.localhost:8000/

Use Instruction

Before using these APIs, you must first obtain two parameters. After logging in to the website, enter the API function, open and then get the parameters of Api Id and Api Secret. With these two parameters, you will have advanced permissions such as trading orders and querying assets. Please pay attention to confidentiality. In addition to 1.1 get the market list, 1.2 get the currency list, 6 market quotes interface, all other http interfaces need to be signed, the signature rules are described later.

1 API Configuration and basic function

1.1 Get market list

path:/exchange/config/controller/website/marketcontroller/getByWebId
Request method:get/post
Request message:

None

Return to successful message

          
            {
              { "datas": [
                {
                  "amountDecimal": 8, //Quantity accuracy
                  "minAmount": "0.0001000000", //minimum amount
                  "buyerCurrencyId": "2", //Buyer currency
                  "priceDecimal": 8, //Price accuracy
                  "serverId": "entrust-server-001", //Service ID
                  "marketId": "70", //Market ID
                  "webId": "100", //Site ID
                  "modifyTime": 0,
                  "sellerCurrencyId": "19", //Seller currency
                  "createTime": 1522400906009,
                  "defaultFee": "0.00050000", //Default rate
                  "name": "eth_btc", //Market name
                  "leverType": "1", //Lever type: 1 spot 2 leverage
                  "state": 1, //Status: 1 Run, 2 Pause (cannot place order, 0 stop -1 delete
                  "openTime": 1, //Opening time, the timestamp in milliseconds
                  "isMining":0 //Whether mining: 1 is 0 is not
                },
                ....
              ],
              "resMsg": {
                "code": "1",
                "method": null,
                "message": "success !"
              }
            }
          
        

1.2 Get currency list

path:/exchange/config/controller/website/currencycontroller/getCurrencyList
Request method:post
Request message:

None

Return to successful message

          
            {
              "datas": [
                {
                  "totalNumber": "230000000.00000000", //Total
                  "tradeSearchUrl": null, //Transaction inquiry address
                  "tokenCoinsId": 0, //If greater than 0 is the token of another currency, otherwise equal to 0
                  "minCash": null,
                  "tokenName": null,//
                  "description": "Bitcoin", //description
                  "arithmetic": null,   //Consensus algorithm
                  "dailyDrawLimit": 10000,
                  "remark": null,   //
                  "isLegalCoin": 0, //Is it a legal currency, such as US dollars 1 is, 0 is not
                  "outConfigTimes": 0,//
                  "timesFreetrial": "0",//
                  "hourFreetrial": "0",//
                  "inConfigTimes": 6,//
                  "alias": "b", //Alias
                  "logo": "market-btc.png", //icon
                  "needBlockUrl": 0, //Whether you need a block address, 0 does not need 1 need
                  "currencyId": "2", //Currency ID
                  "drawFlag": 1,
                  "rechargeFlag": 1,
                  "onceDrawLimit": 100,
                  "founder": null,
                  "drawFee": "0.00100000",
                  "blockChainUrl": "https://blockchain.info/tx/", //blockChain query address (block query address)
                  "dayFreetrial": "0",
                  "marketValue": null, //The total market capitalization
                  "minFee": null,
                  "teamAddress": null,
                  "defaultDecimal": 2, //Currency decimal places (accuracy) - lower priority than the configuration in the market
                  "publishNumber": "14500000.00000000", //Issued
                  "isMining": "0", //Whether it can mine
                  "name": "btc", //name
                  "limitAmount": null,
                  "websiteCurrencyId": "223f4d23232",
                  "state": 1, //Status -1 Delete 0 Disable 1 Enable Default 1
                  "descriptionEnglish": "<p>The BTC is ...</p>", //English description
                  "mark": null //symbol
                },
                .....
              ],
              "resMsg": {
                "code": "1",
                "method": null,
                "message": "success !"
              }
            }
          
        

2 Interface to Obtain User Information

2.1 Interface to Obtain User Information

path:/exchange/user/controller/website/usercontroller/getuserinfo
Request method:post
Request message:

None

Return to successful message

          
            {
              "datas":{
              "loginMobileAuth":0, //Whether mobile phone certification: 0: No, 1: Yes
              "googleStatus":0, //Audit status: 0: no review, 1: revision review
              "isAlipay":"", //Whether to bind Alipay 1 binding 0 is not bound
              "loginPwd":"1", //Whether to set the login password: 0: No, 1: Yes
              "externalUidType":null, //Extended userid source type, such as: zb, exx
              "isWechat":"", //Whether to bind WeChat 1 binding 0 is not bound
              "loginAuth":3, //Login verification (1-login password 2-off-site login verification 4-Google verification, can be any combination of three, default 3
              "merchantName":"", //Merchant name
              "countryCode":"+86", //country code
              "loginName":"130***17", //log-in name
              "loginGoogleAuth":1, //Whether Google certification: 0: No, 1: Yes
              "email":null, //User mailbox
              "nickName":"130***17", //User's Nickname
              "isBank":"", //Whether to bind the bank
              "mobileAuth":1, //Whether mobile phone authentication: 0: No, 1: Yes, [2: Modification failed, not passed, -1: Modified review]
              "mobile":"+86 130***17", //cellphone number
              "userId":"test6", //User id
              "recommendCode":"dGVzdDY=\u000a", //Recommendation code
              "realName":"", //User real name
              "withdrawAuth":3, //Cash withdrawal verification (1-Fund password 2 - SMS/mailbox verification 4-Google verification code Default funding password + SMS / email = 3)
              "recommendCount":null, //Recommended number
              "externalUserId":null, //Extended userid, such as zb one-click login saved zb userid
              "mobileStatus":0, //Audit status: 0: no review, 1: revision review
              "safePwdAuth":0, //Whether to set a security password: 0: No, 1: Yes
              "googleAuth":1, //Whether Google certification: 0: No, 1: Yes
              "loginEmailAuth":0, //Whether email authentication: 0: No, 1: Yes
              "tradeAuth":1, //Transaction Verification (1 - Never enter the funds password 2 - 6 hours free of funds password - 3 verification of the funds password for each transaction)
              "status":1 //0 (000-initial state) 1 (001-real-name certification) 2 (010-has bank certification) 3 (011 has real name and bank certification)
              },
              "resMsg":{
              "code":"1",
              "method":null,
              "message":"success !"
              }
            }
          
        

3 Trade API

3.1 Additional entrustment

path:/exchange/entrust/controller/website/EntrustController/addEntrust
Request method:post
Request message format:application/json
Request message:

          
            json
            {
              "amount": 0,                          //Order quantity
              "type": 0,                            //Trading type: 0 Sell 1 Buy
              "rangeType": 0,                            //Delegate type 0 is a limit order 1 Interval delegate, currently only supports limit order
              "marketId": "90",                     //Market ID
              "price": 0                            //Price
            }
          
        

Return message>

          json
            {
              "datas": {
                  “entrustId”:"E6419466484531482624"  //Delegate ID
              },
              "resMsg": {
                  "code": "1",
                  "method": null,
                  "message": "success !"
              }
            }
          
        

3.2 Cancel order

path: /exchange/entrust/controller/website/EntrustController/cancelEntrust
Request method:post
Request message format:application/json
Request message:

          json
            {
              "entrustId": "E6419466484531482624",  //Delegate ID to cancel
              "marketId": "90" //Market ID
            }
          
        

Return message

          json
            {
                "datas": null,
                "resMsg": {
                    "code": "1", //1 means success, other error codes see instructions
                    "method": null,
                    "message": "success !"
                }
            }
          
        

3.3 Check open orders(New interface)

This interface only returns orders with status (status) as part of the start and transaction, and supports paging.

path: /exchange/entrust/controller/website/EntrustController/getUserEntrustRecordFromCacheWithPage
Request method:get
请求报文: key-value


        marketId=80 //Market ID
        pageSize: 4 //Number of pages per page
        pageIndex: 1 //Page number, starting from 1
        

Return message

          json
            {
                "datas":{
                "entrustList":[
                {
                  "amount":"7",                     //Volume
                  "availabelAmount": "3.02",      //The number of remaining transactions
                  "completeAmount": "1.99",       //The number of transactions already made
                  "completeTotalMoney":"15.92",     //Total amount completed
                  "totalMoney":"56.003",                //total amount
                  "rangeType":0,                        //Interval Type 0 Current Order 1 Interval Order
                  "rangeLowPrice":null,             //Minimum price of interval commission
                  "rangeHighPrice":null,                //The highest price of the interval commission
                  "entrustId":"E6437955999037923328",   //Delegate ID
                  "type":0,                         //0 sell 1 purchase -1 cancel
                  "userId":"test6",                 //User id
                  "dealTimes":1,                    //Transaction processing times
                  "createTime":1534928321609,       //order time
                  "price":"8.00005",                //unit price
                  "entrustType":0,              //Delegate type 0 ordinary order 1 leveraged order
                  "status":0     //Status : -2 funds unfrozen failed -1 user funds are insufficient 0 start 1 cancel 2 transaction success 3 transaction part 4 cancel
                }
                ],
                "totalRow":1,  //Total number of rows
                "pageNum":1,   //Page number, starting from 1
                "pageSize":4,  //Number of pages per page
                "totalPage":1  //total pages
            },
              "resMsg": {
                "code": "1",            //1 means success, others are descriptions of error codes.
                "method": null,
                "message": "success !"
              }
            }
          
        

3.3 Check open orders(Legacy interface)

This interface only returns the order with the status (status) as part of the transaction, no paging, and only up to 20 items.

path: /exchange/entrust/controller/website/EntrustController/getUserEntrustRecordFromCache
Request method:get
请求报文: key-value

marketId: 90  //Market ID

Return message

          json
            {
                "datas":
                [
                {
                "amount":"1.1",                     //Volume
                "rangeType":0,                      //Interval Type 0 Current Order 1 Interval Order
                "rangeLowPrice":null,               //Minimum price of interval commission
                "rangeHighPrice":null,              //The highest price of the interval commission
                "totalMoney":"5.555",               //total amount
                "entrustId":"E6437955999037923328", //Delegate ID
                "type":0,                           //0 sell 1 purchase -1 cancel
                "userId":"test6",                   //User id
                "completeAmount":"0",               //The number of transactions already made
                "marketId":"80",                    //Market ID
                "dealTimes":0,                      //Transaction processing times
                "createTime":1534928321609,         //order time
                "price":"5.05",                     //unit price
                "completeTotalMoney":"0",           //Total amount completed
                "entrustType":0,                //Delegate type 0 (false) ordinary order 1 (true) leverage order
                "status":0                          //Status : -2 funds unfrozen failed -1 user funds are insufficient 0 start 1 cancel 2 transaction success 3 transaction part 4 cancel
                }
                  ],
                  "resMsg": {
                    "code": "1",            //1 means success, others are descriptions of error codes.
                    "method": null,
                    "message": "success !"
                  }
            }
          
        

3.4 Paging enquiry on historical records(Closed and cancelled records only)

This interface only returns the delegate records with the status of pending, completed, partially filled, canceled, canceled.

paht: /exchange/entrust/controller/website/EntrustController/getUserEntrustList
Request method:get
请求报文: body json

          
            marketId=90 //Market ID
            pageIndex=1 //page number
            pageSize=20 //Number of impressions per page
            type=0 //(optional) delegate type, 0 sell 1 purchase -1 cancel
            status=0 //(optional) status: -2 funds unfreeze failed -1 user insufficient funds 0 start 1 cancel 2 trade success 3 trade one 4 cancel
            startDateTime=1533204010299 //(Optional) The start time of the order placed, 13-bit time stamp
            endDateTime= 1534204030299 //(Optional) End time of the order placed, 13-bit time stamp
          
        

Return message

          json
            {
                "datas":{
                "entrustList":[
                {
                "amount":"1.1",                     //Volume
                "rangeType":0,                      //Interval Type 0 Current Order 1 Interval Order
                "rangeLowPrice":null,               //Minimum price of interval commission
                "rangeHighPrice":null,              //The highest price of the interval commission
                "totalMoney":"5.555",               //total amount
                "entrustId":"E6437955999037923328", //Delegate ID
                "type":0,                           //0 sell 1 purchase -1 cancel
                "userId":"test6",                   //User id
                "completeAmount":"0",               //The number of transactions already made
                "marketId":"80",                    //Market ID
                "dealTimes":0,                      //Transaction processing times
                "createTime":1534928321609,         //order time
                "price":"5.05",                     //unit price
                "completeTotalMoney":"0",           //Total amount completed
                "entrustType":0,                //Delegate type 0 ordinary order 1 leveraged order
                "status":0              //Status : -2 funds unfrozen failed -1 user funds are insufficient 0 start 1 cancel 2 transaction success 3 transaction part 4 cancel
                },
                ....
                ],
                "totalPage":2,              //Total number of commission records
                "currentPage":1                 //current page number
                },
                  "resMsg": {
                    "code": "1",            //1 means success, others are descriptions of error codes.
                    "method": null,
                    "message": "success !"
                  }
            }
          
        

3.5 Enquiry on record based on t id

path: /exchange/entrust/controller/website/EntrustController/getEntrustById
Request method:get
Request message:key-value

          
            marketId:   90 //Market ID
            entrustId:  E6419443135315070976 //The delegate ID to be queried
          
        

Return message

          json
            {
                "datas": {
                  "amount":"1.1",                     //Volume
                  "rangeType":0,                      //Interval Type 0 Current Order 1 Interval Order
                  "rangeLowPrice":null,               //Minimum price of interval commission
                  "rangeHighPrice":null,              //The highest price of the interval commission
                  "totalMoney":"5.555",               //total amount
                  "entrustId":"E6437955999037923328", //Delegate ID
                  "type":0,                           //0 sell 1 purchase -1 cancel
                  "userId":"test6",                   //User id
                  "completeAmount":"0",               //The number of transactions already made
                  "dealTimes":0,                      //Transaction processing times
                  "createTime":1534928321609,         //order time
                  "price":"5.05",                     //unit price
                  "completeTotalMoney":"0",           //Total amount completed
                  "entrustType":0,                //Delegate type 0 (false) ordinary order 1 (true) leverage order
                  "status":0                          //Status : -2 funds unfrozen failed -1 user funds are insufficient 0 start 1 cancel 2 transaction success 3 transaction part 4 cancel
                  },
                    "resMsg": {
                      "code": "1",            //1 means success, others are descriptions of error codes.
                      "method": null,
                      "message": "success !"
                    }
            }
          
        

4 Financial API

4.1 Obtain deposit address

path:exchange/fund/controller/website/fundcontroller/getPayinAddress
Request method:post
Request message format: application/json
Request message:body json

          
            {
              “currencyTypeName”:"btc" //Currency type name (must pass)
            }
          
        

Return message

          
            {
                "datas": {
                    "address": "19cdJwd3j6ArHNhiYoWpN8cJq9ash7WDDC",//Deposit Address
                    "wallet": "merchants014"
                },
                "resMsg": {
                    "code": "1",
                    "method": null,
                    "message": "success !"
                }
            }
          
        

4.2 Enquiry on deposit record

path:exchange/fund/controller/website/fundcontroller/getPayinCoinRecord
Request method:post
Request message format::application/json
Request message:body json

          
            {
                “currencyTypeName”:“qtum”, //Currency type
                “sort”:1 //Do not pass the refilling time in reverse order, pass in ascending order,
                "pageNum":1
                "pageSize":20
            }
          
        

Return message

          
            {
              "datas": {
                "totalRow": 1,  //Total number of rows
                "totalPage": 1, //total pages
                "pageSize": 20, //Number of pages per page
                "list": [
                    {
                        "currencyTypeId": 1, //Currency type id
                        "depositId": “f3342424”, //Recharge primary key
                        "amount": "10.0", //Number of coins
                        "confirmTimes": "4", //Confirmation
                        "createTime": "2018-03-10 10:22:09.0", //Charging time
                        "depositAddress": "1BKd2sSPYzxC2XHurR6oQWc2wzSx2rZzck", //Deposit Address
                        "txId": "6378183001917882368", //Transaction id
                        "userId": "1", //User id
                        "status": 1,//'0: Not arrived 1: Received'
                    }
                ],
                "pageNum": 1
            },
            "resMsg": {
                "code": "1",
                "method": null,
                "message": "success !"
            }
            }
          
        

4.3 Enquiry on withdrawal record

path:/exchange/fund/controller/website/fundwebsitecontroller/getpayoutcoinrecord
Request method:get
Request message:key-value

          
            currencyId=1    //Currency id (must pass)
            tab=all         //(required) | all, wait (committed, unreviewed), success (audit passed), fail (audit failed), cancel (user undoes)
            pageIndex=1     //Must pass, default 1
            pageSize=10     //Must pass, default 10
          
        

Return message

          
            {
              "datas": {
                  "totalRow": 34,                                          //Total number of rows
                  "totalPage": 4,                                          //total pages
                  "pageSize": 10,                                          //Number of pages per page
                  "list": [
                      {
                          "modifyUid": null,                               //Modify person id
                          "withdrawalId": "W6419027628808093696",          //Withdraw id
                          "fees": "0.001000000000000000",                  //Fees
                          "amount": "10.000000000000000000",               //Cash withdrawal amount
                          "userApplyWithdrawId": "7eBDJ5PKbSK",            //Withdrawal record id
                          "verifyRemark": null,                            //Audit opinion
                          "remark": null,                                  //Remarks
                          "verifyTime": 0,                                 //Review time
                          "userName": "[email protected]",                  //username
                          "userId": "7e9ioSoVXcW",                         //User id
                          "actuallyAmount": "10.000000000000000000",       //Actual arrival amount
                          "modifyTime": 0,                                 //Change the time
                          "verifyStatus": 0,                               //Audit status (0 pending review, 1 review passed -1 review failed)
                          "createTime": 1530415446577,                    //Coin time
                          "state": 1,                                                             //Status (-1 delete, 1 normal)
                          "currencyId": "2",                                                          //Currency id
                          "withdrawalAddress": "1JimMZks39eVqU6T3v6wvz1m4LtJ3tPjGL",                  //Withdrawal address
                          "verifyUid": null                                                           //Reviewer id
                      }
                  ],
                  "pageNum": 1
              },
              "resMsg": {
                  "code": "1",
                  "method": null,
                  "message": "success !"
              }
            }
          
        

4.4 Obtain all fund information of user

path:/exchange/fund/controller/website/fundcontroller/findbypage
Request method:post
Request message format:application/json
Request message:body json

          
            {
                "pageSize":30,       # Number of lines per page (optional)
                "pageNum":1          # Page number (optional)
            }
          
        

Return message

          
            {
                "datas": {
                    "totalRow": null,
                    "totalPage": null,
                    "pageSize": 30,
                    "list": [
                        {
                            "currencyTypeId": 1,                    //Currency type id
                            "amount": "971.174",     //The amount of funds currently available to the user
                            "freeze": "122",     //User freezes the amount of funds
                            "createTime": "2018-02-19 10:02:33",
                            "depositAddress": null,
                            "userId": "1"
                        },
                        {
                            "currencyTypeId": 2,
                            "amount": "768.368",
                            "freeze": "131",
                            "createTime": "2018-02-19 10:02:33",
                            "depositAddress": null,
                            "userId": "1"
                        }
                    ],
                    "pageNum": 1
                },
                "resMsg": {
                    "code": "1",
                    "method": null,
                    "message": "success !"
                }
            }
          
        

4.5 Enquiry on withdrawal address

path:/exchange/fund/controller/website/fundwebsitecontroller/getwithdrawaddress
Request method:get
Request message: formdata key-value Form submission

          
            currencyId=2          //(Must pass)
            pageIndex=1           //(Must pass, default 1)
            pageSize=10           //(Must pass, default 10)
          
        

Return message

          
            {
              "datas": {
                  "totalRow": 2,
                  "totalPage": 1,
                  "pageSize": 10,
                  "list": [
                      {
                          "address": "1DkwrD4bMtjd6kcZw8CxM9r3z4AGVFfSRz",    //Address
                          "modifyTime": 1524217688882,                        //Change the time
                          "currencyName": "btc",                              //Currency name
                          "createTime": 1523185357488,                        //Coin time
                          "userFundAddressId": "7bwK95B7jTk",                 //Address id
                          "remark": "correct",                                //Remarks
                          "currencyId": "2",                                  //Currency id
                          "type": 1,                                          //(1-coin address, 2-telephone address)
                          "userName": "Mr.牛",                                //username
                          "userId": "7e8fMkzTlL6",                            //userId
                          "status": "1"                                       //Status (-1 delete, 1 normal)
                      }
                  ],
                  "pageNum": 1
              },
              "resMsg": {
                  "code": "1",
                  "method": null,
                  "message": "success !"
              }
            }
          
        

5 Signature and password encryption rules

5.1 Signature rules

The signature string sign=md5 (Apiid+Timestamp+ parameter content string + signature key), the signature key is Api Secret, and Apiid is obtained when the website opens the Api function, and the parameter string content rules are available. There are only three types of header parameters. The empty string, the body json format parameter is the json string format of the body parameter, the key-value and the parameter form of the get form are all sorted by the initial value of the key value, and then press key1+value1+key2 A string of +value2.... After signing, put Apiid, Timestamp, and Sign into the request header. Note that the first letter is capitalized, followed by all lowercase.
For example, when turns on API on the website, it gets the following two parameters Apiid=7eESLc0x69I7eESLc0x69J,Apisecret = 87ceba599b6d39a39deb01cf71eacd57,Timestamp=1533179478000,
a、Body json Format parameter

          
            The parameter content json string is:{"userId":"u111","name":"zhangsan"}
            Parameter content is as follows:{"userId":"u111","name":"zhangsan"}
            then Sign = md5(7eESLc0x69I7eESLc0x69J1533179478000{"userId":"u111","name":"zhangsan"}87ceba599b6d39a39deb01cf71eacd57)
            = 9bd4ef5f834add851badb0bbd5bb0f2c
          
        

b、Withour any body or get parameter

          
            Parameter content string is empty
            then Sign = md5(7eESLc0x69I7eESLc0x69J153317947800087ceba599b6d39a39deb01cf71eacd57)
            = 935b6a59860cc12e802e5dee30c6a614
          
        

c、formdata key-value,or 'get' parameter

          
            The parameter content is:userid=10,status=1,acount = 10
            Parameter content is as follows:account10status1userid10
            then Sign = md5(7eESLc0x69I7eESLc0x69J1533179478000account10status1userid1087ceba599b6d39a39deb01cf71eacd57)
            = 6f732b47933684dd11a770d6575f43fa
          
        

Provide the Java version of the signature code as follows, other languages please refer to the code to achieve their own

          
            import com.alibaba.fastjson.JSON;
            import java.nio.charset.Charset;
            import java.security.MessageDigest;
            import java.security.NoSuchAlgorithmException;
            import java.util.HashMap;
            import java.util.Map;

            /**
            * @Author:
            * @Description:
            * @Date: Created in 2018/6/26  下午3:48
            * @Modified By:
            */
            public class SignUtils {
                private static Charset DEFAULT_CHARSET = Charset.forName("UTF-8");

                /**
                * Set it up according to your needs, generally think that only one is used in a service.
                */
                public static String ID_NAME = "Apiid";

                /**
                * Not null, not empty string, not double quotes, not empty{}
                *
                * @param source
                * @return
                */
                public static boolean isEmpty(String source) {
                    return source == null || source.isEmpty() || source.equals("\"\"") || source.trim().equals("{}");
                }

                /**
                * The signature header is obtained by the form data key value or the get parameter form.
                * @param parameters
                * @return
                */
                public static Map getHeaderOfKeyValue(String id, String secret,Map<String, Object> parameters) {
                    long time = System.currentTimeMillis();
                    Map header = new HashMap();
                    StringBuffer contentSb = new StringBuffer();
                    parameters = new TreeMap<>(parameters);
                    Iterator it = parameters.entrySet().iterator();
                    while(it.hasNext()){
                        Map.Entry entry = (Map.Entry)it.next();
                        contentSb.append(entry.getKey()).append(entry.getValue());
                    }

                    header.put(ID_NAME,id);
                    header.put("Timestamp", String.valueOf(time));
                    header.put("Sign", encryptMD5(id + time + contentSb.toString() + secret));
                    return header;
                }

                /**
                * Get the signature header when the parameter is empty
                * @return
                */
                public static Map getHeaderOfNoParams(String id, String secret) {
                    Map header = new HashMap();
                    long time = System.currentTimeMillis();
                    header.put(ID_NAME, id);
                    header.put("Timestamp", String.valueOf(time));
                    header.put("Sign", encryptMD5(id + time + secret));
                    return header;

                }

                /**
                * Get the signature header if the argument is in the form of body json
                * @param object
                * @return
                */
                public static Map getHeaderOfBodyJson(String id, String secret, Object object) {
                    Map header = new HashMap();
                    long time = System.currentTimeMillis();
                    String params = JSON.toJSONString(object);
                    header.put(ID_NAME, id);
                    header.put("Timestamp", String.valueOf(time));
                    header.put("Sign", encryptMD5(id + time + params + secret));
                    return header;
                }

                public static String encryptMD5(String str) {
                    return digest("MD5", str);
                }

                public static String digest(String code, String str) {
                    try {
                        MessageDigest messageDigest = MessageDigest.getInstance(code);
                        messageDigest.reset();
                        messageDigest.update(str.getBytes(DEFAULT_CHARSET));
                        byte[] byteArray = messageDigest.digest();
                        StringBuffer md5StrBuff = new StringBuffer();

                        for(int i = 0; i < byteArray.length; ++i) {
                            if (Integer.toHexString(255 & byteArray[i]).length() == 1) {
                                md5StrBuff.append("0").append(Integer.toHexString(255 & byteArray[i]));
                            } else {
                                md5StrBuff.append(Integer.toHexString(255 & byteArray[i]));
                            }
                        }

                        return md5StrBuff.toString();
                    } catch (NoSuchAlgorithmException var6) {
                        var6.printStackTrace();
                        return null;
                    }
                }
            }
          
        

6 Market class interface

Note that the market quotation class interface does not require signature, and the header does not need to pass several parameters of the signature. This part of the interface can only access 1000 times in one minute, please pay attention to the control frequency.

6.1 All market 24H market prices

This data server update speed is 5 seconds, not too frequent
path:/api/data/v1/tickers
Request method:get
Request message

isUseMarketName=true //Must pass, select true to return the result with the market name of BTC_USDT instead of marketId, false use marketId

Return message in two formats
When isUseMarketName is fasle, the format is as follows

          
            {
              "resMsg": {
                  "code": "1",
                  "method": null,
                  "message": "success !"
              },
              "datas": [
                  [
                      99,
                      "0.0",
                      "0",
                      "0",
                      "0",
                      "0.0",
                      "[]",
                      "9.396",
                      "9.08",
                      "21469873.428"
                  ],
                  [
                      90,
                      "8249994.968",
                      "8257720.9458",
                      "8207608.58",
                      "1080294.9779",
                      "0.51",
                      "[[1, 8219706.597], [2, 8249994.998]]",
                      "7418805.42381067",
                      "7418805.425",
                      "21469873.428"
                  ]
              ]
            }
          
        

When isUseMarketName is true, the format is as follows

          
            {
              "resMsg": {
                  "code": "1",
                  "method": null,
                  "message": "success !"
              },
              "datas": {
                  "ETC_USDT": [
                      99,
                      "0.0",
                      "0",
                      "0",
                      "0",
                      "0.0",
                      "[]",
                      "9.296",
                      "9.708",
                      "21469873.428"
                  ],
                  "BTC_KRW": [
                      90,
                      "8245004.195",
                      "8257720.93",
                      "8207608.57",
                      "1187226.0187",
                      "0.45",
                      "[[1, 8219706.597], [2, 8245004.125]]",
                      "7418805.413",
                      "7418805.47",
                      "21469873.408"
                  ]
              }
            }
          
        

the data shows

          
            [Market ID, latest transaction price, highest price, lowest price, 24-hour volume, 24-hour price increase, recent 6H closing price list, buy one price, sell one price, 24-hour turnover (unit is buyer's currency) ]
          
        

The list of recent 6H closing prices is sorted in chronological order, data description:

          [[serial number, closing price], [serial number, closing price], [serial number, closing price]]
        

6.2 Single market 24H market

This data server update speed is 5 seconds, not too frequent
path:/api/data/v1/ticker
Request method:get
Request message

          
            marketId=90          //Market id, and the market name can be passed
            marketName=ETC_USDT          //Market name, and market id can be passed
          
        

Return message format

          
            {
              "datas": [
                  99,
                  "826.4023",
                  "826.4023",
                  "820.5862",
                  "172.1401",
                  "0.73",
                  "[[1, 821.597], [2, 826.7998], [3, 826.4023]]",
                  "741.4126",
                  "741.4237",
                  "2143.408"
              ],
              "resMsg": {
                  "code": "1",
                  "method": null,
                  "message": "success !"
              }
            }
          
        

the data shows

          
            [Market ID, latest transaction price, highest price, lowest price, 24-hour volume, 24-hour price increase, recent 6H closing price list, buy one price, sell one price, 24-hour turnover (unit is buyer's currency) ]
          
        

The list of recent 6H closing prices is sorted in chronological order, data description:

          
            [[serial number, closing price], [serial number, closing price], [serial number, closing price]]
          
        

6.3 K line

path:/api/data/v1/klines
Request method:get
Request message

          
            marketId=90                     //Market id, and the market name can be passed
            marketName=ETC_USDT             //Market name, and market id can be passed
            type=1M                         //K line type, support 1M, 5M, 15M, 30M, 1H, 1D, 1W Seven types, representing 1-30 minutes, 1 hour, 1 day, 1 week
            dataSize=5                      //The amount of data, up to 500
          
        

Return message format

          
            {
              "datas": [
                  [
                      "K",
                      "99",
                      "etc_usdt",
                      "1532181600",
                      "826.7",
                      "827.68",
                      "826.68",
                      "826.07",
                      "492261",
                      "0.04",
                      "6.8",
                      "1H",
                      "false",
                      "407073731.01"
                  ],
                  ..........
              ],
              "resMsg": {
                  "code": "1",
                  "method": null,
                  "message": "success !"
              }
            }
          
        

the data shows

          
            [Data type, market ID, market name, time stamp, opening data, highest price, lowest price, closing price, volume, price range, US dollar exchange rate, K-line period, whether converted]
          
        

6.4 Transaction Record

path:/api/data/v1/trades
Request method:get
Request message

          
            marketId=90                     //Market id, and the market name can be passed
            marketName=ETC_USDT             //Market name, and market id can be passed
            dataSize=10                     //The amount of data, up to 20
          
        

Return message format

          
            {
              "datas": [
                  [
                      "T",
                      "99",
                      "1532183063",
                      "ETC_USDT",
                      "bid",
                      "827.90",
                      "515.50"
                  ],
                  ..........
              ],
              "resMsg": {
                  "code": "1",
                  "method": null,
                  "message": "success !"
              }
            }
          
        

the data shows

          
            [Data type, market ID, time stamp, currency information, type of sale (asks sell bids), price, quantity]
          
        

6.5 Handicap data (market depth)

This interface returns the market data of up to 50 files.
path:/api/data/v1/entrusts
Request method:get
Request message

          
            marketId=90                     //Market id, and the market name can be passed
            marketName=ETC_USDT             //Market name, and market id can be passed
            dataSize=5                      //The number of gears means that each sale is 5 files, and the maximum is 50.
          
        

Return message format

          
            {
              "datas": {
                  "asks": [
                      [
                          "824.898",
                          "5.95"
                      ],
                      [
                          "741.435",
                          "4.88"
                      ],
                      [
                          "741.47",
                          "0.01"
                      ]
                  ],
                  "bids": [
                      [
                          "294",
                          "24.32"
                      ],
                      [
                          "247",
                          "2.064"
                      ],
                      [
                          "216",
                          "17.043"
                      ]
                  ],
                  "timestamp": "1532183394"
              },
              "resMsg": {
                  "code": "1",
                  "method": null,
                  "message": "success !"
              }
          
        

the data shows

          
            asks:(sell) [[price, quantity]]
            bids:(Buy) [[price, quantity]]
          
        

7 Error code

The message returned on failure is as follows

          
            {
              "datas": null,
              "resMsg": {
                  "code": "1000",
                  "method": null,
                  "message": "param invalid"
              }
            }
          
        

Error code list

Error codeDescriptionDescription in English
999签名错误sign is invalid!
1000系统错误system error
1003无效的参数param invalid
2000参数错误parameter error
2001委托价格类型为空entrust price range type null
2002委托类型错误rangeType [ 0,1] error
2003委托价格异常entrust price abnormal
2004市场ID不能为空market id null
2008买卖类型不能为空type[ buy :type=1 or sell: type=0] null
2009买卖类型错误type[ buy :type=1 or sell: type=0] error
2012委托信息不存在或状态异常entrust not exists or status abnormal
2014缓存中无该该委托单entrust not exists in cache
2015委托单已取消或数据库中不存在entrust already canceled or not exists in database
2016分页index,pageSize参数有误paging:index or pageSize invalid
2017交易货币量为空entrust amount null
2018交易货币量异常entrust amount abnormal
2019委托单ID不能为空entrustId null
2020委托类型不能为空entrustType null
2022交易货币量小于最小值entrust amount low min limit
2999内部错误system error
6000参数缺失Param Missing
6002授权失效,需要重新登录Authorization invalid, please sign in again.
6021限制提币操作Limit the withdraw operation
6076安全密码错误,请重新输入Security password error, please enter again!
6095用户不存在User does not exist
6096无效的参数Invalid parameter
6114提币地址为空Please select a currency address!
6124审核失败Audit failure!
6126审核通过Audit Approve!
6115提交提币申请失败Submit a withdrawal application failure!
6125无效的货币类型An invalid currency type!
6130没有选取币种No selection of currency, Please try again!
6894时间过长,API签名已失效The time is too long,sign for api is invalid now!
6895校验API权限失败,接口不属于授权APIFailed to verify the API permission. This interface is not a authorize API!
6896校验API权限失败,Userid和Apiid不匹配Failed to verify the API permission. The Userid is not matching with Apiid!
6897校验API权限失败,请确认是否开启Api权限Failed to verify the API permission. Please confirm whether to enable API permission!
6898多次校验API权限失败,请确认是否开启Api权限Failed to verify the API permission for multiple times. Please confirm whether to enable API permission!
6900交易所现暂不对外开放api交易The exchange server temporarily not open to API trading!
10012未知异常unknown error

Error code description of market, market data (market depth), k line, transaction record four types of API

Error codeDescriptionDescription in English
1000系统错误system error
5010参数错误param is invalid
5016数据不存在data not exist
5017该市场不存在market not exist
5019你的IP一分钟内访问次数过多your ip has too many visits per minute