Trade API(http)

HTTP API

BW为用户提供了一个简单的而又强大的API,旨在帮助用户快速高效的将BW交易功能整合到自己应用当中。如果在使用过程中有任何问题,请联系我们技术讨论QQ群,我们将为您做出最权威的解答。我们提供了Java和Python版本的完整Demo,请加群索取。

API Address Domain Name address

Domain name address:https://www.BW.com/

Use Instruction

使用这些API之前首先要获取两项参数,在网站登录后,进入API功能,开启然后获取Api Id和Api Secret两项参数。拥有这两个参数便拥有交易下单、查询资产等高级权限,请用户注意保密。除了1.1获取市场列表、1.2获取币种列表、6市场行情类接口,其他所有http接口都需要进行签名,签名规则在后面说明。

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,//数量精度
                  "minAmount": "0.0001000000",//最小数量
                  "buyerCurrencyId": "2",//买方币种
                  "priceDecimal": 8,//价格精度
                  "serverId": "entrust-server-001",//服务ID
                  "marketId": "70",//市场ID
                  "webId": "100", //站点ID
                  "modifyTime": 0,
                  "sellerCurrencyId": "19",//卖方币种
                  "createTime": 1522400906009,
                  "defaultFee": "0.00050000",//默认费率
                  "name": "eth_btc",//市场名称
                  "leverType": "1",//杠杆类型: 1现货 2杠杆
                  "state": 1,//状态: 1 运行, 2 暂停(不能下单交易, 0 停止 -1 删除
                  "openTime": 1,//开盘时间,单位为毫秒的时间戳
                  "isMining":0 //是否挖矿:1是 0不是
                },
                ....
              ],
              "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",//总量
                  "tradeSearchUrl": null,//交易查询地址
                  "tokenCoinsId": 0,//如果大于0是另一种币的token,否则等于0
                  "minCash": null,
                  "tokenName": null,//
                  "description": "比特币",//描述
                  "arithmetic": null,   //共识算法
                  "dailyDrawLimit": 10000,
                  "remark": null,   //
                  "isLegalCoin": 0, //是否是法币,比如美金 1是,0不是
                  "outConfigTimes": 0,//
                  "timesFreetrial": "0",//
                  "hourFreetrial": "0",//
                  "inConfigTimes": 6,//
                  "alias": "b",//别名
                  "logo": "market-btc.png",//图标
                  "needBlockUrl": 0,//是否需要block地址,0不需要 1需要
                  "currencyId": "2",//币种ID
                  "drawFlag": 1,
                  "rechargeFlag": 1,
                  "onceDrawLimit": 100,
                  "founder": null,
                  "drawFee": "0.00100000",
                  "blockChainUrl": "https://blockchain.info/tx/", //blockChain查询地址(区块查询地址)
                  "dayFreetrial": "0",
                  "marketValue": null,//总市值
                  "minFee": null,
                  "teamAddress": null,
                  "defaultDecimal": 2,//币种小数位(精度)-优先级低于 market中的配置
                  "publishNumber": "14500000.00000000",//已发行
                  "isMining": "0",//是否可挖矿
                  "name": "btc",//名称
                  "limitAmount": null,
                  "websiteCurrencyId": "223f4d23232",
                  "state": 1, //状态 -1 删除 0 禁用 1启用 默认1
                  "descriptionEnglish": "<p>The BTC is ...</p>",//英文描述
                  "mark": null//符号
                },
                .....
              ],
              "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,//是否手机认证:0:否,1:是
              "googleStatus":0,//审核状态:0:没审核,1:修改审核中
              "isAlipay":"",//是否绑定支付宝1绑定0未绑定
              "loginPwd":"1",//是否设置登录密码:0:否,1:是
              "externalUidType":null,//扩展的userid来源类型,比如:zb,exx
              "isWechat":"",//是否绑定微信1绑定0未绑定
              "loginAuth":3,//登录验证(1-登录密码 2-异地登录验证 4-谷歌验证,可以三者任意组合,默认 3
              "merchantName":"",//商户名字
              "countryCode":"+86",//国家代码
              "loginName":"130***17",//登录名
              "loginGoogleAuth":1,//是否谷歌认证:0:否,1:是
              "email":null,//用户邮箱
              "nickName":"130***17",//用户昵称
              "isBank":"",//是否绑定银行
              "mobileAuth":1,//是否手机认证:0:否,1:是,[2:修改失败,不通过,-1:修改审核中]
              "mobile":"+86 130***17",//手机号码
              "userId":"test6",//用户id
              "recommendCode":"dGVzdDY=\u000a",//推荐码
              "realName":"",//用户实名
              "withdrawAuth":3,//提现验证(1-资金密码 2-短信/邮箱验证 4-谷歌验证码 默认资金密码+短信/邮箱 = 3)
              "recommendCount":null,//推荐人数
              "externalUserId":null,//扩展的userid,比如zb一键登陆保存的zb的userid
              "mobileStatus":0,//审核状态:0:没审核,1:修改审核中
              "safePwdAuth":0,//是否设置安全密码:0:否,1:是
              "googleAuth":1,//是否谷歌认证:0:否,1:是
              "loginEmailAuth":0,//是否邮箱认证:0:否,1:是
              "tradeAuth":1,//交易验证(1-永不输入资金密码 2-6小时内免输资金密码 3-每次交易均验证资金密码)
              "status":1//0(000-初始状态) 1(001-已实名认证) 2(010-已银行认证) 3(011已实名和银行认证)
              },
              "resMsg":{
              "code":"1",
              "method":null,
              "message":"success !"
              }
            }
          
        

