用户API-HTTP接口

Trade API(http)

HTTPAPI

BW provides users with a simple and powerful API designed to help them quickly and efficiently integrate BW trading functionality into their applications.

API Address Domain Name address

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

Use Instruction

Before using these API, you need to get two parameters first. After login in the website, you need to go to the API feature turn-on to get the Api ID and Api Secret parameters. Through these two parameters you can have the high-level permissions to issue a transaction order, withdrawal and so on. Please pay attention to the confidentiality. All http interfaces need to be signed, and the signing rules are explained later.

1 API Configuration and basic function

1.1 获取市场列表

path:/exchange/config/controller/website/marketcontroller/getByWebId
Request method: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 运行, 0 停止 -1 删除
      "openTime": 1,//开盘时间
    },
    ....
  ],
  "resMsg": {
    "code": "1",
    "method": null,
    "message": "success !"
  }
}

1.2 获取币种列表

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",
      "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,BW
"isWechat":"",//是否绑定微信1绑定0未绑定
"loginAuth":3,//登录验证(1-登录密码 2-异地登录验证 4-谷歌验证,可以三者任意组合,默认 3
"merchantName":"",//商户名字
"countryCode":null,//国家代码
"loginName":"13068859717",//登录名
"loginGoogleAuth":1,//是否谷歌认证:0:否,1:是
"email":null,//用户邮箱
"nickName":"13068859717",//用户昵称
"isBank":"",//是否绑定银行
"mobileAuth":1,//是否手机认证:0:否,1:是,[2:修改失败,不通过,-1:修改审核中]
"mobile":"+86 13068859717",//手机号码
"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":1,//是否设置安全密码: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
Request message

json
{
  "amount": 0,                          //下单数量
  "type": 0,                            //买卖类型:0 卖出 1 购买
  "rangeType": 0,                            //恒定为0
  "marketId": "90",                     //市场ID
  "price": 0                            //价格
}

返回报文:

json
{
    "datas": {
        "entrustList": [{
            "amount": "43.730000000000000000”,                //数量
            "rangeType": 0,                                    //区间类型:0现价委托 1区间委托
            "rangeLowPrice": null,                              //区间委托的最低价
            "customerOrderId": null,                            //站点的内部委托单id
            "rangeHighPrice": null,                             //区间委托的最高价
            "totalMoney": "31.603671000000000000”,            //总金额
            "entrustId": "E6434001988198871040”,              //委托id
            "type": 1,                           				//0 卖出 1 购买  -1 取消
            "userId": "7eiiEs6gmlE”,            				 //站点的用户id
            "freezeId": "Z6434001988224442368”, 			 //冻结Id,取消时候存储被取消的id
            "completeAmount": "43.730000000000000000”,	//已经成交的数量
            "marketId": "302”,                   			//市场id
            "dealTimes": 1,                      			//交易处理次数
            "webId": "102”,                      				//网站的id
            "createTime": 1533985611963,        				 //发送时间
            "price": "0.722700000”,             			 //单价
            "completeTotalMoney": "31.603671000000000000”,   //已完成的总金额
            "entrustType": false,                               //'委托类型 0普通委托单 1杠杆委托单'
            "sumToWeb": 1,                      				 //'是否合并到主项目’:默认为1
            "status": 2                                        //'状态 : -2资金解冻失败 -1用户资金不足 0起始 1取消 2交易成功 3交易一部分 4撮合完成等待资金变更 
                                                                    //13 部分完成等待资金变更 12 撮合完成等待资金变更
    }],
        "totalPage": 1,
        "currentPage": 1
    },
    "resMsg": {
        "code": "1",
        "method": null,
        "message": "success !"
    }
}

3.2 Cancel order

path: /exchange/entrust/controller/website/EntrustController/cancelEntrust
Request method:post
请求报文:

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

返回报文:

json
{
    "datas": {
        "entrustList": [{
            "amount": "43.730000000000000000”,                //数量
            "rangeType": 0,                                    //区间类型:0现价委托 1区间委托
            "rangeLowPrice": null,                              //区间委托的最低价
            "customerOrderId": null,                            //站点的内部委托单id
            "rangeHighPrice": null,                             //区间委托的最高价
            "totalMoney": "31.603671000000000000”,            //总金额
            "entrustId": "E6434001988198871040”,              //委托id
            "type": 1,                           				//0 卖出 1 购买  -1 取消
            "userId": "7eiiEs6gmlE”,            				 //站点的用户id
            "freezeId": "Z6434001988224442368”, 			 //冻结Id,取消时候存储被取消的id
            "completeAmount": "43.730000000000000000”,	//已经成交的数量
            "marketId": "302”,                   			//市场id
            "dealTimes": 1,                      			//交易处理次数
            "webId": "102”,                      				//网站的id
            "createTime": 1533985611963,        				 //发送时间
            "price": "0.722700000”,             			 //单价
            "completeTotalMoney": "31.603671000000000000”,   //已完成的总金额
            "entrustType": false,                               //'委托类型 0普通委托单 1杠杆委托单'
            "sumToWeb": 1,                      				 //'是否合并到主项目’:默认为1
            "status": 2                                        //'状态 : -2资金解冻失败 -1用户资金不足 0起始 1取消 2交易成功 3交易一部分 4撮合完成等待资金变更 
                                                                    //13 部分完成等待资金变更 12 撮合完成等待资金变更
    }],
        "totalPage": 1,
        "currentPage": 1
    },
    "resMsg": {
        "code": "1",
        "method": null,
        "message": "success !"
    }
}

3.3 Enquiry on on-going entrustment

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

marketId: 90                    //市场ID

返回报文:

json
            {
                "datas": 
                [{
                "amount": "43.730000000000000000”,                //数量
                        "rangeType": 0,                                    //区间类型:0现价委托 1区间委托
                        "rangeLowPrice": null,                              //区间委托的最低价
                        "customerOrderId": null,                            //站点的内部委托单id
                        "rangeHighPrice": null,                             //区间委托的最高价
                        "totalMoney": "31.603671000000000000”,            //总金额
                        "entrustId": "E6434001988198871040”,              //委托id
                        "type": 1,                           				//0 卖出 1 购买  -1 取消
                        "userId": "7eiiEs6gmlE”,            				 //站点的用户id
                        "freezeId": "Z6434001988224442368”, 			 //冻结Id,取消时候存储被取消的id
                        "completeAmount": "43.730000000000000000”,	//已经成交的数量
                        "marketId": "302”,                   			//市场id
                        "dealTimes": 1,                      			//交易处理次数
                        "webId": "102”,                      				//网站的id
                        "createTime": 1533985611963,        				 //发送时间
                        "price": "0.722700000”,             			 //单价
                        "completeTotalMoney": "31.603671000000000000”,   //已完成的总金额
                        "entrustType": false,                               //'委托类型 0普通委托单 1杠杆委托单'
                        "sumToWeb": 1,                      				 //'是否合并到主项目’:默认为1
                        "status": 2                                        //'状态 : -2资金解冻失败 -1用户资金不足 0起始 1取消 2交易成功 3交易一部分 4撮合完成等待资金变更 
                                                                                //13 部分完成等待资金变更 12 撮合完成等待资金变更
            
            }]
                "resMsg": {
                "code": "1",            //1代表成功,其他为错误码见说明
                "method": null,
                "message": "success !"
                }
            }
            

3.4 Paging enquiry on historical entrustment (Only including settled and cancelled entrustment record)

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

marketId:   90                      //市场ID
pageIndex:  1               //页码
pageSize:   20              //每页展示条数

返回报文:

json
{
    "datas": {
        "entrustList": [{
            "amount": "43.730000000000000000”,                //数量
            "rangeType": 0,                                    //区间类型:0现价委托 1区间委托
            "rangeLowPrice": null,                              //区间委托的最低价
            "customerOrderId": null,                            //站点的内部委托单id
            "rangeHighPrice": null,                             //区间委托的最高价
            "totalMoney": "31.603671000000000000”,            //总金额
            "entrustId": "E6434001988198871040”,              //委托id
            "type": 1,                           				//0 卖出 1 购买  -1 取消
            "userId": "7eiiEs6gmlE”,            				 //站点的用户id
            "freezeId": "Z6434001988224442368”, 			 //冻结Id,取消时候存储被取消的id
            "completeAmount": "43.730000000000000000”,	//已经成交的数量
            "marketId": "302”,                   			//市场id
            "dealTimes": 1,                      			//交易处理次数
            "webId": "102”,                      				//网站的id
            "createTime": 1533985611963,        				 //发送时间
            "price": "0.722700000”,             			 //单价
            "completeTotalMoney": "31.603671000000000000”,   //已完成的总金额
            "entrustType": false,                               //'委托类型 0普通委托单 1杠杆委托单'
            "sumToWeb": 1,                      				 //'是否合并到主项目’:默认为1
            "status": 2                                        //'状态 : -2资金解冻失败 -1用户资金不足 0起始 1取消 2交易成功 3交易一部分 4撮合完成等待资金变更 
                                                                    //13 部分完成等待资金变更 12 撮合完成等待资金变更
    }],
        "totalPage": 1,
        "currentPage": 1
    },
    "resMsg": {
        "code": "1",
        "method": null,
        "message": "success !"
    }
}

3.5 Enquiry on entrustment record based on trust deed id

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

marketId:   90                      //市场ID
entrustId:  E6419443135315070976    //要查询的委托ID

返回报文:

json
            {
                "datas": 
                {
                "amount": "43.730000000000000000”,                //数量
                        "rangeType": 0,                                    //区间类型:0现价委托 1区间委托
                        "rangeLowPrice": null,                              //区间委托的最低价
                        "customerOrderId": null,                            //站点的内部委托单id
                        "rangeHighPrice": null,                             //区间委托的最高价
                        "totalMoney": "31.603671000000000000”,            //总金额
                        "entrustId": "E6434001988198871040”,              //委托id
                        "type": 1,                           				//0 卖出 1 购买  -1 取消
                        "userId": "7eiiEs6gmlE”,            				 //站点的用户id
                        "freezeId": "Z6434001988224442368”, 			 //冻结Id,取消时候存储被取消的id
                        "completeAmount": "43.730000000000000000”,	//已经成交的数量
                        "marketId": "302”,                   			//市场id
                        "dealTimes": 1,                      			//交易处理次数
                        "webId": "102”,                      				//网站的id
                        "createTime": 1533985611963,        				 //发送时间
                        "price": "0.722700000”,             			 //单价
                        "completeTotalMoney": "31.603671000000000000”,   //已完成的总金额
                        "entrustType": false,                               //'委托类型 0普通委托单 1杠杆委托单'
                        "sumToWeb": 1,                      				 //'是否合并到主项目’:默认为1
                        "status": 2                                        //'状态 : -2资金解冻失败 -1用户资金不足 0起始 1取消 2交易成功 3交易一部分 4撮合完成等待资金变更 
                                                                                //13 部分完成等待资金变更 12 撮合完成等待资金变更
            
            },
                "resMsg": {
                "code": "1",            //1代表成功,其他为错误码见说明
                "method": null,
                "message": "success !"
                }
            }

3.6 批量取消委托

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

marketId:   90                      //市场ID

返回报文:

json
{
    "datas": 
    [{
    "amount": "43.730000000000000000”,                //数量
            "rangeType": 0,                                    //区间类型:0现价委托 1区间委托
            "rangeLowPrice": null,                              //区间委托的最低价
            "customerOrderId": null,                            //站点的内部委托单id
            "rangeHighPrice": null,                             //区间委托的最高价
            "totalMoney": "31.603671000000000000”,            //总金额
            "entrustId": "E6434001988198871040”,              //委托id
            "type": 1,                           				//0 卖出 1 购买  -1 取消
            "userId": "7eiiEs6gmlE”,            				 //站点的用户id
            "freezeId": "Z6434001988224442368”, 			 //冻结Id,取消时候存储被取消的id
            "completeAmount": "43.730000000000000000”,	//已经成交的数量
            "marketId": "302”,                   			//市场id
            "dealTimes": 1,                      			//交易处理次数
            "webId": "102”,                      				//网站的id
            "createTime": 1533985611963,        				 //发送时间
            "price": "0.722700000”,             			 //单价
            "completeTotalMoney": "31.603671000000000000”,   //已完成的总金额
            "entrustType": false,                               //'委托类型 0普通委托单 1杠杆委托单'
            "sumToWeb": 1,                      				 //'是否合并到主项目’:默认为1
            "status": 2                                        //'状态 : -2资金解冻失败 -1用户资金不足 0起始 1取消 2交易成功 3交易一部分 4撮合完成等待资金变更 
                                                                    //13 部分完成等待资金变更 12 撮合完成等待资金变更

}]
    "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
请求报文:body json

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

返回报文


{
    "datas": {
        "address": "19cdJwd3j6ArHNhiYoWpN8cJq9ash7WDDC",//充币地址
        "isMemo": false,
        "memo": ""  
        "account": ""   
    },
    "resMsg": {
        "code": "1",
        "method": null,
        "message": "success !"
    }
}

4.2 Enquiry on deposit record

path:exchange/fund/controller/website/fundcontroller/getPayinCoinRecord
Request method:post
请求报文: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
请求报文:key-value

currencyId=1    //币种id(必传)
tab=all         //(必选) | all(所有), wait(已提交,未审核), success(审核通过), fail(审核失败), cancel(用户主动取消)
pageIndex=1     //必传, 默认1
pageSize=10     //必传, 默认10

返回报文

{
    "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": "994709373@qq.com",                  //用户名
                "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
请求报文:body json


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

返回报文


{
    "datas": {
        "totalRow": null,
        "totalPage": null,
        "pageSize": 30,
        "list": [
            {
                "currencyTypeId": 1,                      //货币类型id
                "amount": "0",                           //用户当前可用资金数量
                "fundId": "F3785385345384r84337",
                "freeze": "122.000000000000000000",      //用户冻结资金数量
                "saved": "122.000000000000000000",      //存币冻结(数量为0时是不会显示该参数)
                "modifyTime": "2018-02-19 10:02:33",
                "webId":"102",                           //站点Id
                "createTime": "2018-02-19 10:02:33",
                "depositAddress": null,                    //打币地址
                "userId": "7sefsudf3fr1"                   //用户Id
            },
            {
                "currencyTypeId": 81,                       
                "amount": "0",                           
                "freeze": "122.000000000000000000",      
                "modifyTime": "2018-02-19 10:02:33",
                "webId":"102",                           
                "createTime": "2018-02-19 10:02:33",
                "depositAddress": null,                    
                "userId": "7sefsudf3fr1"                   
            }
        ],
        "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)

返回报文

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

The signature string sign=md5 (piid + timestamp + parameter content spell string + signature secret key), the signature secret key is the Api secret key, and the Apiid can be obtained when opens the Api function in the website. There are three kinds of rules for the parameter spell string content. Only the empty string " "of the header parameter, the json string format of the body json format of the body parameter, key-value, and the contents of the parameters in the form of get are sorted alphabetically by the first letter of the key value of all the parameters, followed by a string in the form of key1 + value1 + key2 + value2…. After signing, put Apiid, Timestamp, and Sign into the request header, noting that the first letter is uppercase, followed by all lowercase letters.
For example, when the website turns on the API feature, it gets the following two parameters Apiid=7eESLc0x69I7eESLc0x69J,Apisecret = 87ceba599b6d39a39deb01cf71eacd57,Timestamp=1533179478000,
a、Body json format parameter

参数内容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 ger the parameter

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

6市场行情类接口

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

6.1 所有市场24H市场行情

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

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

返回报文分两种格式
isUseMarketName为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市场行情

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

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

返回报文格式

{
    "datas": [
        90, 
        "8268227.40230003",
        "8268227.40230003",
        "8207608.58629997",
        "1725211.1401",
        "0.73",
        "[[1, 8219706.597], [2, 8266335.7998], [3, 8268227.4023]]", 
        "7418805.4126",
        "7418805.4237",
        "21469873.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                      //数据量,最多为20

返回报文格式

{
    "datas": [
        [
            "K", 
            "90", 
            "btc_krw", 
            "1532181600", 
            "8266335.737", 
            "8279949.6898", 
            "8266003.6894", 
            "8269418.0781", 
            "492264.06", 
            "0.04", 
            "1", 
            "1H", 
            "false"
        ], 
        ..........
    ], 
    "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", 
            "90", 
            "1532183063", 
            "BTC_KRW", 
            "bid", 
            "8271173.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": [
            [
                "8247657.898", 
                "5.95"
            ], 
            [
                "7418805.435", 
                "4.88"
            ], 
            [
                "7418805.47", 
                "0.01"
            ]
        ], 
        "bids": [
            [
                "0.81945643", 
                "24.32"
            ], 
            [
                "0.847", 
                "2.064"
            ],  
            [
                "0.516", 
                "17.043"
            ]
        ], 
        "timestamp": "1532183394"
    }, 
    "resMsg": {
        "code": "1", 
        "method": null, 
        "message": "success !"
    }
}

数据说明

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

7 完整Demo

JavaPython
                        
# ! /usr/bin/env python
# -*- coding:utf-8 -*-
from ws4py.client.threadedclient import WebSocketClient
import time
import hashlib
import requests
import json
"""
简单刷单demo
订阅行情,在买1卖1平均价自买自卖(未处理不成交的情况)
更多复杂功能轻自行修改实现
"""


class Bw:
def __init__(self, key, secret):
    self.base_url = 'https://www.bw.com'  # 交易地址
    self.key = key
    self.secret = secret

def public_request(self, method, api_url, **payload):
    """request public url"""
    r_url = 'https://www.bw.com/' + api_url
    try:
        r = requests.request(method, r_url, params=payload)
        r.raise_for_status()
        if r.status_code == 200:
            return True, r.json()
        else:
            return False, {'error': 'E10000', 'data': r.status_code}
    except requests.exceptions.HTTPError as err:
        return False, {'error': 'E10001', 'data': r.text}
    except Exception as err:
        return False, {'error': 'E10002', 'data': err}

def get_trades(self, symbol):
    """get detail trade"""
    return self.public_request('GET', 'market/trades/{symbol}'.format(symbol=symbol))

def signed_request(self, method, api_url, **payload):
    """request a signed url"""
    timestamp = str(int(time.time() * 1000))
    full_url = self.base_url + api_url

    param = ''
    if method == 'GET' and payload:
        param = json.dumps(''.join([key + '=' + str(payload[key]) for key in sorted(payload.keys())]))
    elif method == 'POST' and payload:
        # param = json.dumps({key: payload[key] for key in sorted(payload.keys())})
        param = json.dumps(payload)
    elif not payload:
        payload = ''

    sig_str = self.key + timestamp + param + self.secret
    signature = hashlib.md5(sig_str.encode('utf-8')).hexdigest()

    headers = {
        'Apiid': self.key,
        'Timestamp': timestamp,
        'Sign': signature
    }
    # print(self.key, timestamp, param, self.secret)
    # print(sig_str)
    # print(headers)

    try:
        r = requests.request(method, full_url, headers=headers, json=payload)
        r.raise_for_status()
        if r.status_code == 200:
            return True, r.json()
        else:
            return False, {'error': 'E10000', 'data': r.status_code}
    except requests.exceptions.HTTPError as err:
        return False, {'error': 'E10001', 'data': r.text}
    except Exception as err:
        return False, {'error': 'E10002', 'data': err}

def get_balance(self):
    a = {"pageSize": "30", "pageNum": "1"}
    return self.signed_request('POST', '/exchange/fund/controller/website/fundcontroller/findbypage', **a)

def get_info(self):
    return self.signed_request('POST', '/exchange/user/controller/website/usercontroller/getuserinfo')

def get_PayinAddress(self, name="btc"):
    a = {"currencyTypeName": name}
    return self.signed_request('POST', '/exchange/fund/controller/website/fundwebsitecontroller/getwithdrawaddress', **a)

def get_market(self):
    return self.signed_request('POST', '/exchange/config/controller/website/marketcontroller/getByWebId')

def create_order(self, **payload):
    """create order"""
    return self.signed_request('POST', '/exchange/entrust/controller/website/EntrustController/addEntrust', **payload)

def buy(self, marketId, price, amount):
    """buy someting"""
    return self.create_order(marketId=marketId, type=1, rangeType=0, price=price, amount=amount)

def sell(self, marketId, price, amount):
    """sell someting"""
    return self.create_order(marketId=marketId, type=0, rangeType=0, price=price, amount=amount)

def cancel_order(self, entrustId, marketId):
    payload = {'entrustId': entrustId, 'marketId': marketId}
    return self.signed_request('POST', '/exchange/entrust/controller/website/EntrustController/cancelEntrust', **payload)

def get_unfinish_order(self, marketId):
    return self.signed_request('GET', '/exchange/entrust/controller/website/EntrustController/getUserEntrustRecordFromCache', marketId = marketId)


class DummyClient(WebSocketClient):
def __init__(self, url):
    super(DummyClient, self).__init__(url)
    self.b = Bw(key='xxxxxx', secret='xxx')  # 填写自己的key和secret
    self.symbol = 'eth_usdt'  # 必须同时持有这两个币种,刷其他币对请修改symbol
    self.vol = 0.001  # 单次刷单量,最好先用小量试一下

    market = self.b.get_market()  # 获取基本市场信息
    if market[0]:
        for cur in market[1]['datas']:
            if cur['name'] == self.symbol:
                self.marketId = cur['marketId']  # 市场id
                self.price_decimal = cur['priceDecimal']  # 报价精度
                self.amount_decimal = cur['amountDecimal']  # 委托精度
                self.buy_id = int(cur['buyerCurrencyId'])  # 买方币种id
                self.sell_id = int(cur['sellerCurrencyId'])  # 买方币种id
                self.min_amount = float(cur['minAmount'])  # 最小委托量

    self.price_tick = 10 ** (-self.price_decimal)  # 最小价格变动单位
    self.data = {'asks': [], 'bids': []}

def opened(self):  # 订阅行情
    self.send('{"dataType": "' + self.marketId + '_ENTRUST_ADD_' + self.symbol.upper() + '","dataSize":1000,"action":"ADD"}')

def closed(self, code, reason=None):
    print("Closed down", code, reason)

def received_message(self, m):  # 接收行情
    data = eval(str(m))
    if data[0] != 'E' and data[0][0] == 'AE':
        self.data['asks'] = data[0][4]['asks']
        self.data['bids'] = data[0][5]['bids']
        self.data['ts'] = data[0][3]
    elif data[0] == 'E':
        self.data['ts'] = data[2]
        self.update_data(data)

    self.update_trade()  # 来一个行情刷一次

def update_data(self, data):  # 将行情格式规范好
    side = data[4].lower() + 's'
    for i in range(len(self.data[side])):
        if self.data[side][i][0] == data[5]:
            if data[6] != '0':
                self.data[side][i][1] = data[6]
            else:
                self.data[side].pop(i)
            return
        elif float(data[5]) > float(self.data[side][i][0]) and data[6] != '0':
            self.data[side].insert(i, [data[5], data[6]])
            return

    if data[6] != '0':
        self.data[side].append([data[5], data[6]])

def update_trade(self):  # 刷单逻辑部分
    ask1 = float(self.data['asks'][-1][0])
    bid1 = float(self.data['bids'][0][0])
    print('time:{}\task1:{}\tbid1:{}'.format(self.data['ts'], ask1, bid1))
    if ask1 - bid1 < self.price_tick * 1.5:  # 买1卖1至少相差两个档位才能刷单,不然会和别人成交
        print('价差太小,无法刷单!')
        return

    price = round((ask1 + bid1) / 2, self.price_decimal)  # 在买1卖2平均价位刷单
    buy_order = self.b.buy(self.marketId, price, self.vol)
    sell_order = self.b.sell(self.marketId, price, self.vol)
    print('{}\t{}\t{}\t{:.2f}\t{:.4f}'.format(self.data['ts'], self.marketId, self.symbol, price, self.vol))

    if buy_order[0] and 'datas' in buy_order[1] and buy_order[1]['datas']:
        a = self.b.cancel_order(buy_order[1]['datas']['entrustId'], self.marketId)
    if sell_order[0] and 'datas' in sell_order[1] and sell_order[1]['datas']:
        a = self.b.cancel_order(sell_order[1]['datas']['entrustId'], self.marketId)


if __name__ == '__main__':
ws = DummyClient('wss://kline.bw.com/websocket')  # websocket行情订阅地址
if hasattr(ws, 'marketId'):
    ws.connect()
    ws.run_forever()
else:
    print('信息获取失败!')  # 如果获取不到市场信息,检查网络是否有问题,是否要翻墙                        
                        
                    
                        
package io.test;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;

import org.apache.http.HttpException;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.util.EntityUtils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

/*
    * note:该代码适配官网https服务器接口
    * jar包版本:httpclient-4.5.3.jar 、httpcore-4.4.6.jar
    * 错误码请参考官网
    * */
public class BwApiDemos {
        private static final String BW域名 = "https://www.bw.com";
        private static final String 获取市场列表URL = "/exchange/config/controller/website/marketcontroller/getByWebId";
        private static final String 获取币种列表URL = "/exchange/config/controller/website/currencycontroller/getCurrencyList";
        private static final String 获取用户信息URL ="/exchange/user/controller/website/usercontroller/getuserinfo";//		
        private static final String 新增委托URL = "/exchange/entrust/controller/website/entrustController/addEntrust";
        private static final String 取消委托URL = "/exchange/entrust/controller/website/EntrustController/cancelEntrust";
        private static final String 查询正在进行的委托URL = "/exchange/entrust/controller/website/entrustController/getUserEntrustRecordFromCache";
        private static final String 分页查询历史委托记录URL="/exchange/entrust/controller/website/EntrustController/getUserEntrustList";
        private static final String 根据委托单id查询委托记录="/exchange/entrust/controller/website/EntrustController/getEntrustById";		
        private static final String 获取充币地址URL="/exchange/fund/controller/website/fundcontroller/getPayinAddress";
        private static final String 查询充币记录URL="/exchange/fund/controller/website/fundcontroller/getPayinCoinRecord";
        private static final String 查询提币记录URL="/exchange/fund/controller/website/fundwebsitecontroller/getPayoutCoinRecord";
        private static final String 获取用户所有资金信息URL="/exchange/fund/controller/website/fundcontroller/findbypage";
        private static final String 查询提币地址URL="/exchange/fund/controller/website/fundwebsitecontroller/getwithdrawaddress";	
    private static final String 批量取消委托URL = "/exchange/entrust/controller/website/EntrustController/batchCancelEntrustByMarketId";
        private static String API访问密钥 = "7fMCs1GQe7fMCsw1GQeP";//"7fMBgZfWzOC7fMBgZfWzOD";//[0-9a-zA-Z]//7fHskt6xdPk7fHskt6xdPl//我的7f6K9CGG4qO7f6K9CGG4qP
        private static String API私有密钥 ="f43e8280d994724db633241d3c1502";//"eed02fcdc4ecb7711b19ed0a29cb0550";//HexString//499b0780fa25007af59e9e9417e38912 //我的c7dc6c2e766bcd2a9499885c94f3e928
        public static Map 市场交易对缓存 = new HashMap<>();
        private static SSLConnectionSocketFactory sslsf = null; 
        private static PoolingHttpClientConnectionManager cm = null; 
        private static SSLContextBuilder builder = null; 
        //SSL证书校验相关
        static { 
            try { 
                builder = new SSLContextBuilder(); 
                builder.loadTrustMaterial(null, new TrustStrategy() { 
                @Override 
                    public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { 
                    return true; 
                } 
                }); 
                sslsf = new SSLConnectionSocketFactory(builder.build(), new String[]{"SSLv2Hello", "SSLv3", "TLSv1", "TLSv1.2"}, null, NoopHostnameVerifier.INSTANCE); 
                Registry registry = RegistryBuilder. create().register("http", new PlainConnectionSocketFactory()) .register("https", sslsf) .build(); 
                cm = new PoolingHttpClientConnectionManager(registry); 
                cm.setMaxTotal(200);//max connection 
            } catch (Exception e) { 
                e.printStackTrace(); 
                } 
        } 
        //对HttpClient包装以支持的https
        public static CloseableHttpClient getHttpClient() throws Exception { 
            CloseableHttpClient httpClient = HttpClients.custom() 
            .setSSLSocketFactory(sslsf) 
            .setConnectionManager(cm) 
            .setConnectionManagerShared(true) 
            .build(); 
            return httpClient; 
            } 
        
        
        public static void 初始化密钥(String Apiid,String Apisecret){
            BwApiDemos.API访问密钥 = Apiid;
            BwApiDemos.API私有密钥 = Apisecret;
        }

        public static void main(String[] args) throws Exception {
                //-------基础功能API-----
                市场交易对缓存 = 获取市场列表();
                获取币种列表();
                获取用户信息();	
                //------交易API------
                String 委托成功订单号 = 新增委托("290",0,0.5,60);//交易对、交易方向(0卖出 1买入)、数量、价格
                String 委托成功订单号2= 新增委托("290",1,0.5,50);
                    取消委托("290","E6433935901914578944");//JSON请求参考此
                查询正在进行的委托("290");//key1:value1请求参考此
                分页查询历史委托记录("302",1,20);
                根据委托单id查询委托记录("302","E6435033358698295296");
        批量取消委托("302");
                //------财务资金API-----
                获取充币地址("btc");
                查询充币记录("eth",1,1,20);
                查询提币记录(1,"all",1,10);
                获取用户所有资金信息(30,1);
                查询提币地址(5,1,10);
                    
        }

        
            /*根据返回的List获取需要的信息*/
            public static Map 获取市场列表() throws Exception{
            System.out.println("获取市场列表开始.....");
            CloseableHttpClient client=getHttpClient();
            HttpPost httpPost=new HttpPost(BW域名+获取市场列表URL);
            Md5签名(httpPost, null,false);		    
            HttpResponse rsp=client.execute(httpPost);
            int status = rsp.getStatusLine().getStatusCode();		    
            if(status==200){
                String 响应报文 = EntityUtils.toString(rsp.getEntity());
                JSONArray json  = (JSONArray) 通用解析响应(响应报文);
                if(json.size()>0){
                    System.out.println("获取市场列表成功.....");
                    List mapListJson = (List)json;
                    Map marketsMapping = new HashMap();
                    //可以根据需要返回对应的交易对
                    if(mapListJson.size()>0){
                        marketsMapping = mapListJson.get(0);
                    }
                    //此处只返回一个交易对以作示例
                    return marketsMapping;
                }else return null;
            }else throw new HttpException("返回码异常:"+status);
        }

        /*根据返回的List获取需要的信息 */
        public static List 获取币种列表() throws Exception{
                System.out.println("获取币种列表开始.....");
                    CloseableHttpClient client=getHttpClient();
                HttpPost httpPost=new HttpPost(BW域名+获取币种列表URL);
                Md5签名(httpPost, null,false);		    
                HttpResponse rsp=client.execute(httpPost);
                int status = rsp.getStatusLine().getStatusCode();		
                if(status==200){
                    String 响应报文 = EntityUtils.toString(rsp.getEntity());
                        JSONArray json  = (JSONArray) 通用解析响应(响应报文);
                    if(json.size()>0){
                        System.out.println("获取币种列表成功.....");
                        //资金列表
                        List mapListJson = (List)json;
                        System.out.println("获取币种列表结果------->"+JSONArray.toJSONString(mapListJson));
                        return mapListJson;
                    }else return null;
                }else throw new HttpException("返回码异常:"+status);
        }
        
        /*获取用户信息接口*/
        public static String 获取用户信息() throws Exception{
                System.out.println("获取用户信息开始.....");
                    CloseableHttpClient client=getHttpClient();
                HttpPost httpPost=new HttpPost(BW域名+获取用户信息URL);
                Md5签名(httpPost, null,false);		    
                HttpResponse rsp=client.execute(httpPost);
                int status = rsp.getStatusLine().getStatusCode();		
                if(status==200){
                    String 响应报文 = EntityUtils.toString(rsp.getEntity());
                    JSONObject json  = (JSONObject) 通用解析响应(响应报文);
                        System.out.println("商户名字="+json.getString("merchantName"));
                        System.out.println("email="+json.getString("email"));
                        System.out.println("用户昵称="+json.getString("nickName"));
                        System.out.println("用户实名="+json.getString("realName")); 			       
                    return json.toJSONString();			        
                }else throw new HttpException("返回码异常:"+status);
        }
        public static String 新增委托(final String marketId,final Integer type,final double amount,final double price) throws Exception{
            if(市场交易对缓存.get(marketId)!=null){
                    System.out.println("新增委托: "+(type==0?"卖出":"买入")+" ["+市场交易对缓存.get(marketId).toString()+"] "
                            +amount+"个,单价:["+price+"]");
            }else{
                System.out.println("新增委托: "+(type==0?"卖出":"买入")+" ["+marketId+"] "+amount+"个,单价:["+price+"]");
            }
            CloseableHttpClient client=getHttpClient();
            HttpPost httpPost=new HttpPost(BW域名+新增委托URL);
            Map parameters = new HashMap(){{ 
                put("amount", amount);
                put("type", type);
                put("rangeType", 0);
                put("marketId", marketId);
                put("price", price);
            }};	
            StringEntity httpParams=new StringEntity(JSON.toJSONString(parameters));
            //设置请求体
            httpPost.setEntity(httpParams);
            //设置签名、请求头
            Md5签名(httpPost, parameters,true);
            HttpResponse httpResponse = client.execute(httpPost);	    
            int status=httpResponse.getStatusLine().getStatusCode();
            if(status==200){
                String 响应报文 = EntityUtils.toString(httpResponse.getEntity());
                JSONObject json  = (JSONObject) 通用解析响应(响应报文);
                String entrustId = (String) json.get("entrustId");
                System.out.println("委托新增成功,委托订单号为:======>>["+entrustId+"]");
                return entrustId;
            }else throw new HttpException("返回码异常:"+status);
        }
                
        public static String 取消委托(final String marketId,final String entrustId) throws Exception{
                System.out.println("取消委托:["+entrustId+"]");
                CloseableHttpClient client=getHttpClient();
                HttpPost httpPost=new HttpPost(BW域名+取消委托URL);
                Map parameters = new HashMap(){{
                    put("marketId", marketId);
                    put("entrustId", entrustId);
                }};
                StringEntity httpParams=new StringEntity(JSON.toJSONString(parameters));
                //设置请求体
                httpPost.setEntity(httpParams);
                //设置签名、请求头
                Md5签名(httpPost, parameters,true);		    
                HttpResponse rsp=client.execute(httpPost);
                int status = rsp.getStatusLine().getStatusCode();	
                if(status==200){
                    String 响应报文 = EntityUtils.toString(rsp.getEntity());
                    JSONObject json  = (JSONObject) 通用解析响应(响应报文);
                    System.out.println("委托取消成功");
                    return entrustId;
                }else throw new HttpException("返回码异常:"+status);
        }

        public static JSONArray 查询正在进行的委托(final String marketId) throws Exception{
            System.out.println("查询["+marketId+"]的所有挂单");
            CloseableHttpClient client=getHttpClient();
            HttpPost httpPost=new HttpPost(BW域名+查询正在进行的委托URL);
            Map parameters = new HashMap(){{
                put("marketId", marketId);	
            }};	 	   
            httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded");
            //注意:对于key-value的请求数据格式,HttpPost中Entity和Param均需传入相应的属性
                httpPost.setEntity(new StringEntity("marketId="+marketId));
            httpPost.getParams().setParameter("marketId", marketId);
            //设置签名、请求头
            Md5签名(httpPost, parameters,false);
                HttpResponse rsp=client.execute(httpPost);
            int status = rsp.getStatusLine().getStatusCode();	
            if(status==200){
                String 响应报文 = EntityUtils.toString(rsp.getEntity());
                JSONArray json  = (JSONArray) 通用解析响应(响应报文);
                if(json==null||json.size()==0){
                    System.out.println("没有正在进行的委托");
                    return null;
                }
                System.out.println("委托查询成功---->"+json);//请调用方自行解析json获取需要的数据 格式参考页尾
                    return json;
            }else throw new HttpException("返回码异常:"+status);
        }
        
        /*分页查询历史委托记录*/
        public static String 分页查询历史委托记录(final String marketId,int pageIndex,int pageSize) throws Exception{
                    System.out.println("marketId="+marketId+",pageIndex="+pageIndex+",pageSiz="+pageSize);
                    CloseableHttpClient client=getHttpClient();
                    //get请求方式:参数拼接在URL后面
                HttpGet httpGet=new HttpGet(BW域名+分页查询历史委托记录URL+"?marketId="+marketId+"&pageIndex="+String.valueOf(pageIndex)+"&pageSize="+String.valueOf(pageSize));
                Map parameters = new HashMap(){{
                        put("marketId", marketId);
                        put("pageIndex",pageIndex);
                        put("pageSize",pageSize);
                    }};	
                Md5签名(httpGet, parameters,true);
                HttpResponse httpResponse = client.execute(httpGet);	    
                int status=httpResponse.getStatusLine().getStatusCode();
                if(status==200){
                    String 响应报文 = EntityUtils.toString(httpResponse.getEntity());
                    JSONObject json  = (JSONObject) 通用解析响应(响应报文);
                    String entrustRecordsList=json.getJSONArray("entrustList").toJSONString();
                    System.out.println("历史委托记录为:======>>["+entrustRecordsList+"]");
                    return json.toJSONString();
                }else throw new HttpException("返回码异常:"+status);
        }
        
        /*根据委托单id查询委托记录*/
        public static String 根据委托单id查询委托记录(final String marketId,final String entrustId) throws Exception{
                    System.out.println("marketId="+marketId+",entrustID="+entrustId);
                    CloseableHttpClient client=getHttpClient();
                    //get请求方式:参数拼接在URL后面
                    HttpGet httpGet=new HttpGet(BW域名+根据委托单id查询委托记录+"?marketId="+marketId+"&entrustId="+entrustId);
                    Map parameters = new HashMap(){{
                            put("marketId", marketId);
                            put("entrustId",entrustId);
                    }};	
                    Md5签名(httpGet, parameters,false);
                    HttpResponse httpResponse = client.execute(httpGet);	    
                    int status=httpResponse.getStatusLine().getStatusCode();
                    if(status==200){
                        String 响应报文 = EntityUtils.toString(httpResponse.getEntity());
                        JSONObject json  = (JSONObject) 通用解析响应(响应报文);
//				        String entrustRecordsList=json.getJSONArray("entrustList").toJSONString();
                        System.out.println("委托记录为:======>>["+json+"]");
                        return json.toJSONString();
                    }else throw new HttpException("返回码异常:"+status);
        }

    public static String 批量取消委托(final String marketId) throws Exception {
            System.out.println("批量取消委托:["+marketId+"]");
            CloseableHttpClient client=getHttpClient();
            HttpPost httpPost=new HttpPost(BW域名+批量取消委托URL);
            Map parameters = new HashMap(){{
                put("marketId", marketId);	
            }};	 	   
            httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded");
            //注意:对于key-value的请求数据格式,HttpPost中Entity和Param均需传入相应的属性
                httpPost.setEntity(new StringEntity("marketId="+marketId));
            httpPost.getParams().setParameter("marketId", marketId);
            Md5签名(httpPost, parameters,false);
            HttpResponse rsp=client.execute(httpPost);
            int status = rsp.getStatusLine().getStatusCode();
            if(status==200){
                String 响应报文 =  EntityUtils.toString(rsp.getEntity());
                JSONObject respsone = JSONObject.parseObject(响应报文);
                Object resMsg = respsone.get("resMsg");
                JSONArray json = null;
                if(resMsg!=null&&resMsg instanceof JSONObject){
                    if("1".equals(((JSONObject)resMsg).get("code"))){//返回码成功
                        json = (JSONArray) respsone.get("datas");
                        if(json==null||json.size()==0){
                            System.out.println("没有正在进行的委托");
                            return null;
                        }else {
                            System.out.println("委托取消成功");
                            //返回取消的所有委托单
                            return json.toJSONString();
                        }
                    }
                }
                System.err.println("respsone----------------"+respsone);
                return respsone.toJSONString();
            }else throw new HttpException("返回码异常:"+status);
        }
        
        /*--------------------------------财务资金API-------------------------------------*/
        public static String 获取充币地址(final String currencyTypeName) throws Exception{
            System.out.println("币种="+currencyTypeName);
            CloseableHttpClient client=getHttpClient();
            HttpPost httpPost=new HttpPost(BW域名+获取充币地址URL);
            Map parameters = new HashMap(){{
                put("currencyTypeName", currencyTypeName);	
            }};
            StringEntity httpParams=new StringEntity(JSON.toJSONString(parameters));
            //设置请求体
            httpPost.setEntity(httpParams);
            //设置签名、请求头
            Md5签名(httpPost, parameters,true);
                HttpResponse rsp=client.execute(httpPost);
            int status = rsp.getStatusLine().getStatusCode();	
            if(status==200){
                String 响应报文 = EntityUtils.toString(rsp.getEntity());
                JSONObject json  = (JSONObject) 通用解析响应(响应报文);
                String chargingAddress=json.get("address").toString();
                System.out.println("充币地址为---->"+chargingAddress);//请调用方自行解析json获取需要的数据 格式参考页尾
                return chargingAddress;
            }else throw new HttpException("返回码异常:"+status);
        }
        
        /*查询充币记录*/
        public static String 查询充币记录(final String currencyTypeName,int sort,int pageNum,int pageIndex) throws Exception{
            System.out.println("currencyTypeName="+currencyTypeName+",sort="+sort+",pageNum="+pageNum+",pageIndex="+pageIndex);
            CloseableHttpClient client=getHttpClient();
            HttpPost httpPost=new HttpPost(BW域名+查询充币记录URL);
            Map parameters = new HashMap(){{
                put("currencyTypeName", currencyTypeName);	
                put("sort", sort);
                put("pageNum", pageNum);//
                put("pageIndex", pageIndex);//
            }};	 	
            StringEntity httpParams=new StringEntity(JSON.toJSONString(parameters));
            //设置请求体
            httpPost.setEntity(httpParams);
            Md5签名(httpPost, parameters,true);
                HttpResponse rsp=client.execute(httpPost);
            int status = rsp.getStatusLine().getStatusCode();	
            if(status==200){
                String 响应报文 = EntityUtils.toString(rsp.getEntity());
                JSONObject json  = (JSONObject) 通用解析响应(响应报文);
                String chargingCoinRecord=json.getJSONArray("list").toJSONString();	            
                System.out.println("充币记录---->"+chargingCoinRecord);//请调用方自行解析json获取需要的数据 格式参考页尾
                return chargingCoinRecord;
            }else throw new HttpException("返回码异常:"+status);
        }
        
        /*查询提币记录*/
        public static String 查询提币记录(int currencyId,final String tab,int pageIndex,int pageNum) throws Exception{
                    System.out.println("currencyId="+currencyId+",tab="+tab+",pageIndex="+pageIndex+",pageNum="+pageNum);
                    CloseableHttpClient client=getHttpClient();
                    //get请求方式:参数拼接在URL后面
                HttpGet httpGet=new HttpGet(BW域名+查询提币记录URL+"?currencyId="+currencyId+"&tab="+tab+"&pageIndex="+pageIndex+"&pageNum="+pageNum);
                    Map parameters = new HashMap(){{
                            put("currencyId", currencyId);
                            put("tab",tab);
                            put("pageIndex",pageIndex);
                            put("pageNum",pageNum);		    	   
                    }};	
                    Md5签名(httpGet, parameters,false);
                    HttpResponse httpResponse = client.execute(httpGet);	    
                    int status=httpResponse.getStatusLine().getStatusCode();
                    if(status==200){
                        String 响应报文 = EntityUtils.toString(httpResponse.getEntity());
                        JSONObject json  = (JSONObject) 通用解析响应(响应报文);
                        String getCoinRecordsList=json.getJSONArray("list").toJSONString();
                        System.out.println("提币记录为:======>>["+getCoinRecordsList+"]");
                        return getCoinRecordsList;
                    }else throw new HttpException("返回码异常:"+status);
        }
        
        /*获取用户所有资金信息*/
            public static String 获取用户所有资金信息(final Integer pageSize,final Integer pageNum) throws Exception{
            CloseableHttpClient client=getHttpClient();
            HttpPost httpPost=new HttpPost(BW域名+获取用户所有资金信息URL);
            Map parameters = new HashMap(){{ 
                put("pageSize", pageSize);
                put("pageNum", pageNum);
            }}; 
            StringEntity httpParams=new StringEntity(JSON.toJSONString(parameters));
            //设置请求体
            httpPost.setEntity(httpParams);
            //设置签名、请求头
            Md5签名(httpPost, parameters,true);
            HttpResponse httpResponse = client.execute(httpPost);     
            int status=httpResponse.getStatusLine().getStatusCode();
            if(status==200){
                String 响应报文 = EntityUtils.toString(httpResponse.getEntity());
                JSONObject json  = (JSONObject) 通用解析响应(响应报文);
                String 资金信息列表=json.get("list").toString();
                System.out.println("资金信息列表为:======>>["+资金信息列表+"]");
                return 资金信息列表;
            }else throw new HttpException("返回码异常:"+status);
        }
        
        /*查询提币地址*/
        public static String 查询提币地址(int currencyId,int pageIndex,int pageNum) throws Exception{
            System.out.println("currencyId="+currencyId+",pageIndex="+pageIndex+",pageNum="+pageNum);
            CloseableHttpClient client=getHttpClient();
            //get请求方式:参数拼接在URL后面
        HttpGet httpGet=new HttpGet(BW域名+查询提币地址URL+"?currencyId="+currencyId+"&pageIndex="+pageIndex+"&pageNum="+pageNum);
            Map parameters = new HashMap(){{
                    put("currencyId", currencyId);
                    put("pageIndex",pageIndex);
                    put("pageNum",pageNum);		    	   
            }};	
            Md5签名(httpGet, parameters,false);
            HttpResponse httpResponse = client.execute(httpGet);	    
            int status=httpResponse.getStatusLine().getStatusCode();
            if(status==200){
                String 响应报文 = EntityUtils.toString(httpResponse.getEntity());
                JSONObject json  = (JSONObject) 通用解析响应(响应报文);
                String getCoinRecordsList=json.getJSONArray("list").toJSONString();
                System.out.println("提币地址为:======>>["+getCoinRecordsList+"]");
                return getCoinRecordsList;
            }else throw new HttpException("返回码异常:"+status);
        }
        
        /*--------------------------------------------基础功能方法-----------------------------------------*/
        /* 解析响应报文获取data参数 */
        private static JSON 通用解析响应(String responseStr){
            JSONObject respsone = JSONObject.parseObject(responseStr);
            Object resMsg = respsone.get("resMsg");
            if(resMsg!=null&&resMsg instanceof JSONObject){
                if("1".equals(((JSONObject)resMsg).get("code"))){//返回码成功
                    return (JSON) respsone.get("datas");
                }
            }
            System.err.println("responseStr------------------------------------->"+responseStr);
            throw new RuntimeException("API调用失败:报文解析失败!");
        }


        /**
        * @param parameters  			参数MAP
        * @param isJson				是否是JSON字符串 请求格式为JSON时传true,为key1:value1时传false
        */
        protected static void Md5签名(HttpPost post,Map parameters,boolean isJson){
            
            StringBuffer sb = new StringBuffer(API访问密钥);
            String timestamp = String.valueOf(System.currentTimeMillis());
            sb.append(timestamp);
            if(parameters!=null&&!parameters.isEmpty()){
                if(isJson){
                    String params = JSON.toJSONString(parameters);
                    sb.append(params);
                }else{
                    parameters = new TreeMap<>(parameters);
                    Iterator it = parameters.entrySet().iterator();
                    while(it.hasNext()){
                        Entry entry = (Entry)it.next();
                        sb.append(entry.getKey()).append(entry.getValue());
                    }
                }
            }
            sb.append(API私有密钥);
            String sign = digest(sb.toString());
            post.addHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3");
            post.addHeader("Apiid", API访问密钥);
            post.addHeader("Timestamp", timestamp);
            post.addHeader("Sign", sign);
        }
        
        protected static void Md5签名(HttpGet get,Map parameters,boolean isJson){
            
            StringBuffer sb = new StringBuffer(API访问密钥);
            String timestamp = String.valueOf(System.currentTimeMillis());
            sb.append(timestamp);
            if(parameters!=null&&!parameters.isEmpty()){
                if(isJson){
                    String params = JSON.toJSONString(parameters);
                    sb.append(params);
                }else{
                    parameters = new TreeMap<>(parameters);
                    Iterator it = parameters.entrySet().iterator();
                    while(it.hasNext()){
                        Entry entry = (Entry)it.next();
                        sb.append(entry.getKey()).append(entry.getValue());
                    }
                }
            }
            sb.append(API私有密钥);
            String sign = digest(sb.toString());
            get.addHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3");
            get.addHeader("Apiid", API访问密钥);
            get.addHeader("Timestamp", timestamp);
            get.addHeader("Sign", sign);
        }
        

        public static String digest(String str) {
                try {
                        //实现了MD5加密算法的digest
                    MessageDigest messageDigest = MessageDigest.getInstance("MD5");
                    messageDigest.reset();
                    messageDigest.update(str.getBytes());
                    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 e) {
                    e.printStackTrace();
                    return null;
                }
            }   
}
                            

                                                           
                        
                    

8 Error code

Return to the message as below when failure

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

Error code list

Error code Description Description 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权限失败,接口不属于授权API Failed 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
会话

{{selectedConversation.conversationName}}

Send Message
{{curr.unreadCount}}

{{curr.conversationName}}

Send Message

{{item.senderInfo.nickname}}