YIBI

2020-7-9

API文档

开启API权限    

用户的API请在个人中心进行获取。其中apiKey是API用户的访问密钥,apiSecret用于对请求参数签名的私钥。 

注意: 请勿向任何人泄露这两个参数,这两个参数关乎您账号的安全。

参数签名    

用户提交的参数除sign外,都要参与签名。

签名规则:将待签名的参数名进行排序(首先比较所有参数名的第一个字母,按abcd顺序排列,若遇到相同首字母,则看第二个字母,以此类推),

按参数名称再加上apiSecret升序排序,将参数值进行连接 。

例如:对于如下的参数进行签名(取 apiSecret="IPC2018195703")

string[] parameters={"market=X/BTC","apiKey=195703","type=1","price=10000"};
参数+apiSecre后排序后
{"apiKey=195703",apiSecret="IPC2018195703","market=X/BTC","price=10000","type=1"}
生成待签名的字符串为:
195703IPC2018195703X/BTC100001 
 

最后,利用MD5算法,对最终待签名字符串进行签名运算,从而得到签名结果字符串(该字符串赋值于参数sign)。

  签名和MD5算法如下:

public static String md5(String string) {
        byte[] hash;
        try {
            hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("UTF-8 is unsupported", e);
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException("MessageDigest不支持MD5Util", e);
        }
        StringBuilder hex = new StringBuilder(hash.length * 2);
        for (byte b : hash) {
            if ((b & 0xFF) < 0x10) hex.append("0");
            hex.append(Integer.toHexString(b & 0xFF));
        }
        return hex.toString();
    }

    /**
     * md5签名
     * 按参数名称升序,将参数值进行连接 签名
     * @param appSecret
     */
    public static String sign(String appSecret, TreeMap<String, String> params) {
        StringBuilder paramValues = new StringBuilder();
        params.put("appSecret", appSecret);
        for (Map.Entry<String, String> entry : params.entrySet()) {
            paramValues.append(entry.getValue());
        }
        return md5(paramValues.toString());
    }

 

一 简要描述:

  • 获取所有可交易的交易对

请求URL:

请求方式:

  • GET

参数:

       无

返回示例

{
"code": "1",
"success": true,
"msg": null,
"data": [{
    "ticker_id": "USDT_UCNY",
    "base": "USDT",
    "target": "UCNY"
}, {
    "ticker_id": "BTC_USDT",
    "base": "BTC",
    "target": "USDT"
  }]
}

返回参数说明

参数名 类型 说明
ticker_id string 交易对名称
base string 交易币种
target string 市场币种

 

 

 

 

二 简要描述:

  • 获取所有交易对信息

请求URL:

请求方式:

  • GET

参数:

       无

返回示例

{
"code": "1",
"success": true,
"msg": null,
"data": [{
    "ticker_id": "USDT_UCNY",
    "base_currency": "USDT",
    "target_currency": "UCNY",
    "last_price": "6.2063",
    "base_volume": "11320474.523",
    "target_volume": "69938728.85344426",
    "bid": "6.1189",
    "ask": "6.3127",
    "high": "6.5554",
    "low": "6.0688"
}, {
    "ticker_id": "BTC_USDT",
    "base_currency": "BTC",
    "target_currency": "USDT",
    "last_price": "48527.91",
    "base_volume": "229.852284",
    "target_volume": "11212881.13491958",
    "bid": "48735.03",
    "ask": "45799.32",
    "high": "49047.4",
    "low": "48493.24"
    }]
}

返回参数说明

参数名 类型 说明
ticker_id string 交易对名称
base_currency string 交易币种
target_currency string 市场币种
last_price decimal 最新价格
base_volume decimal 24小时内交易币成交数量
target_volume decimal 24小时内成交额
bid decimal 买一价格
ask decimal 卖一价格
high decimal 24小时内最高成交价格
low decimal 24小时内最低成交价格

 

 

 

 

三 简要描述:

  • 获取深度

请求URL:

请求方式:

  • GET