3 Trade API

3.1 Additional entrustment

path:/exchange/entrust/controller/website/EntrustController/addEntrust
Request method:post
请求报文格式:application/json
Request message:

          
            json
            {
              "amount": 0,                          //下单数量
              "type": 0,                            //买卖类型:0 卖出 1 购买
              "rangeType": 0,                            //委托类型 0 为限价委托 1 区间委托,目前暂时只支持限价委托
              "marketId": "90",                     //市场ID
              "price": 0                            //价格
            }
          
        

Return message>

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

3.2 Cancel order

path: /exchange/entrust/controller/website/EntrustController/cancelEntrust
Request method:post
请求报文格式:application/json
Request message:

          json
            {
              "entrustId": "E6419466484531482624",  //要取消的委托ID
              "marketId": "90" //市场ID
            }
          
        

Return message

          json
            {
                "datas": null,
                "resMsg": {
                    "code": "1", //1代表成功,其他错误码见说明
                    "method": null,
                    "message": "success !"
                }
            }
          
        

3.3 Check open orders(新版接口)

此接口只返回状态(status)为起始、交易一部分的订单,支持分页。

path: /exchange/entrust/controller/website/EntrustController/getUserEntrustRecordFromCacheWithPage
Request method:post
Request message:key-value


        marketId=80 //市场ID
        pageSize: 4 //每页条数
        pageIndex: 1 //页码,从1开始计算
        

Return message

          json
            {
                "datas":{
                "entrustList":[
                {
                  "amount":"7",                     //数量
                  "availabelAmount": "3.02",      //剩余可以成交的数量
                  "completeAmount": "1.99",       //已经成交的数量
                  "completeTotalMoney":"15.92",     //已完成的总金额
                  "totalMoney":"56.003",                //总金额
                  "rangeType":0,                        //区间类型 0 现价委托 1 区间委托
                  "rangeLowPrice":null,             //区间委托的最低价
                  "rangeHighPrice":null,                //区间委托的最高价
                  "entrustId":"E6437955999037923328",   //委托ID
                  "type":0,                         //0 卖出 1 购买  -1 取消
                  "userId":"test6",                 //用户id
                  "dealTimes":1,                    //交易处理次数
                  "createTime":1534928321609,       //下单时间
                  "price":"8.00005",                //单价
                  "entrustType":0,              //委托类型 0普通委托单 1杠杆委托单
                  "status":0     //状态 : -2资金解冻失败 -1用户资金不足 0起始 1取消 2交易成功 3交易一部分 4取消中
                }
                ],
                "totalRow":1,  //总行数
                "pageNum":1,   //页码,从1开始计算
                "pageSize":4,  //每页条数
                "totalPage":1  //总页数
            },
              "resMsg": {
                "code": "1",            //1代表成功,其他为错误码见说明
                "method": null,
                "message": "success !"
              }
            }
          
        

