- Notifications
You must be signed in to change notification settings - Fork 1.5k
WebSocket Protocol
The API is based on JSON RPC of Websocket protocol. Repeated subscription will be cancelled for the same data type.
Request
- method: method,String
- params: parameters,Array
- id: Request id, Integer
Response
- result: Json object,null for failure
- error: Json object,null for success, non-null for failure
- code: error code
- message: error message
- id: Request id, Integer
Notify
- method: method,String
- params: parameters,Array
- id: Null
General error code:
- 1: invalid argument
- 2: internal error
- 3: service unavailable
- 4: method not found
- 5: service timeout
- 6: require authentication
PING
- method:
server.ping - params: None
- result: "pong"
- example:
{"error": null, "result": "pong", "id": 1000}
System time
- method:
server.time - params: none
- result: timestamp,Integer
- example:
{"error": null, "result": 1493285895, "id": 1000}
ID verification Web
- method:
server.auth - params:
- token: String
- source: String, source,e.g. "web", version number up to 30 bytes is required for applications
ID verification Api
- method:
server.sign - params:
- access_id: String
- authorization: String, sign data
- tonce: timestamp,for milliseconds spent from Unix epoch to current time,and error between tonce and server time can not exceed plus or minus 60s
Market inquiry
- method:
kline.query - params:
- market: market name
- start: start time,Integer
- end: end time, Integer
- interval: interval, Integer
- result:
"result": [ [ 1492358400, time "7000.00", open "8000.0", close "8100.00", highest "6800.00", lowest "1000.00" volume "123456.00" amount "BTCCNY" market name ] ... ] Market subscription
- method:
kline.subscribe - params:
- market
- interval
Market notification
- method:
kline.update - params:
[ [ 1492358400, time "7000.00", open "8000.0", close "8100.00", highest "6800.00", lowest "1000.00" volume "123456.00" amount "BTCCNY" market name ] ... ] Cancel subscription
- method:
kline.unsubscribe - params: none
Acquire latest price
- method:
price.query - params:
- market: String, market name
- result: String, price
Latest price subscription
- method:
price.subscribe - params: market list
Latest market notification
- method:
price.update - params:
- market: String
- price: String
Cancel subscription
- method:
price.unsubscribe - params: none
Acquire market status
- method:
state.query - params:
- market: market
- period: cycle period,Integer, e.g. 86400 for last 24 hours
- result:
{ "open": open price "last": latest price "high": highest price "low": lowest price "deal": amount "volume": volume } Market 24H status subscription
- method:
state.subscribe - params: market list
Market 24H status notification
- method:
state.update - params:
- market:
- result: same as query
Cancel subscription
- method:
state.unsubscribe - params: none
Acquire Market today status
- method:
today.query - params:
- market: market
- result:
{ "open": Today open price "last": Today latest price "high": Today highest price "low": Today lowest price "deal": 24H amount "volume": 24H volume } Market today status subscription
- method:
today.subscribe - params: market list
Market Today status notification
- method:
today.update - params:
- market:
- result: same as query
Cancel subscription
- method:
today.unsubscribe - params: none
Acquire latest executed list
- method:
deals.query - params:
- market:market
- limit:amount limit
- last_id: largest ID of last returned result
Latest order list subscription
- method:
deals.subscribe - params: market list
Latest order list update
- method:
deals.update - params:
- market name
- order list
Cancel subscription
- method:
deals.unsubscribe - params: none
Acquire depth
- method:
depth.query - params:
- market:market name
- limit: amount limit,Integer
- interval: interval,String, e.g. "1" for 1 unit interval, "0" for no interval
"result": { "asks": [ [ "8000.00", "9.6250" ] ], "bids": [ [ "7000.00", "0.1000" ] ] } Depth subscription
- method:
depth.subscribe - params:
- market
- limit
- interval
Depth notification
- method:
depth.update - params:
- clean: Boolean, true: complete result,false: last returned updated result
- Same as depth.query,only return what's different from last result, asks 或 bids may not exist. amount == 0 for delete
- market name
Cancel subscription
- method:
depth.unsubscribe - params: none
Unexecuted order inquiry
- method:
order.query - params:
- market: market name,String
- offset: offset,Integer
- limit: limit,Integer
- result: see HTTP protocol
Executed order inquiry
- method:
order.history - params:
- market: market name,String
- start_time: start time,0 for unlimited,Integer
- end_time: end time,0 for unlimited, Integer
- offset: offset,Integer
- limit: limit,Integer
- side: side,0 for unlimited,1 for sell,2 for buy
Order subscription
- method:
order.subscribe - params: market list
Order notification
- method:
order.update - params:
- event: event type,Integer, 1: PUT, 2: UPDATE, 3: FINISH
- order: order detail,Object,see HTTP protocol
Cancel subscription
- method:
order.unsubscribe - params: none
Asset inquiry
- method:
asset.query - params: asset list, null for inquire all
- result:
{"BTC": {"available": "1.10000000","freeze": "9.90000000"}} Asset history
- method:
asset.history - params:
- asset: asset name, which can be null
- business: business,which can be null, use ',' to separate types
- start_time: start time, 0 for unlimited,Integer
- end_time: end time, 0 for unlimited, Integer
- offset: offset,Integer
- limit: amount limit,Integer
Asset subscription
- method:
asset.subscribe - params: asset list
Asset notification
- method:
asset.update - params:
[{"BTC: {"available": "1.10000000","freeze": "9.90000000"}, "CNY": {}}] Cancel subscription
- method:
asset.unsubscribe - params: none