参数:

     
参数名 必选 类型 说明
ticker_id String 市场名称 币种名称后面需要加"_"和板块名称(BTC_USDT)

 

 

返回示例

{
"code": "1",
"success": true,
"msg": null,
"data": {
    "ticker_id": "BTC_USDT",
    "timestamp": "1639473000000",
    "bids": [
        ["48735.05", "0.200128"],
        ["48735.04", "0.1005"]
  ],
    "asks": [
        ["48735.06", "0.203296"],
        ["48735.07", "0.108152"]
     ]
  }
}

返回参数说明

参数名 类型 说明
ticker_id string 交易对名称
timestamp timestamp 获取数据时间
bids decimal 包含 2 个元素的数组。 每个订单的报价和数量
asks decimal 包含 2 个元素的数组。 每个订单的报价和数量

 

 

 

 

 

 

四 简要描述:

  • 获取成交记录

请求URL:

请求方式:

  • GET

参数:

     
参数名 必选 类型 说明
ticker_id String 市场名称 币种名称后面需要加"_"和板块名称(BTC_USDT)

 

 

返回示例

{
"code": "1",
"success": true,
"msg": null,
"data": {
    "buy": [{
        "trade_id": 187317363,
        "price": 293392.99,
        "base_volume": 0.000146,
        "target_volume": 42.83537654,
        "trade_timestamp": 1639470864000,
        "type": "buy"
}],
    "sell": [{
        "trade_id": 187314280,
        "price": 297323.2,
        "base_volume": 0.45152,
        "target_volume": 134247.37126400,
        "trade_timestamp": 1639470624000,
        "type": "sell"
    }]
  }
}

返回参数说明

参数名 类型 说明
trade_id int 成交记录id
price decimal 交易价格
base_volume decimal 成交数量
target_volume decimal 成交额
trade_timestamp long 成交时间,时间戳
type string buy 是买入,sell是卖出

 

 

 

 

 

 

五 简要描述:

  • 获取所有市场行情

请求URL:

请求方式:

  • POST

参数:

       无

返回示例

{
  "code": "1",
  "success": true,
  "msg": null,
  "data": {
    "X/BTC": {
    "id": 4,
    "low": 1e-8,
    "high": 0.00019921,
    "last": 0.0000154,
    "sell": 0.0000154,
    "buy": 0.000015,
    "volume": 3391.6974,
    "turnover": 0.0180623959,
    "changeRate": 76900
    },
    "ETH/BTC": {
    "id": 1,
    "low": 0.0587,
    "high": 0.058713,
    "last": 0.058713,
    "sell": 0.058713,
    "buy": 0.0587,
    "volume": 3.0002,
    "turnover": 0.17614254,
    "changeRate": 0.0221465076660988074957
    },
    "X/ETH": {
    "id": 2,
    "low": 0.000188,
    "high": 0.00023399,
    "last": 0.00018915,
    "sell": 0.00018915,
    "buy": 0.000188,
    "volume": 454,
    "turnover": 0.09322828,
    "changeRate": -5.0547133821905431181608
    }
  }
}

返回参数说明

参数名 类型 说明
id int 市场id
low decimal 市场最低价
high decimal 市场最高价
last decimal 市场最新价
sell decimal 卖一价
buy decimal 买一价
volume decimal 销售量
turnover decimal 销售额
changeRate decimal 涨跌幅

 

 


 

 

 

 

 

 

六 简要描述:

  • 获取单个市场行情

请求URL:

请求方式:

  • POST

参数:

   
参数名 必选 类型 说明
market String 市场名称 币种名称后面需要加"/"和板块名称(btc/usd)

 

 

 

返回示例

{
  "code": "1",
  "success": true,
  "msg": null,
  "data": {
    "X/BTC": {
    "id": 4,
    "low": 1e-8,
    "high": 0.00019921,
    "last": 0.0000154,
    "sell": 0.0000154,
    "buy": 0.000015,
    "volume": 3391.6974,
    "turnover": 0.0180623959,
    "changeRate": 76900
    }
  }
}

 