3.3 Check open orders(旧版接口)

此接口只返回状态(status)为起始、交易一部分的订单,无分页,最多只能获取到20条

path: /exchange/entrust/controller/website/EntrustController/getUserEntrustRecordFromCache
Request method:post
Request message:key-value

marketId: 90  //市场ID

Return message

          json
            {
                "datas":
                [
                {
                "amount":"1.1",                     //数量
                "rangeType":0,                      //区间类型 0 现价委托 1 区间委托
                "rangeLowPrice":null,               //区间委托的最低价
                "rangeHighPrice":null,              //区间委托的最高价
                "totalMoney":"5.555",               //总金额
                "entrustId":"E6437955999037923328", //委托ID
                "type":0,                           //0 卖出 1 购买  -1 取消
                "userId":"test6",                   //用户id
                "completeAmount":"0",               //已经成交的数量
                "marketId":"80",                    //市场id
                "dealTimes":0,                      //交易处理次数
                "createTime":1534928321609,         //下单时间
                "price":"5.05",                     //单价
                "completeTotalMoney":"0",           //已完成的总金额
                "entrustType":0,                //委托类型 0(false)普通委托单 1(true)杠杆委托单
                "status":0                          //状态 : -2资金解冻失败 -1用户资金不足 0起始 1取消 2交易成功 3交易一部分 4取消中
                }
                  ],
                  "resMsg": {
                    "code": "1",            //1代表成功,其他为错误码见说明
                    "method": null,
                    "message": "success !"
                  }
            }
          
        

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

此接口只返回状态为待撮合、已成交、部分成交、已取消、取消中的委托记录

paht: /exchange/entrust/controller/website/EntrustController/getUserEntrustList
Request method:get
Request message:body json

          
            marketId=90 //市场ID
            pageIndex=1 //页码
            pageSize=20 //每页展示条数
            type=0 //(可选)委托类型,0 卖出 1 购买  -1 取消
            status=0 //(可选)状态 : -2资金解冻失败 -1用户资金不足 0起始 1取消 2交易成功 3交易一部  4取消中
            startDateTime=1533204010299 //(可选)委托下单的起始时间,13位时间戳
            endDateTime= 1534204030299 //(可选)委托下单的结束时间,13位时间戳
          
        

