接口說明
CEO為用戶提供了兩種調用接口的方式,分別為:Rest和WebSocket,開發者可根據自身需求來選擇適合自己的方式查詢市場深度信息、交易和查詢相關的交易記錄
REST,即Representational State Transfer的縮寫,是目前最流行的一種互聯網軟件架構。它利用了Web的現有特征和能力, 能更好地使用現有Web標准中的一些准則和約束。
WebSocket 是 HTML5 開始提供的一種在單個 TCP 連接上進行全雙工通訊的協議。WebSocket 使得客戶端和服務器之間的數據交換變得更加簡單,允許服務端主動向客戶端推送數據。在 WebSocket API 中,瀏覽器和服務器只需要完成一次握手,兩者之間就直接可以創建持久性的連接,並進行雙向數據傳輸。
- REST:https://api.ceobi.com/
- WebSocket:wss://api.ceobi.com/websocket
接口詳細
獲取全幣種行情
Request
Method: GET
URL: api/market/allTicker
Response
{
"code": 1000,
"message": "成功",
"data": {
"ceo_qc": { //市場名
"buy": "91.00000000", //買一價
"sell": "91.50000000", //賣一價
"last": "90.00000000", //最新成交價
"vol": "0.00000000", //成交量(最近的24小時)
"high": "0.00000000", //最高價
"low": "0.00000000", //最低價
"change": "0.10" //漲跌幅
},
"eth_ceo": {
"buy": "52.18000000",
"sell": "53.30000000",
"last": "53.30000000",
"vol": "5.00000000",
"high": "53.30000000",
"low": "53.00000000",
"change": "0.10"
},
......
}
java
行情
Request
Method: GET
URL: api/market/ticker
Parameters:
參數 類型 必填 描述 market string Y 市場名稱 api/market/ticker?market=ceo_qc
Response
{
"code": 1000,
"message": "成功",
"data": {
"buy": "91.00000000", //買一價
"sell": "91.50000000", //賣一價
"last": "90.00000000", //最新成交價
"vol": "0.00000000", //成交量(最近的24小時)
"high": "0.00000000", //最高價
"low": "0.00000000", //最低價
"change": "0.10", //漲跌幅
"time": 1535012914 //時間
}
}
java
委托記錄
Request
Method: GET
URL: api/market/entrust
Parameters:
參數 類型 必填 描述 market string Y 市場名稱 api/market/entrust?market=ceo_qc
Response
{
"code": 1000,
"message": "成功",
"data": {
"b": [ //買
[
"11.37", //價格
"877.627331" //數量
],
[
"11.01",
"1018.843536"
],
],
"s": [ //賣
[
"70.00", //
"1000.000000"
],
[
"60.00",
"1000.000000"
]
]
}
歷史成交
Request
Method: GET
URL: api/market/trades
Parameters:
參數 類型 必填 描述 market string Y 市場名稱 api/market/trades?market=bit_qc
Response
{
"code": 1000,
"message": "成功",
"data": [
{
"amount": "5000.000000", //交易數量
"price": "0.400000", //交易價格
"type": 2, //交易類型,1(買)/2(賣)
"time": 1530144000 //交易時間(時間戳)
},
{
"amount": "5000.000000",
"price": "0.400000",
"type": 1,
"time": 1530144000
},
......
]
}
K線
Request
Method: GET
URL: api/market/kline
Parameters:
參數 類型 必填 描述 market string Y 市場名稱 type string Y 時間 size int Y 返回數據的條數限制(默認為1000,大於1000,只返回1000) type 值為: 1min 3min 5min 15min 30min 1day 3day 1week 1hour 2hour 4hour 6hour 12hour
api/market/kline?market=bit_qc&type=1week
Response
{
"code": 1000,
"message": "成功",
"data": {
"sellCoin": "bit", //賣出貨幣
"buyCoin": "qc", //買入貨幣
"data": [
[
1518843600, //時間戳
"2550558.083140", //交易量
"1.322000", //開盤價
"1.396000", //最高價
"1.005000", //最低價
"1.031000" //收盤價
],
......
}
}
所有交易對市場詳情
Request
Method: GET
URL: api/market/allSymbol
Parameters: 無
api/market/allSymbol
Response
{
"code": 1000,
"message": "成功",
"data": [{
"id": "usdt_qc", //交易對名稱;string;required: true
"baseCurrency": "usdt", //交易貨幣名稱;string; required: true
"quoteCurrency": "qc", //計價貨幣名稱;string;required: true
"quantityIncrement": "0.001", //數量精度;string;required: true
"tickSize": "0.00001", //價格精度;string;required: true
"takeLiquidityRate": "0.0012", //taker手續費率;string;
"provideLiquidityRate": "0.0012", //maker手續費率;string;
"feeCurrency": "qc" //手續費幣種;string;
}]
}
交易對市場詳情
Request
Method: GET
URL: api/market/symbol/{symbol}
Parameters:
參數 類型 必填 描述 symbol string Y 市場名稱 api/market/symbol/usdt_qc
Response
{
"code": 1000,
"message": "成功",
"data": {
"id": "usdt_qc", //交易對名稱;string;required: true
"baseCurrency": "usdt", //交易貨幣名稱;string; required: true
"quoteCurrency": "qc", //計價貨幣名稱;string;required: true
"quantityIncrement": "0.001", //數量精度;string;required: true
"tickSize": "0.00001", //價格精度;string;required: true
"takeLiquidityRate": "0.0012", //taker手續費率;string;
"provideLiquidityRate": "0.0012", //maker手續費率;string;
"feeCurrency": "qc" //手續費幣種;string;
}
}
Get-symbol-info
Request
Method: GET
URL: api/market/symbol/{symbol}
Parameters:
Parameters type required description symbol string Y trading symbol api/market/symbol/usdt_qc
Response
{
"code": 1000,
"message": "成功",
"data": {
"id": "usdt_qc", //The trading symbol
"baseCurrency": "usdt", //The main trading currency for this symbol
"quoteCurrency": "qc", //The secondary trading currency for this symbol
"quantityIncrement": "0.001", //Quantitative accuracyAll quantities must be divisible by this number, and cannot be less than this number
"tickSize": "0.00001", //Price accuracy,All prices must be divisible by this number, and cannot be less than this number
"takeLiquidityRate": "0.0012", //The buy/sell trading fee for taker orders. Taker orders remove an item from the order books
"provideLiquidityRate": "0.0012", //The buy/sell trading fee for maker orders. Maker orders add an item to the order books.
"feeCurrency": "qc" //The currency in which fees are taken
}
}
Demo
條件查詢成交記錄
Request
Method: GET
URL: api/market/trades/{symbol}
Parameters:
參數 類型 必填 描述 symbol string Y 市場名稱 sort string N 排序方式 DESC ASC 默認 DESC by string N 根據(ID/時間)排序 (id timestamp) 默認 timestamp from string N 如果by-ID;tradeid;;否則時間;string till string N 如果by-ID;tradeid;;否則時間;string limit integer N 獲取數量,默認100;integer offset integer N 查詢記錄的起始索引 起始為0 api/market/trades/usdt_qc?sort=asc&by=timestamp&from=1573434000&till=1573436000&limit=100&offset=0
Response
{
"code": 1000,
"message": "成功",
"data": [
{
"id": 3107340,
"uuid": "3107340",
"price": "0.00679", //價格
"quantity": "1.046987", //數量
"side": "sell", //buy 買 sell 賣
"timestamp": "2019-11-08 13:28:49.0",
"unixtimestamp": 1573219729
},
......
]
}
Trades
Request
Method: GET
URL: api/market/trades/{symbol}
Parameters:
Parameters type required description symbol string Y trading symbol sort string N Sort direction (DESC ASC) Default value: DESC by string N Filter field (id timestamp) Default value: timestamp from string N If filter by timestamp, then datetime in iso format or timestamp in millisecond otherwise trade id till string N If filter by timestamp, then datetime in iso format or timestamp in millisecond otherwise trade id limit integer N Default 100. Minimum value 1, Maximum value 1000 Default value: 100 offset integer N offset Starting from 0 api/market/trades/usdt_qc?sort=asc&by=timestamp&from=1573434000&till=1573436000&limit=100&offset=0
Response
{
"code": 1000,
"message": "成功",
"data": [
{
"id": 3107340, //ID long
"uuid": "3107340", //UUID Default ID
"price": "0.00679", //price
"quantity": "1.046987", //quantity
"side": "sell", //buy or sell
"timestamp": "2019-11-08 13:28:49.0", //timestamp
"unixtimestamp": 1573219729 //unixtimestamp
},
......
]
}
Demo
獲取用戶信息
Request
Method: GET
URL: api/deal/accountInfo
Parameters:
參數 類型 必填 描述 accesskey string Y accesskey method string Y 直接賦值 accountInfo reqTime int Y 當前時間秒數 sign string Y 簽名串 api/deal/accountInfo?accesskey=519b3346-7198-47e3-81b8-20ce13513835&method=accountInfo& sign=3967426b6a1aaa3f26a2c7b382a50621&reqTime=1535102429
Response
{
"code": 1000,
"message": "成功",
"data": {
"base": {
"auth_google_enabled": false, //是否開通谷歌驗證
"auth_mobile_enabled": true, //是否開通手機驗證
"trade_password_enabled": true, //是否開通交易密碼
"username": "test" //用戶名
},
"coins": [
{
"enName": "btc", //幣種英文名
"cnName": "比特幣", //幣種中文名
"symbol": "฿", //幣種符號
"available": "86114.16208700", //可用資產
"freez": "0.00000000", //凍結資產
"unitDecimal": "2", //保留小數位
"isCanRecharge": true, //是否可充值
"isCanWithdraw": true //是否可提現
},
......
]
}
}
委托下單
Request
Method: GET
URL: api/deal/order
Parameters:
參數 類型 必填 描述 accesskey string Y accesskey method string Y 直接賦值 order reqTime int Y 當前時間秒數 sign string Y 簽名串 price float Y 單價 amount float Y 交易數量 tradeType int Y 交易類型1/2[買/賣] currency string Y 市場名字 api/deal/order?accesskey=519b3346-7198-47e3-81b8-20ce13513835&method=order& sign=f7169edac202a776b87811661817aeeb&reqTime=1535102429&price=60000&amount=0.113&tradeType=1¤cy=btc_qc
Response
{
"code": 1000,
"message": "委托掛單成功",
"data": {
"orderId": "643" //訂單ID
}
}
取消委托
Request
Method: GET
URL: api/deal/cancelOrder
Parameters:
參數 類型 必填 描述 accesskey string Y accesskey method string Y 直接賦值 cancelOrder reqTime int Y 當前時間秒數 sign string Y 簽名串 currency string Y 市場名字 id int Y 訂單ID api/deal/cancelOrder?accesskey=519b3346-7198-47e3-81b8-20ce13513835&method=cancelOrder& sign=1cb2d3c0d1fd708abb7eda37770172b5&reqTime=1535102429&id=626¤cy=btc_qc
Response
{
"code": 1000,
"message": "撤銷成功",
"data": ""
}
獲取委托買單或賣單
Request
Method: GET
URL: api/deal/getOrder
Parameters:
參數 類型 必填 描述 accesskey string Y accesskey method string Y 直接賦值 getOrder reqTime int Y 當前時間秒數 sign string Y 簽名串 currency string Y 市場名字 id int Y 訂單ID api/deal/getOrder?accesskey=519b3346-7198-47e3-81b8-20ce13513835&method=getOrder& sign=d712dfa60eaf5bc4053ebcd4af5ec253&reqTime=1535102429&id=626¤cy=btc_qc
Response
{
"code": 1000,
"message": "成功",
"data": {
"currency": "btc_qc", //市場
"id": 626, //委托掛單號
"price": "60000.000000", //單價
"status": 2, ////掛單狀態 (狀態(0:交易中,1:已完成,2:已撤銷, 3:部分成交))
"total_amount": "0.113000", //掛單總數量
"trade_amount": "0.000000", //已成交數量
"trade_time": 1534301098, //委托時間
"trade_money": "6793.560000", //總交易金額
"type": 1 //掛單類型 1/2[buy/sell]
"deal_money": "15.560000", //實際成交金額
}
}
獲取多個委托買單或賣單
Request
Method: GET
URL: api/deal/getOrders
Parameters:
參數 類型 必填 描述 accesskey string Y accesskey method string Y 直接賦值 getOrders reqTime int Y 當前時間秒數 sign string Y 簽名串 currency string Y 市場名字 pageIndex int Y 當前頁數 pageSize int Y 每頁數量 10-100 tradeType int N 交易類型1/2[buy/sell] tradeStatus int N 交易狀態 0:交易中,1:已完成,2:已撤銷,3:部分成交,4:合並1與3 api/deal/getOrders?accesskey=519b3346-7198-47e3-81b8-20ce13513835&method=getOrders& sign=6ed7b69018b4c151b2cf77f531a655a0&reqTime=1535102429¤cy=btc_qc&pageIndex=1&pageSize=10&tradeStatus=1
Response
{
"code": 1000,
"message": "成功",
"data": [
{
"currency": "btc_qc", //市場
"id": 631, //委托掛單號
"price": "60000.000000", //單價
"status": 0, //掛單狀態 (狀態(0:交易中,1:已完成,2:已撤銷, 3:部分成交))
"total_amount": "0.113000", //掛單總數量
"trade_amount": "0.000000", //已成交數量
"trade_date": 1535162354, //委托時間
"trade_money": "6793.560000", //總交易金額
"type": 1 //掛單類型 1/2[buy/sell]
},
......
]
}
獲取交易記錄
Request
Method: GET
URL: api/deal/getTrades
Parameters:
參數 類型 必填 描述 accesskey string Y accesskey method string Y 直接賦值 getTrades reqTime int Y 當前時間秒數 sign string Y 簽名串 currency string Y 市場名字 pageIndex int Y 當前頁數 pageSize int Y 每頁數量 10-100 orderId int Y 訂單編號 startTime int Y 開始時間毫秒數 endTime int Y 結束時間毫秒數 api/deal/getTrades?accesskey=f11c8358-9b30-4a5c-9c2d-906e4adb71d0&method=getTrades& sign=6ed7b69018b4c151b2cf77f531a655a0&reqTime=1535102429&pageIndex=1¤cy=ceo_qc& pageSize=10&orderId=16&startTime=1566355654&endTime=1566371318
Response
{
"code": 1000,
"message": "成功",
"data": [
{
"currency": "ceo_qc", //市場
"id": 571, //交易id
"price": "36.000000", //單價
"amount": "0.261040", //交易量
"type": 1, //交易類型 1/2[buy/sell]
"date": 1538276466, //時間
"fee": "0.000210" //手續費
}
]
}
獲取單個訂單交易記錄
Request
Method: GET
URL: api/deal/tradeLog
Parameters:
參數 類型 必填 描述 accesskey string Y accesskey method string Y 直接賦值 tradeLog reqTime int Y 當前時間秒數 sign string Y 簽名串 orderId long Y 訂單ID api/deal/getTrades?accesskey=f11c8358-9b30-4a5c-9c2d-906e4adb71d0&method=tradeLog& sign=6ed7b69018b4c151b2cf77f531a655a0&reqTime=1535102429&orderId=1
Response
{
"code": 1000,
"message": "成功",
"data": [
{
"currency": "ceo_qc", //市場
"id": 571, //交易id
"price": "36.000000", //單價
"amount": "0.261040", //交易量
"type": 1, //交易類型 1/2[buy/sell]
"date": 1538276466, //時間
"fee": "0.000210" //手續費
}
]
}
獲取用戶充值地址
Request
Method: GET
URL: api/deal/getUserAddress
Parameters:
參數 類型 必填 描述 accesskey string Y accesskey method string Y 直接賦值 getUserAddress reqTime int Y 當前時間秒數 sign string Y 簽名串 currency string Y 幣名 api/deal/getUserAddress?accesskey=519b3346-7198-47e3-81b8-20ce13513835&method=getUserAddress& sign=469595363c7a04a9b1f693273397cbc0&reqTime=1535102429¤cy=gxs
Response
{
"code": 1000,
"message": "成功",
"data": {
"address": "qqfewfew", //地址
"memo": "99" //備注
}
}
獲取用戶的數字幣提現地址
Request
Method: GET
URL: api/deal/getWithdrawAddress
Parameters:
參數 類型 必填 描述 accesskey string Y accesskey method string Y 直接賦值 getWithdrawAddress reqTime int Y 當前時間秒數 sign string Y 簽名串 currency string Y 幣名 api/deal/getWithdrawAddress?accesskey=519b3346-7198-47e3-81b8-20ce13513835&method=getWithdrawAddress& sign=620f6c274e4dd0e9cd8312a8765f2c17&reqTime=1535102429¤cy=btc
Response
{
"code": 1000,
"message": "成功",
"data": [
"1DZdA2WAzcsSak3tQYRVwuXWeSqhLuVCoA",
"1DZdA2WAzcsSak3tQYRVwuXWeSqhLuVCoc"
]
}
獲取數字幣提現記錄
Request
Method: GET
URL: api/deal/getWithdrawRecord
Parameters:
參數 類型 必填 描述 accesskey string Y accesskey method string Y 直接賦值 getWithdrawRecord reqTime int Y 當前時間秒數 sign string Y 簽名串 currency string Y 幣名 pageIndex int Y 當前頁數 pageSize int Y 每頁數量 api/deal/getWithdrawRecord?accesskey=519b3346-7198-47e3-81b8-20ce13513835&method=getWithdrawRecord& sign=0e94e185a41dcf339491bd4c6c958dea&reqTime=1535102429¤cy=btc&pageIndex=1&pageSize=10
Response
{
"code": 1000,
"message": "成功",
"data": {
"pageIndex": 1, //當前頁數
"pageSize": 10, //每頁數量
"totalCount": 7, //總數量
"totalPage": 1, //總頁數
"list": [
{
"amount": "5.00000000", //提現金額
"fees": "0.00150000", //提現手續費
"id": 165558, //提現記錄id
"manageTime": 0, //提現處理的時間的時間戳
"status": 0, //提幣狀態狀態(0:等待處理;1:轉出成功;2:已經審核;3:已經撤銷)
"submitTime": 1534920264, //提現發起的時間的時間戳
"toAddress": "1DZdA2WAzcsSak3tQYRVwuXWeSqhLuVCoc" //提現的接收地址
},
......
]
}
}
獲取數字幣充值記錄
Request
Method: GET
URL: api/deal/getChargeRecord
Parameters:
參數 類型 必填 描述 accesskey string Y accesskey method string Y 直接賦值 getChargeRecord reqTime int Y 當前時間秒數 sign string Y 簽名串 currency string Y 幣名 pageIndex int Y 當前頁數 pageSize int Y 每頁數量 api/deal/getChargeRecord?accesskey=519b3346-7198-47e3-81b8-20ce13513835&method=getChargeRecord& sign=538b6d053c32cd83f97fd2cfadfb7f31&reqTime=1535102429¤cy=eth&pageIndex=1&pageSize=10
Response
{
"code": 1000,
"message": "成功",
"data": {
"pageIndex": 1, //當前頁數
"pageSize": 10, //每頁數量
"totalCount": 2, //總數量
"totalPage": 1, //總頁數
"list": [
{
"address": "0x5de61aec70dc1654456f75aa964daf754d2a7f30",
"amount": "0.01050000",
"confirmTimes": 3,
"currency": "ETH",
"hash": "0x84d073ef430e53e5b21bb35831b135ce217a69efbadddc187b9380fa3fdd5a3b",
"id": 19813,
"status": 1,
"submit_time": 1511961018,
"type": "站外"
},
{
"address": "0x5de61aec70dc1654456f75aa964daf754d2a7f30",
"amount": "5.00000000",
"confirmTimes": 0,
"currency": "ETH",
"hash": "",
"id": 15,
"status": 1,
"submit_time": 1507882027,
"type": "系統充值"
}
]
}
}
Response狀態
1000; //成功
1001; //一般錯誤
1002; //內部錯誤
1003; //驗證不通過
1004; //網站維護中
1005;// API接口維護中
1006; //權限不足
1007; //無效的參數
1008; //無效的IP或與綁定的IP不一致
簽名方式
請求參數按照ASCII值排序,然后通過hmac MD5加密
javascript
function sign(params, secretKey) { if (typeof params != 'object') { throw Error('參數必須為對象') } let preSign = []; for (let key of Object.keys(params).sort()) { preSign.push(key+'='+params[key]); } return CryptoJS.HmacMD5(preSign.join('&'), secretKey).toString(); }
php
function sign(array $params, $secretKey) { ksort($params); $preSign = http_build_query($params, '', '&'); $sign = hash_hmac('md5', $preSign, $secretKey); return $sign; }
java
代碼庫中 SignUtil.java
public static String sign(Map<String, String> paramMap, String secret) throws Exception { StringBuilder sb = new StringBuilder(); TreeMap<String, String> params = new TreeMap<>(); params.putAll(paramMap); params.entrySet() .forEach(entry -> { if (sb.length() > 0) { sb.append("&"); } sb.append(entry.getKey()).append("="); sb.append(entry.getValue()); }); return sign(sb.toString(), secret); } public static String sign(String paramString, String secretKey) throws Exception { SecretKeySpec secret_key = new SecretKeySpec(secretKey.getBytes(), "HmacMD5"); String actualSignature = ""; try { actualSignature = Hex.encodeHexString(encodeHmacMD5(paramString.getBytes("UTF-8"), secret_key)); } catch (UnsupportedEncodingException e) { throw new Exception("驗簽加密失敗!"); } return actualSignature; } private static byte[] encodeHmacMD5(byte[] data, Key key) { Mac mac = null; try { mac = Mac.getInstance("HmacMD5"); mac.init(key); } catch (NoSuchAlgorithmException | InvalidKeyException e) { e.printStackTrace(); return new byte[0]; } return mac.doFinal(data); }
postman 交易API測試
Params
參數名 值 reqTime {{sign}} sign {{reqTime}}
Pre-request Script
function signfn(params, secretKey) { let preSign = []; for (let key of Object.keys(params).sort()) { if (key == 'sign') { console.log(params[key]); } if (key === 'sign' || params[key] === '') { continue; } preSign.push(key+'='+params[key]); } return CryptoJS.HmacMD5(preSign.join('&'), secretKey).toString(); } let now = Math.floor(Date.now()); pm.globals.set("reqTime", now); let query = {}; pm.request.url.query.all().forEach((param) => { query[param.key] = param.value}); query.reqTime = now; pm.globals.set("sign", signfn(query, '8d06dae1-72ef-4d9c-82ca-5210b1a1dc48'));
訪問限制
單個IP限制每分鍾3000次訪問
交易API單個用戶限制每秒鍾50次訪問
Ws獲取全部市場行情
Request
參數 類型 必填 描述 event string Y addChannel channel string Y all_ticker
Response
{
"channel": "all_ticker",
"date": "1472800466093",
"data":
{
"ceo_qc": { // 市場名
"buy": "91.00000000", // 買一價
"sell": "91.50000000", // 賣一價
"last": "90.00000000", // 最新成交價
"vol": "0.00000000", // 成交量(最近的24小時)
"high": "0.00000000", // 最高價
"low": "0.00000000", // 最低價
"change": "0.10" //漲跌幅
},
"eth_ceo": {
"buy": "52.18000000",
"sell": "53.30000000",
"last": "53.30000000",
"vol": "5.00000000",
"high": "53.30000000",
"low": "53.00000000",
"change": "0.10"
},
......
}
}
Ws獲取市場行情
Request
參數 類型 必填 描述 event string Y addChannel channel string Y ceo_qc_ticker
Response
{
"channel": "ceo_qc_ticker",
"date": "1472800466093",
"ticker":
{
"buy": "91.00000000", // 市場名
"sell": "91.50000000", // 買一價
"last": "90.00000000", // 賣一價
"vol": "0.00000000", // 最新成交價
"high": "0.00000000", // 成交量(最近的24小時)
"low": "0.00000000", // 最高價
"change": "0.10" //漲跌幅
}
}
Ws獲取市場深度
Request
參數 類型 必填 描述 event string Y addChannel channel string Y ceo_qc_order
Response
{
"date" : 1567582150426 ,
"b": [ // 買
[
"11.37", // 價格
"877.627331" // 數量
],
[
"11.37"
"877.627331"
],
......
],
"s":[ // 賣
[
"11.37"
"877.627331"
],
[
"11.37",
"877.627331"
],
......
],
"channel": "ceo_qc_order"
}
Ws獲取歷史成交
Request
參數 類型 必填 描述 event string Y addChannel channel string Y ceo_qc_trade
Response
{
"date" : 1567582150426 ,
"data": [
{
"id": 1,
"amount": "5000.000000", // 交易數量
"price": "0.400000", // 交易價格
"type": 2, // 交易類型,1(買)/2(賣)
"time": 1530144000 // 交易時間(時間戳)
},
......
],
"channel": "ceo_qc_trade"
}