返回参数说明

参数名 类型 说明
id int 市场id
low decimal 市场最低价
high decimal 市场最高价
last decimal 市场最新价
sell decimal 卖一价
buy decimal 买一价
volume decimal 销售量
turnover decimal 销售额
changeRate decimal 涨跌幅
 

 

 

七 简要描述:

  • 获取用户单个市场交易记录

请求URL:

请求方式:

  • POST

参数:

   
参数名 必选 类型 说明
apiKey String 用户申请的密钥
sign String 参数签名
market String 币种名称 币种名称后面需要加"/"和板块名称(btc/usd)

 

 

 

 

 

返回示例

{
  "code": "1",
  "success": true,
  "msg": null,
  "data": {
    "id": 1336,
    "amount": 1.8812,
    "qty": 10000,
    "price": 0.00018812,
    "type": "sell",
    "createTime": "2018-07-27 11:42:17",
    "createTimeMs": 1532662937000
    },

  {
    "id": 1335,
    "amount": 1.8812,
    "qty": 10000,
    "price": 0.00018812,
    "type": "buy",
    "createTime": "2018-07-27 11:42:17",
    "createTimeMs": 1532662937000
  }
}

返回参数说明

参数名 类型 说明
id int 市场id
amount decimal 销售额
qty decimal 销售数量
price decimal 市场价
type String l类型 1buy 2sell
createTime String 创建时间
createTimeMs long 创建时间毫秒值
 

 

 


 

 

 

八 简要描述:

  • 获取单个市场交易记录

请求URL:

请求方式:

  • POST

参数:

   
参数名 必选 类型 说明
market String 币种名称 币种名称后面需要加"/"和板块名称(btc/usd)

 

 

 

返回示例

{

  "code": "1",
  "success": true,
  "msg": null,
  "data": {
    "id": 1336,
    "amount": 1.8812,
    "qty": 10000,
    "price": 0.00018812,
    "type": "sell",
    "createTime": "2018-07-27 11:42:17",
    "createTimeMs": 1532662937000
    },
  {
    "id": 1335,
    "amount": 1.8812,
    "qty": 10000,
    "price": 0.00018812,
    "type": "buy",
    "createTime": "2018-07-27 11:42:17",
    "createTimeMs": 1532662937000
  }
}

返回参数说明

参数名 类型 说明
id int 市场id
amount decimal 销售额
qty decimal 销售数量
price decimal 市场价
type String l类型 1buy 2sell
createTime String 创建时间
createTimeMs long 创建时间毫秒值
 

 

 


 

 

 

九 简要描述:

  • 获取币币市场深度

请求URL:

请求方式:

  • POST

参数:

   
参数名 必选 类型 说明
market String 币种名称 币种名称后面需要加"/"和板块名称(btc/usd)

 

 

 

返回示例

{
  "code": "1",
  "success": true,
  "msg": null,
  "data": {
    "buyList": [
    {
      "amount": 0.000015,
      "price": 0.000015,
      "qty": 1
    },
    {
      "amount": 6.5824e-8,
      "price": 0.00001496,
      "qty": 0.0044
    },
    {
      "amount": 0.0002986,
      "price": 0.00001493,
      "qty": 20
    },
    {
      "amount": 0.012325414984,
      "price": 0.00001492,
      "qty": 826.1002
    }],
    "sellList": [
    {
      "amount": 1.54e-9,
      "price": 0.0000154,
      "qty": 0.0001
    }]
  }
}

返回参数说明

参数名 类型 说明
amount decimal 销售额
qty decimal 销售数量
price decimal 市场价
 

 

 


十 简要描述:

  • 获取用户所有余额

请求URL:

请求方式:

  • POST

参数:

   
参数名 必选 类型 说明
apiKey String 用户申请的密钥
sign String 参数签名

 

 

 

 

返回示例