Return message

          json
            {
                "datas":{
                "entrustList":[
                {
                "amount":"1.1",                     //数量
                "rangeType":0,                      //区间类型 0 现价委托 1 区间委托
                "rangeLowPrice":null,               //区间委托的最低价
                "rangeHighPrice":null,              //区间委托的最高价
                "totalMoney":"5.555",               //总金额
                "entrustId":"E6437955999037923328", //委托ID
                "type":0,                           //0 卖出 1 购买  -1 取消
                "userId":"test6",                   //用户id
                "completeAmount":"0",               //已经成交的数量
                "marketId":"80",                    //市场id
                "dealTimes":0,                      //交易处理次数
                "createTime":1534928321609,         //下单时间
                "price":"5.05",                     //单价
                "completeTotalMoney":"0",           //已完成的总金额
                "entrustType":0,                //委托类型 0普通委托单 1杠杆委托单
                "status":0              //状态 : -2资金解冻失败 -1用户资金不足 0起始 1取消 2交易成功 3交易一部分 4取消中
                },
                ....
                ],
                "totalPage":2,              //委托记录总条数
                "currentPage":1                 //当前页数
                },
                  "resMsg": {
                    "code": "1",            //1代表成功,其他为错误码见说明
                    "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 //市场ID
            entrustId:  E6419443135315070976 //要查询的委托ID
          
        

Return message

          json
            {
                "datas": {
                  "amount":"1.1",                     //数量
                  "rangeType":0,                      //区间类型 0 现价委托 1 区间委托
                  "rangeLowPrice":null,               //区间委托的最低价
                  "rangeHighPrice":null,              //区间委托的最高价
                  "totalMoney":"5.555",               //总金额
                  "entrustId":"E6437955999037923328", //委托ID
                  "type":0,                           //0 卖出 1 购买  -1 取消
                  "userId":"test6",                   //用户id
                  "completeAmount":"0",               //已经成交的数量
                  "dealTimes":0,                      //交易处理次数
                  "createTime":1534928321609,         //下单时间
                  "price":"5.05",                     //单价
                  "completeTotalMoney":"0",           //已完成的总金额
                  "entrustType":0,                //委托类型 0(false)普通委托单 1(true)杠杆委托单
                  "status":0                          //状态 : -2资金解冻失败 -1用户资金不足 0起始 1取消 2交易成功 3交易一部分 4取消中
                  },
                    "resMsg": {
                      "code": "1",            //1代表成功,其他为错误码见说明
                      "method": null,
                      "message": "success !"
                    }
            }
          
        

4 Financial API

4.1 Obtain deposit address

path:exchange/fund/controller/website/fundcontroller/getPayinAddress
Request method:post
请求报文格式: application/json
Request message:body json

          
            {
              “currencyTypeName”:"btc" //货币类型名称(必传)
            }
          
        

Return message

          
            {
                "datas": {
                    "address": "19cdJwd3j6ArHNhiYoWpN8cJq9ash7WDDC",//充币地址
                    "wallet": "merchants014"
                },
                "resMsg": {
                    "code": "1",
                    "method": null,
                    "message": "success !"
                }
            }
          
        

4.2 查询充币记录

path:exchange/fund/controller/website/fundcontroller/getPayinCoinRecord
请求方式:post
请求报文格式:application/json
请求报文:body json

          
            {
                “currencyTypeName”:“qtum”, //货币类型
                “sort”:1 //不传按充币时间倒序排,传了按升序排序,
                "pageNum":1
                "pageSize":20
            }
          
        

返回报文

          
            {
              "datas": {
                "totalRow": 1,  //总行数
                "totalPage": 1, //总页数
                "pageSize": 20, //每页数量
                "list": [
                    {
                        "currencyTypeId": 1,//货币类型id
                        "depositId": “f3342424”,//充值主键
                        "amount": "10.0",//充币数量
                        "confirmTimes": "4",//确认次数
                        "createTime": "2018-03-10 10:22:09.0",//充币时间
                        "depositAddress": "1BKd2sSPYzxC2XHurR6oQWc2wzSx2rZzck",//充币地址
                        "txId": "6378183001917882368",//交易id
                        "userId": "1",//用户id
                        "status": 1,//'0:未到账  1:已到账'
                    }
                ],
                "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    //币种id(必传)
            tab=all         //(必选) | all(所有), wait(已提交,未审核), success(审核通过), fail(审核失败), cancel(用户主动取消)
            pageIndex=1     //必传, 默认1
            pageSize=10     //必传, 默认10
          
        

Return message

          
            {
              "datas": {
                  "totalRow": 34,                                          //总行数
                  "totalPage": 4,                                          //总页数
                  "pageSize": 10,                                          //每页数量
                  "list": [
                      {
                          "modifyUid": null,                               //修改人id
                          "withdrawalId": "W6419027628808093696",          //提现id
                          "fees": "0.001000000000000000",                  //手续费
                          "amount": "10.000000000000000000",               //提现数量
                          "userApplyWithdrawId": "7eBDJ5PKbSK",            //提现记录id
                          "verifyRemark": null,                            //审核意见
                          "remark": null,                                  //备注
                          "verifyTime": 0,                                 //审核时间
                          "userName": "[email protected]",                  //用户名
                          "userId": "7e9ioSoVXcW",                         //用户id
                          "actuallyAmount": "10.000000000000000000",       //实际到账数量
                          "modifyTime": 0,                                 //修改时间
                          "verifyStatus": 0,                               //审核状态(0 待审核 , 1 审核通过 -1 审核不通过)
                          "createTime": 1530415446577,                    //提币时间
                          "state": 1,                                                             //状态(-1 删除, 1 正常)
                          "currencyId": "2",                                                          //币种id
                          "withdrawalAddress": "1JimMZks39eVqU6T3v6wvz1m4LtJ3tPjGL",                  //提币地址
                          "verifyUid": null                                                           //审核人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
请求报文格式:application/json
Request message:body json

          
            {
                "pageSize":30,       # 每页行数(可选)
                "pageNum":1          # 页码(可选)
            }
          
        

Return message

          
            {
                "datas": {
                    "totalRow": null,
                    "totalPage": null,
                    "pageSize": 30,
                    "list": [
                        {
                            "currencyTypeId": 1,                    //货币类型id
                            "amount": "971.174",     //用户当前可用资金数量
                            "freeze": "122",     //用户冻结资金数量
                            "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形式提交

          
            currencyId=2          //(必传)
            pageIndex=1           //(必传, 默认1)
            pageSize=10           //(必传, 默认10)
          
        

Return message

          
            {
              "datas": {
                  "totalRow": 2,
                  "totalPage": 1,
                  "pageSize": 10,
                  "list": [
                      {
                          "address": "1DkwrD4bMtjd6kcZw8CxM9r3z4AGVFfSRz",    //地址
                          "modifyTime": 1524217688882,                        //修改时间
                          "currencyName": "btc",                              //币种名称
                          "createTime": 1523185357488,                        //提币时间
                          "userFundAddressId": "7bwK95B7jTk",                 //地址id
                          "remark": "correct",                                //备注
                          "currencyId": "2",                                  //币种id
                          "type": 1,                                          //(1-提币地址, 2-打币地址)
                          "userName": "Mr.牛",                                //用户名
                          "userId": "7e8fMkzTlL6",                            //userId
                          "status": "1"                                       //状态(-1 删除, 1 正常)
                      }
                  ],
                  "pageNum": 1
              },
              "resMsg": {
                  "code": "1",
                  "method": null,
                  "message": "success !"
              }
            }
          
        

5 Signature and password encryption rules

5.1 Signature rules

签名串sign=md5(Apiid+Timestamp+参数内容拼串+签名秘钥),签名秘钥为Api Secret,和Apiid在网站打开Api功能时获取,参数拼串内容规则,有三种,只有header参数的为空字符串"",body json格式的参数为body参数的json字符串格式,key-value以及get形式的参数内容拼串为所有参数按key值首字母排序后再按key1+value1+key2+value2...的形式拼串。签名后将 Apiid、Timestamp、Sign放入到请求header中,注意首字母大写,后面全小写。
For example, when turns on API on the website, it gets the following two parameters Apiid=7eESLc0x69I7eESLc0x69J,Apisecret = 87ceba599b6d39a39deb01cf71eacd57,Timestamp=1533179478000,
a、Body json 格式参数

          
            参数内容json字符串为:{"userId":"u111","name":"zhangsan"}
            参数内容拼串为:{"userId":"u111","name":"zhangsan"}
            则Sign = md5(7eESLc0x69I7eESLc0x69J1533179478000{"userId":"u111","name":"zhangsan"}87ceba599b6d39a39deb01cf71eacd57)
            = 9bd4ef5f834add851badb0bbd5bb0f2c
          
        

b、Withour any body or get parameter

          
            参数内容拼串为空
            则Sign = md5(7eESLc0x69I7eESLc0x69J153317947800087ceba599b6d39a39deb01cf71eacd57)
            = 935b6a59860cc12e802e5dee30c6a614
          
        

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

          
            参数内容为:userid=10,status=1,acount = 10
            参数内容拼串为:account10status1userid10
            则Sign = md5(7eESLc0x69I7eESLc0x69J1533179478000account10status1userid1087ceba599b6d39a39deb01cf71eacd57)
            = 6f732b47933684dd11a770d6575f43fa
          
        

提供Java版本的签名代码如下,其他语言请参考代码自行实现

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

                /**
                * 自行根据需要设置,一般认为一个服务里使用的只有一个
                */
                public static String ID_NAME = "Apiid";

                /**
                * 不为空、不为空字符串、不为双引号、不为空{}
                *
                * @param source
                * @return
                */
                public static boolean isEmpty(String source) {
                    return source == null || source.isEmpty() || source.equals("\"\"") || source.trim().equals("{}");
                }

                /**
                * 参数是formdata key value,或者get参数 形式的情况下获取签名header
                * @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;
                }

                /**
                * 参数为空情况下获取签名header
                * @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;

                }

                /**
                * 参数是body json形式的情况下获取签名header
                * @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 市场行情类接口

注意,市场行情类接口不需要签名,header不需要传签名的几个参数。这部分接口一个IP一分钟内最多只能访问1000次,请注意控制频率。

6.1 所有市场24H市场行情

这个数据服务端更新速度为5秒一次,不必太过频繁获取
path:/api/data/v1/tickers
请求方式:get
请求报文

isUseMarketName=true //必传,选择true则返回的结果中用BTC_USDT这样的市场名替代掉marketId,false则使用marketId

返回报文分两种格式
sUseMarketName为fasle时格式如下

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

isUseMarketName为true时格式如下

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

数据说明

          
            [ 市场ID, 最新成交价, 最高价,最低价, 24小时成交量,24小时涨跌幅, 最近6H收盘价列表,买一价,卖一价,24小时成交额(单位是买方币种)]
          
        

最近6H收盘价列表按时间顺序排序,数据说明:

          [[序号, 收盘价], [序号, 收盘价], [序号, 收盘价]]
        

6.2 单个市场24H市场行情

这个数据服务端更新速度为5秒一次,不必太过频繁获取
path:/api/data/v1/ticker
请求方式:get
请求报文

          
            marketId=90          //市场id,和市场名传一个即可
            marketName=ETC_USDT          //市场名,和市场id传一个即可
          
        

返回报文格式

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

数据说明

          
            [ 市场ID, 最新成交价, 最高价,最低价, 24小时成交量,24小时涨跌幅, 最近6H收盘价列表,买一价,卖一价,24小时成交额(单位是买方币种)]
          
        

最近6H收盘价列表按时间顺序排序,数据说明:

          
            [[序号, 收盘价], [序号, 收盘价], [序号, 收盘价]]
          
        

6.3 K线

path:/api/data/v1/klines
请求方式:get
请求报文

          
            marketId=90                     //市场id,和市场名传一个即可
            marketName=ETC_USDT             //市场名,和市场id传一个即可
            type=1M                         //K线类型,支持1M,5M,15M,30M,1H,1D,1W 七种类型,分别代表1-30分钟,1小时,1日,1周
            dataSize=5                      //数据量,最多为500
          
        

返回报文格式

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

数据说明

          
            [数据类型, 市场ID, 市场名字, 时间戳, 开盘数据, 最高价, 最低价, 收盘价, 成交量, 涨跌幅度, 美元汇率, K线周期, 是否经过转换]
          
        

6.4 交易记录

path:/api/data/v1/trades
请求方式:get
请求报文

          
            marketId=90                     //市场id,和市场名传一个即可
            marketName=ETC_USDT             //市场名,和市场id传一个即可
            dataSize=10                     //数据量,最多为20
          
        

返回报文格式

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

数据说明

          
            [数据类型, 市场ID, 时间戳, 币种信息, 买卖类型(asks卖bids买), 价格, 量]
          
        

6.5 盘口数据(市场深度)

本接口最多返回买卖50档的盘口数据
path:/api/data/v1/entrusts
请求方式:get
请求报文

          
            marketId=90                     //市场id,和市场名传一个即可
            marketName=ETC_USDT             //市场名,和市场id传一个即可
            dataSize=5                      //档位数,表示买卖各5档,最大为50
          
        

返回报文格式

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

数据说明

          
            asks:(卖盘)[[价格, 量]]
            bids:(买盘)[[价格, 量]]
          
        

7 Error code

失败时返回报文如下

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

行情、盘口数据(市场深度)、k线、交易记录四类API的错误码说明

错误码说明英文说明
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