{
  "code": "1",
  "success": true,
  "msg": null,
  "data": {
    "exchangePrice": {
      "usdtPrice": 180.710456121,
      "cnyPrice": 1204.446278568,
      "btcPrice": 0.0224152268028,
      "ethPrice": 0.3817047
    },
  "banlance": [
    {
      "id": 3,
      "userId": 195703,
      "banlance": 2018,
      "freezingBanlance": 0,
      "totalBanlance": 2018,
      "shortName": "X",
      "fullName": "X",
      "image": "http://uniex.oss-cn-hongkong.aliyuncs.com/test/coin/2018/07/18/b369665c07014c06a720d1f9ddf0cecd.png",
      "btcPrice": null,
      "cnyPrice": 1204.446278568,
      "usdtPrice": 180.710456121,
      "withdrawFee": 0.02,
      "allowRecharge": 1,
      "allowWithdraw": 1,
      "type": 3,
      "minOutQty": 2,
      "maxOutQty": 100000,
      "useredWithdrawal": null,
      "withdrawalAmount": null,
      "tradeList": null
    },
    {
      "id": 1,
      "userId": 195703,
      "banlance": 0,
      "freezingBanlance": 0,
      "totalBanlance": 0,
      "shortName": "ETH",
      "fullName": "ethereum",
      "image": "http://uniex.oss-cn-hongkong.aliyuncs.com/test/2018/07/12/9bdaa67c911d41a0b95155929ace74dc.png",
      "btcPrice": null,
      "cnyPrice": 0,
      "usdtPrice": 0,
      "withdrawFee": 0.01,
      "allowRecharge": 1,
      "allowWithdraw": 1,
      "type": 1,
      "minOutQty": 0.05,
      "maxOutQty": 10,
      "useredWithdrawal": null,
      "withdrawalAmount": null,
      "tradeList": null
    }]
  }
}

返回参数说明

参数名 类型 说明
banlance decimal 可用金额
freezingBanlance decimal 冻结金额
totalBanlance decimal 总金额
 

 

 


十一 简要描述:

  • 获取用户订单

请求URL:

请求方式:

  • POST

参数:

   
参数名 必选 类型 说明
apiKey String 用户申请的密钥
sign String 参数签名
status int 状态 -1已撤单 0已下单 1待撮合 2撮合中 3已完成撮合
market String 币种名称 币种名称后面需要加"/"和板块名称(btc/usd)

 

 

 

 

 

 

 

返回示例

{
  "code": "1",
  "success": true,
  "msg": null,
  "data": [
    {
      "createTime": 1534301588000,
      "price": 0.045662,
      "qty": 0.253,
      "id": 1440592,
      "type": 1,
      "trade_qty": 0,
      "status": 1
  },
  {
      "createTime": 1534301587000,
      "price": 0.045682,
      "qty": 0.9046,
      "id": 1440590,
      "type": 1,
      "trade_qty": 0,
      "status": 1
    }]
}

返回参数说明

参数名 类型 说明
id int 订单id
type int 订单类型  1buy 2sell
price decimal 销售价格
qty decimal 总数量
trade_qty decimal 已交易数量
status int 状态-1已撤单 0已下单 1待撮合 2撮合中 3已完成
 

 

 


 

 

 

十二 简要描述:

  • 下单

请求URL:

请求方式:

  • POST

参数:

   
参数名 必选 类型 说明
apiKey String 用户申请的密钥
sign String 参数签名
type int 类型 1买入 2卖出
qty decimal 数量
price decimal 价格
market String 币种名称 币种名称后面需要加"/"和板块名称(btc/usd)

 

 

 

 

 

 

 

返回示例

{
  "code": "1",
  "success": true,
  "msg": "下单成功!",
  "data": null
}

返回参数说明

      无

 


十三 简要描述:

  • 撤单

请求URL:

请求方式:

  • POST

参数:

   
参数名 必选 类型 说明
apiKey String 用户申请的密钥
sign String 参数签名
userId String 用户id  与密钥一致
id String 订单id

 

 

 

 

 

返回示例

{
  "code": "1",
  "success": true,
  "msg": "撤单成功!",
  "data": null
}

返回参数说明