Overview
Welcome to CBX Developer API V3 Documents
API Base Endpoint: https://api.cbx.one/api/v3/
Notice: This is just base endpoint and must be concatenated with the remaining part in each page below for normal access. Example: https://api.cbx.one/api/v3/ping
We recommend you to use following API entry point if you are in mainland China to avoid expected or unexpected network problems:
API EntryPoint: https://api.cbx.one/api/v3/
Authentication
This document is a guidance of the authentication for CBX Developer API.
CBX Developer APIs fall into public APIs and private APIs. As for private API, developers have to offer token in header for CBX to verify the user identity:
curl "https://API_SERVER/viewer/accounts" \ -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoiT3BlbkFQSVYyIiwic3ViIjoiY2VlODhhYjAtYmM2OS00MzU3LTg0YjctZGIwNTQ1ZTg1NjQ3Iiwibm9uY2UiOiIxNTI3NjY1MjYyMTY4MzkxMDAwIiwicmVjdl93aW5kb3ciOiI1MCJ9.AwsojrjKuQGTgmmkLDZ3piCOmuAQ_Y2PtU9JSUOQaT0'
How to get API Key and API Secret
Developers can set up API Key and API Secret in CBX setting page.
Notice: The old private key is not compatible with OpenAPI V3 and a new private key must be generated.
Set up your token
CBX API uses JSON Web Tokens (JWT) to make sure the request is authorized.
You need a JWT library for your language that supports the HS256 algorithm and the claims type MapClaim.
And DO NOT encode your signature using Base64, otherwise the token would be invalid.
The JWT header
Make sure that the JWT's header conforms to the following constraints:
JWT Header Claims |
type |
value |
alg |
string |
HS256 |
typ |
string |
JWT |
The JWT payload
Make sure that the JWT was signed by your own API Secret and the JWT payload conforms the following constraints:
JWT Payload Claims |
type |
value |
type |
string |
REQUIRED. Value Must be OpenAPIV2 |
sub |
string |
REQUIRED. Your API Key |
nonce |
string |
REQUIRED. Must be a timestamp converted to a string. And the differential time between nonce and current timestamp must less than seconds that recv_window set. This timestamp is measured in nanoseconds since the UNIX epoch., e.g. 1527665262168391000. (从int改成char) |
recv_window |
string |
OPTIONAL. The seconds Allowed timestamp offset. Deafult value is 30. |
Example
JWT Header
{
"typ": "JWT",
"alg": "HS256"
}
JWT Payload
{
"type": "OpenAPIV2",
"sub": "cee88ab0-bc69-4357-84b7-db0545e85647",
"nonce": "1527665262168391000",
"recv_window": "50"
}
Use testsecret
as the secret to sign you token
Notice: DO NOT encode your secret using Base64, otherwise the token would be invalid.
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0eXBlIjoiT3BlbkFQSVYyIiwic3ViIjoiY2VlODhhYjAtYmM2OS00MzU3LTg0YjctZGIwNTQ1ZTg1NjQ3Iiwibm9uY2UiOiIxNTI3NjY1MjYyMTY4MzkxMDAwIiwicmVjdl93aW5kb3ciOiI1MCJ9.wuOfj7xmBN7o_TZ9mT4kj0PdZ6qovFkkjEn4WWa7YII
For detailed definitions of error codes, you can see it here and also generate and parse your own token in this website.
Rate Limit
For now, for a single ip: 500 requests per 10 seconds.
API Response
HTTP code
CBX Developer APIs follow the RFC standard.
Response struct
success
{
"code": 0,
"message": "code description",
"data": {},
}
paging
{
"code": 0,
"message": "code description",
"data": {},
"page_token":"dxvf"
}
error
{
"code": 10005,
"message": "internal error",
}
You can see the list of error codes here.
Error Codes
Code |
Description |
10001 |
"syntax error" |
10005 |
"internal error" |
10007 |
"parameter error" |
10011 |
"system error" |
10013 |
"resource not found" |
10014 |
"insufficient funds" |
10403 |
"permission denied" |
10429 |
"too many requests" |
40004 |
"unauthorized" |
40103 |
"invalid otp code" |
40104 |
"invalid asset pin code" |
40302 |
"already requested" |
40601 |
"resource is locked" |
40602 |
"resource is depleted" |
40603 |
"insufficient resource" |
40120 |
"Order is in trading" |
40121 |
"Order is already cancelled or filled" |
Public API
WebSocket(Alpha)
WebSocket API provide the quasi real-time market transaction data.
【DISCLAIMER】 The WebSocket API is still in Alpha stage. CBX cannot guarantee the availability, validity and correctness of it. You have to know clearly that you have to take the risk on your own. The risks include but not limited to the program bugs, errors and insecurity. When you use this API means that you agreed with this disclaimer and considered yourself have the ability to take the risks and you're responsible for this behavior. Our company is responsible for interpreting this document. The relevant laws and regulations of the state should be the standard if there are divergence in this declaration.
API Endpoint
Notice
-
You need to authenticate customer before subscribe viewer orders or accounts
-
And set WebSocket's subprotocol as
json
Sec-WebSocket-Protocol: json
requestId
:requestId
is the identification for the API request. The API Responses will carry the requestId for you to know the response corresponds to which request. So you should use unique requestId in different requests.
AuthenticateCustomer
{"requestId":"1", "authenticateCustomerRequest":{"token":"Bearer xxx.xxx.xxx"}}
Request Parameters
Name | Description | Example | Require |
---|---|---|---|
requestId | id of request | 1 | true |
token | open api token of customer | Bearer xxx.xxx.xxx | true |
Market Depth
subscribe
{"requestId": "1", "subscribeMarketDepthRequest":{"market":"BTC-USDT"}}
Request Parameters
Name | Description | Example | Require |
---|---|---|---|
requestId | id of request | 1 | true |
market | id of market | BTC-USDT | true |
Example of depth snapshot response
{
"requestId": "1",
"depthSnapshot": {
"depth": {
"market":"BTC-USDT",
"asks":[
{
"price":"197.96",
"amount":"5.0",
"orderCount":1
}
],
"bids":[
{
"price":"159.99",
"amount":"1.07552",
"orderCount":1
}
]
}
}
}
Example of depth update response
{
"requestId": "1",
"depthUpdate": {
"depth": {
"market":"BTC-USDT",
"asks":[
{
"price":"197.96",
"amount":"5.0",
"orderCount":"1"
}
],
"bids":[
{
"price":"159.99",
"amount":"1.07552",
"orderCount":"1"
}
]
}
}
}
depth
Name | Description | Example |
---|---|---|
market | id of market | BTC-USDT |
asks | list of depth ask | |
bids | list of depth bid |
ask / bid
Name | Description | Example |
---|---|---|
price | ask price | 197.96 |
amount | ask amount | 5.0 |
orderCount | ask order count | 1 |
unsubscribe
{"requestId": "1", "unsubscribeMarketDepthRequest":{"market":"BTC-USDT"}}
Market Candle
subscribe
{"requestId": "1", "subscribeMarketCandlesRequest":{"market":"BTC-USDT", "period": "MIN5", "limit": "20"}}
Request Parameters
Name | Description | Example | Require |
---|---|---|---|
requestId | id of request | 1 | true |
market | id of market | BTC-USDT | true |
period | symbol of candle period | MIN5 | true |
limit | expect count of candles snapshot | 20 | false |
period
Symbol | Description |
---|---|
MIN1 | 1 minute |
MIN5 | 5 minutes |
MIN15 | 15 minutes |
MIN30 | 30 minutes |
HOUR1 | 1 hour |
HOUR3 | 3 hours |
HOUR4 | 4 hours |
HOUR6 | 6 hours |
HOUR12 | 12 hours |
DAY1 | 1 day |
WEEK1 | 1 week |
Example of candles snapshot response
{
"requestId":"1",
"candlesSnapshot":{
"candles":[
{
"market":"BTC-USDT",
"time":"2018-09-12T13:40:00Z",
"open":"9.0",
"high":"9.0",
"low":"9.0",
"close":"9.0",
"period":"MIN5"
}
]
}
}
Example of candle update response
{
"requestId":"1",
"candleUpdate":{
"candle":{
"market":"BTC-USDT",
"time":"2018-09-12T05:30:00Z",
"open":"9",
"high":"9",
"low":"9",
"close":"9",
"period":"MIN5"
}
}
}
candle
Name | Description | Example |
---|---|---|
market | id of market | BTC-USDT |
time | utc time of candle | 2018-09-12T13:40:00Z |
open | open of candle | 9.0 |
high | high of candle | 9.0 |
low | low of candle | 9.0 |
close | close of candle | 9.0 |
period | symbol of candle period | MIN5 |
unsubscribe
{"requestId": "1", "unsubscribeMarketCandlesRequest":{"market":"BTC-USDT", "period": "MIN5"}}
Market Ticker
subscribe
{"requestId": "1", "subscribeMarketsTickerRequest":{"markets":["BTC-USDT", "ONE-BTC"]}}
Request Parameters
Name | Description | Example | Require |
---|---|---|---|
requestId | id of request | 1 | true |
markets | list of market id | ["BTC-USDT"] | true |
Example of tickers snapshot response
{
"requestId":"1",
"tickersSnapshot":{
"tickers":[
{
"market":"ETH-USDT",
"ask":{
"price":"197.96",
"amount":"5.0",
"orderCount":"1"
},
"bid":{
"price":"159.99",
"amount":"1.07552",
"orderCount":"1"
},
"open":"197.46",
"high":"0.0",
"low":"0.0",
"close":"213.96",
"volume":"0.0"
}
]
}
}
Example of ticker update response
{
"requestId":"1",
"tickerUpdate":{
"ticker":{
"market":"ETH-USDT",
"ask":{
"price":"197.96",
"amount":"5.0",
"orderCount":"1"
},
"bid":{
"price":"159.99",
"amount":"1.07552",
"orderCount":"1"
},
"open":"197.46",
"high":"0.0",
"low":"0.0",
"close":"213.96",
"volume":"0.0"
}
}
}
ticker
Name | Description | Example |
---|---|---|
market | id of market | BTC-USDT |
ask | ticker ask | |
bid | ticker bid | |
open | open of ticker | 10.24 |
high | high of ticker | 10.24 |
low | low of ticker | 10.24 |
close | close of ticker | 10.24 |
volume | volume of ticker | 10.24 |
ask / bid
Name | Description | Example |
---|---|---|
price | ask price | 197.96 |
amount | ask amount | 5.0 |
orderCount | ask order count | 1 |
unsubscribe
{"requestId": "1", "unsubscribeMarketsTickerRequest":{"markets":["BTC-USDT", "ONE-BTC"]}}
Market Trade
subscribe
{"requestId": "1", "subscribeMarketTradesRequest":{"market":"BTC-USDT", "limit": "20"}}
Request Parameters
Name | Description | Example | Require |
---|---|---|---|
requestId | id of request | 1 | true |
market | id of market | BTC-USDT | true |
limit | expect count of trades snapshot | 20 | false |
Example of trades snapshot Response
{
"requestId":"1",
"tradesSnapshot":{
"trades":[
{
"id":"28622",
"price":"9.0",
"amount":"10000.0",
"market":"BTC-USDT",
"createdAt":"2018-09-12T09:52:37Z",
"makerOrder":{
"id":"42844576",
"price":"9.0",
"stopPrice":"0.0",
"amount":"10000.0",
"market":"BTC-USDT",
"state":"FILLED",
"filledAmount":"10000.0",
"filledFees":"10.0",
"avgDealPrice":"9.0",
"createdAt":"2018-09-11T17:35:42Z",
"updatedAt":"2018-09-12T09:52:37Z"
},
"takerOrder":{
"id":"42844576",
"price":"9.0",
"stopPrice":"0.0",
"amount":"10000.0",
"market":"BTC-USDT",
"side":"ASK",
"state":"FILLED",
"filledAmount":"10000.0",
"filledFees":"90.0",
"avgDealPrice":"9.0",
"createdAt":"2018-09-12T09:52:36Z",
"updatedAt":"2018-09-12T09:52:37Z"
}
}
]
}
}
Example of trades update Response
{
"requestId":"1",
"tradesUpdate":{
"trade":{
"id":"28622",
"price":"9.0",
"amount":"10000.0",
"market":"BTC-USDT",
"createdAt":"2018-09-12T09:52:37Z",
"makerOrder":{
"id":"42844576",
"price":"9.0",
"stopPrice":"0.0",
"amount":"10000.0",
"market":"BTC-USDT",
"state":"FILLED",
"filledAmount":"10000.0",
"filledFees":"10.0",
"avgDealPrice":"9.0",
"createdAt":"2018-09-11T17:35:42Z",
"updatedAt":"2018-09-12T09:52:37Z"
},
"takerOrder":{
"id":"42844576",
"price":"9.0",
"stopPrice":"0.0",
"amount":"10000.0",
"market":"BTC-USDT",
"side":"ASK",
"state":"FILLED",
"filledAmount":"10000.0",
"filledFees":"90.0",
"avgDealPrice":"9.0",
"createdAt":"2018-09-12T09:52:36Z",
"updatedAt":"2018-09-12T09:52:37Z"
}
}
}
}
Response Parameters
trade
Name | Description | Example |
---|---|---|
id | id of trade | 1 |
price | price of trade | 9.0 |
amount | amount of trade | 1000.0 |
market | id of market | BTC-USDT |
createdAt | create time of trade | 2018-09-12T09:52:37Z |
makerOrder | order of maker | |
takerOrder | order of taker |
makerOrder / takerOrder
Name | Description | Example |
---|---|---|
id | id of order | 1 |
price | price of order | 10.24 |
stopPrice | stop price of order | 10.24 |
amount | amount of order | 1000.0 |
market | id of market | BTC-USDT |
side | order side | ASK |
state | order state | FILLED |
filledAmount | filled amount | 1000.0 |
filledFees | filled fees | 90.0 |
avgDealPrice | average deal price of order | 9.0 |
createdAt | create time of order | 2018-09-12T09:52:36Z |
updatedAt | update time of order | 2018-09-12T09:52:36Z |
unsubscribe
{"requestId": "1", "unsubscribeMarketTradesRequest":{"market":"BTC-USDT"}}
User Account
subscribe
{"requestId": "1", "subscribeViewerAccountsRequest":{}}
Request Parameters
Name | Description | Example | Require |
---|---|---|---|
requestId | id of request | 1 | true |
Example of accounts snapshot response
{
"requestId":"1",
"accountsSnapshot":{
"accounts":[
{
"asset":"BTC",
"balance":"10.0",
"lockedBalance":"0.0"
}
]
}
}
Example of user accounts update response
{
"requestId":"1",
"accountUpdate":{
"account":{
"asset":"BTC",
"balance":"0.0",
"lockedBalance":"0.0"
}
}
}
account
Name | Description | Example |
---|---|---|
asset | asset of account | BTC |
balance | balance of account | 10.0 |
lockedBalance | locked balance of account | 10.0 |
unsubscribe
{"requestId": "1", "unsubscribeViewerAccountsRequest":{}}
User Order
subscribe
{"requestId": "1", "subscribeViewerOrdersRequest":{"market":"BTC-USDT"}}
Request Parameters
Name | Description | Example | Require |
---|---|---|---|
requestId | id of request | 1 | true |
market | id of market | BTC-USDT | true |
Example of user orders snapshot response
{
"requestId":"1",
"ordersSnapshot":{
"orders":[
{
"id":"42844576",
"price":"9.0",
"stopPrice":"0.0",
"amount":"10000.0",
"market":"BTC-USDT",
"side":"ASK",
"state":"FILLED",
"filledAmount":"10000.0",
"filledFees":"90.0",
"avgDealPrice":"9.0",
"createdAt":"2018-09-12T09:52:36Z",
"updatedAt":"2018-09-12T09:52:37Z"
}
]
}
}
Example of user order update response
{
"requestId":"1",
"orderUpdate":{
"requestId":"1",
"orderUpdate":{
"order":{
"id":"42844576",
"price":"9.0",
"stopPrice":"0.0",
"amount":"10000.0",
"market":"BTC-USDT",
"side":"ASK",
"state":"FILLED",
"filledAmount":"10000.0",
"filledFees":"90.0",
"avgDealPrice":"9.0",
"createdAt":"2018-09-12T09:52:36Z",
"updatedAt":"2018-09-12T09:52:37Z"
}
}
}
}
order
Name | Description | Example |
---|---|---|
id | id of order | 1 |
price | price of order | 10.24 |
stopPrice | stop price of order | 10.24 |
amount | amount of order | 1000.0 |
market | id of market | BTC-USDT |
side | order side | ASK |
state | order state | FILLED |
filledAmount | filled amount | 1000.0 |
filledFees | filled fees | 90.0 |
avgDealPrice | average deal price of order | 9.0 |
createdAt | create time of order | 2018-09-12T09:52:36Z |
updatedAt | update time of order | 2018-09-12T09:52:36Z |
unsubscribe
{"requestId": "1", "unsubscribeViewerOrdersRequest":{"market":"BTC-USDT"}}
Response
After successfully subscribing, the API will return the snapshot data
first, then the update data
if the subscription generates new data.
Response of authenticate customer success
{"requestId":"1","success":{"ok":true}}
{
"requestId":"1",
"error":{
"code":45000,
"message":"GRPC error: xxx"
}
}
code | type |
---|---|
45000 | grpc error |
45001 | login status error |
other | default error |
Ping
Get Server timestamp
GET /ping
{
"data": {
"timestamp": 1527665262168391000
}
}
Ticker
PriceLevel
Attribute Name |
Type |
Description |
Example |
price |
string |
price |
5098.37 |
quantity |
string |
quantity |
0.0679 |
order_count |
string |
order count in this level |
10 |
Ticker
Ticker is the current state of one asset pair, with 24 hour trading data
Attribute Name |
Type |
Description |
Example |
asset_pair_name |
string |
name of asset pair |
BTC-USDT |
bid |
PriceLevel |
latest bid |
|
ask |
PriceLevel |
latest ask |
|
open |
string |
open price in last 24h |
3100.0 |
close |
string |
close price in last 24h |
3100.0 |
high |
string |
highest deal price in last 24h |
3100.0 |
low |
string |
lowest deal price in last 24h |
3100.0 |
volume |
string |
total volume in last 24h |
3100.0 |
daily_change |
string |
change in last 24h |
0.00001 |
Ticker of one asset pair
GET /asset_pairs/{asset_pair_name}/ticker
Parameters
Name |
Type |
Require |
Description |
Example |
asset_pair_name |
string |
true |
asset pair id |
BTC-USDT |
Response is a Ticker object.
{
"volume": "190.4925000000000000",
"open": "0.0777371200000000",
"asset_pair_name": "ETH-BTC",
"low": "0.0742925600000000",
"high": "0.0789150000000000",
"daily_change": "-0.00029",
"close": "0.0774425600000000", // last price
"bid": {
"price": "0.0764777900000000",
"order_count": 4,
"quantity": "6.4248000000000000"
},
"ask": {
"price": "0.0774425600000000",
"order_count": 2,
"quantity": "1.1741000000000000"
}
}
Ticker of multiple asset pairs
GET /asset_pairs/tickers
Parameters
Name | Type | Require | Description | Example |
---|---|---|---|---|
pair_names | string | true | names of asset pair, separated by comma | BTC-USDT,PCX-BTC,GXC-USDT |
Notice: The count of asset pair's name should greater than 0 and less than or equal to 10.
Response is a Ticker array.
{
"code": 0,
"data": [
{
"asset_pair_name": "PCX-BTC",
"bid": {
"price": "0.0007346",
"order_count": 1,
"quantity": "0.03"
},
"ask": {
"price": "0.0007367",
"order_count": 1,
"quantity": "0.235"
},
"open": "0.0007468",
"high": "0.0007551",
"low": "0.000715",
"close": "0.0007357",
"volume": "16230.195",
"daily_change": "-0.0000111"
},
{
"asset_pair_name": "GXC-USDT",
"bid": {
"price": "1.2",
"order_count": 1,
"quantity": "7.43"
},
"ask": {
"price": "1.3584",
"order_count": 1,
"quantity": "27.33"
},
"open": "1.28",
"high": "1.28",
"low": "1.2",
"close": "1.2",
"volume": "488.8",
"daily_change": "-0.08"
}
]
}
Order Book
PriceLevel
Attribute Name |
Type |
Description |
Example |
price |
string |
price |
5098.37 |
quantity |
string |
quantity |
0.0679 |
order_count |
string |
order count in this level |
10 |
Depth
Attribute Name |
Type |
Description |
Example |
asset_pair_name |
string |
asset pair name |
BTC-USDT |
bids |
PriceLevel array |
bids |
|
asks |
PriceLevel array |
asks |
Order Book is the ask orders and bid orders collection of a asset pair
OrderBook of a asset pair
GET /asset_pairs/{asset_pair_name}/depth
Parameters
Name |
Type |
Require |
Description |
Example |
asset_pair_name |
string |
true |
asset pair name |
ETH-BTC |
limit |
string |
false |
default 50; max 200 |
Response is depth object.
{
"asset_pair_name": "EOS-BTC",
"bids": [
{
"price": "42",
"order_count": 4,
"quantity": "23.33363711"
}
],
"asks": [
{
"price": "45",
"order_count": 2,
"quantity": "4193.3283464"
}
]
}
AssetPair Trade
Trade
Attribute Name |
Type |
Description |
Example |
id |
number |
id of trade |
|
asset_pair_name |
string |
name of asset pair |
BTC-USDT |
price |
string |
deal price |
|
amount |
string |
amount |
|
taker_side |
string |
order side, one of "ASK"/"BID" |
|
created_at |
string |
order created datetime |
Trades of a asset pair
Only returns 50 latest trades
GET /asset_pairs/{asset_pair_name}/trades
Parameters
Name |
Type |
Require |
Description |
Example |
asset_pair_name |
string |
true |
asset pair name |
BTC-USDT |
Response is Trade Array.
{
"code": 0,
"data": [{
"id": 38199941,
"price": "3378.67",
"amount": "0.019812",
"taker_side": "ASK",
"created_at": "2019-01-29T06:05:56Z"
}, {
"id": 38199934,
"price": "3376.14",
"amount": "0.019384",
"taker_side": "ASK",
"created_at": "2019-01-29T06:05:40Z"
}]
}
AssetPair Candle
Candle
Attribute Name |
Type |
Description |
close |
string |
close price |
high |
string |
high price |
low |
string |
low price |
open |
string |
open price |
time |
string |
candle time |
volume |
string |
volume |
Candles of a asset pair
GET /asset_pairs/{asset_pair_name}/candles
Parameters
Name |
Type |
Require |
Description |
Example |
asset_pair_name |
string |
true |
asset pair name |
BTC-USDT |
period |
string |
true |
day1, hour1, hour12, hour3, hour4, hour6, min1, min15, min30, min5, month1, week1 |
day1 |
time |
string |
false |
latest time of candle, use current time by default, ISO 8601 format |
|
limit |
number |
false |
default 100, max 500 |
Response is Candle Array.
[{
"close": "3614.18",
"high": "3615.53",
"low": "3613.94",
"open": "3613.94",
"time": "2019-02-14T06:22:00Z",
"volume": "0.084582"
}, {
"close": "3615.38",
"high": "3615.96",
"low": "3614.04",
"open": "3615",
"time": "2019-02-14T06:21:00Z",
"volume": "0.076159"
}]
AssetPair
Asset
Attribute Name |
Type |
Description |
Example |
id |
string |
asset id |
0df9c3c3-255a-46d7-ab82-dedae169fba9 |
symbol |
string |
asset symbol |
BTC |
name |
string |
asset name |
Bitcoin |
AssetPair
Account represents the state of one asset pair.
Attribute Name |
Type |
Description |
Example |
id |
string |
asset pair id |
d2185614-50c3-4588-b146-b8afe7534da6 |
quote_scale |
number |
quote scale of asset pair |
8 |
quote_asset |
Asset |
quote asset of asset pair |
|
name |
string |
asset pair name |
BTG-BTC |
base_scale |
number |
base scale of asset pair |
4 |
min_quote_value |
string |
min quote value of asset pair |
0.0010000000000000 |
base_asset |
asset |
base asset of asset pair |
All AssetPairs
GET /asset_pairs
Response is AssetPair array.
[
{
"id": "d2185614-50c3-4588-b146-b8afe7534da6",
"quote_scale": 8,
"quote_asset": {
"id": "0df9c3c3-255a-46d7-ab82-dedae169fba9",
"symbol": "BTC",
"name": "Bitcoin"
},
"name": "BTG-BTC",
"base_scale": 4,
"min_quote_value":"0.001",
"base_asset": {
"id": "5df3b155-80f5-4f5a-87f6-a92950f0d0ff",
"symbol": "BTG",
"name": "Bitcoin Gold"
}
}
]
Private API
Account
Account
Account represents the state of one account.
Attribute Name |
Type |
Description |
Example |
asset_symbol |
string |
asset symbol of this account |
BTC |
balance |
string |
balance, this is a float number in String format |
10.034 |
locked_balance |
string |
locked balance, this is a float number in String |
10.034 |
Balance of all assets
GET /viewer/accounts
Response is Account Array.
[
{
"asset_symbol": "BTC",
"balance": "0",
"locked_balance": "0"
}
]
Balance of one asset
GET /viewer/accounts/{asset_symbol}
Parameters
Name | Type | Require | Description | Example |
---|---|---|---|---|
asset_symbol | string | true | asset symbol | BTC |
Response is Account object.
{
"asset_symbol": "BTC",
"balance": "0",
"locked_balance": "0"
}
Order
Order
Attribute Name |
Type |
Description |
Example |
id |
number |
id of order |
|
asset_pair_name |
string |
name of asset pair |
|
price |
string |
order price |
|
amount |
string |
order amount |
|
filled_amount |
string |
already filled amount |
|
avg_deal_price |
string |
average price of the deal |
|
side |
string |
order side, one of ASK/BID |
|
state |
string |
order status, one of "FILLED"/"PENDING"/"CANCELLED" |
|
created_at |
string |
created time |
|
updated_at |
string |
updated time |
Get user orders in a asset pair
GET /viewer/orders
Parameters
Name |
Type |
Require |
Description |
Example |
asset_pair_name |
string |
true |
asset pair Name |
BTC-USDT |
page_token |
string |
false |
request page after this page token |
|
side |
string |
false |
order side, one of "ASK"/"BID" |
|
state |
string |
false |
order state, one of "CANCELLED"/"FILLED"/"PENDING" |
|
limit |
string |
false |
default 20; max 200. |
Response is Order array.
{
"data": [{
"id": 10,
"asset_pair_name": "ETH-BTC",
"price": "10.00",
"amount": "10.00",
"filled_amount": "9.0",
"avg_deal_price": "12.0",
"side": "ASK",
"state": "FILLED",
"created_at":"2019-01-29T06:05:56Z",
"updated_at":"2019-01-29T06:05:56Z"
}],
"page_token":"dxzef"
}
Get one order
GET /viewer/orders/{id}
Parameters
Name | Type | Require | Description | Example |
---|---|---|---|---|
id | string | true | order id | 10 |
Response is Order object.
{
"id": 10,
"asset_pair_name": "EOS-BTC",
"price": "10.00",
"amount": "10.00",
"filled_amount": "9.0",
"avg_deal_price": "12.0",
"side": "ASK",
"state": "FILLED",
"created_at":"2019-01-29T06:05:56Z",
"updated_at":"2019-01-29T06:05:56Z"
}
Create Order
POST /viewer/orders
Parameters
Name | Type | Require | Description | Example |
---|---|---|---|---|
asset_pair_name | string | true | asset pair name | BTC-USDT |
side | string | true | order side, one of "ASK"/"BID" | |
price | string | true | order price | |
amount | string | true | must larger than 0 |
Price's scale should less than AssetPair's quote scale Amount's scale should less than AssetPair's base scale
Price * Amount should larger than AssetPair's min_quote_value
Request body should be a json string.
The header of Content-Type
should be application/json
.
Http request example (raw data)
POST /api/v3/viewer/orders HTTP/1.1
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTAwMiwiaWRlbnRpdHkiOm51bGwsInR5cGUiOiJCYXNpYyIsImV4cCI6MTU1MDc0MDM1NCwiaWF0IjoxNTUwNDgxMTU0LCJpc3MiOiJCcm9rZXIiLCJuYmYiOjE1NTA0ODExNTMsInN1YiI6MTAwMn0.4cZZ7hFOyfbROr8EZ6-lu20W--T-P35iSOLMOQuqWp8
Host: b1.run
Connection: close
{"asset_pair_name":"BTC-USDT","side":"ASK","price":"10001","amount":"0.1"}
Response is Order object.
{
"id": 10,
"asset_pair_name": "EOS-BTC",
"price": "10.00",
"amount": "10.00",
"filled_amount": "9.0",
"avg_deal_price": "12.0",
"side": "ASK",
"state": "FILLED",
"created_at":"2019-01-29T06:05:56Z",
"updated_at":"2019-01-29T06:05:56Z"
}
Multiple Create Orders
POST /viewer/orders/multi
The quantity limit of multiple create orders: 10
Notice: If an error occurs in it, all order creations fail.
Parameters
Name | Type | Require | Description | Example |
---|---|---|---|---|
asset_pair_name | string | true | asset pair name | BTC-USDT |
side | string | true | order side, one of "ASK"/"BID" | |
price | string | true | order price | |
amount | string | true | must larger than 0 |
Request body
[{
"asset_pair_name": "EOS-BTC",
"price": "10.00",
"side": "ASK",
"amount": "1"
}]
Response is Order array.
[{
"id": 10,
"asset_pair_name": "EOS-BTC",
"price": "10.00",
"amount": "10.00",
"filled_amount": "9.0",
"avg_deal_price": "12.0",
"side": "ASK",
"state": "FILLED",
"created_at":"2019-01-29T06:05:56Z",
"updated_at":"2019-01-29T06:05:56Z"
}]
Cancel Order
POST /viewer/orders/{id}/cancel
Parameters
Name | Type | Require | Description | Example |
---|---|---|---|---|
id | number | true | order id |
Response is Order object.
{
"id": 10,
"asset_pair_name": "EOS-BTC",
"price": "10.00",
"amount": "10.00",
"filled_amount": "9.0",
"avg_deal_price": "12.0",
"side": "ASK",
"state": "CANCELLED",
"created_at":"2019-01-29T06:05:56Z",
"updated_at":"2019-01-29T06:05:56Z"
}
Cancel All Orders
POST /viewer/orders/cancel
Parameters
Name | Type | Require | Description | Example |
---|---|---|---|---|
asset_pair_name | string | true | asset pair name | BTC-USDT |
Response example.
{
"code":0,
"data": {
"cancelled":[
58272370,
58272377
],
"failed":[]
}
}
Trade
Trade
Attribute Name |
Type |
Description |
id |
number |
id of trade |
asset_pair_name |
string |
asset pair name |
price |
string |
deal price |
amount |
string |
amount |
taker_side |
string |
order side, one of "ASK/BID" |
side |
string |
viewer side, one of "ASK/BID/SELF_TRADING" |
maker_order_id |
number |
maker order id, null if taker_side is equal to side |
taker_order_id |
number |
taker order id, null if taker_side is not equal to side |
maker_fee |
string |
maker fee, null if taker_side is equal to side |
taker_fee |
string |
taker fee, null if taker_side is not equal to side |
created_at |
string |
created time |
Trades of user
GET /viewer/trades
Parameters
Name |
Type |
Require |
Description |
Example |
asset_pair_name |
string |
true |
asset pair name |
BTC-USDT |
page_token |
string |
false |
request page after this page token |
|
limit |
string |
false |
default 20, max 200 |
Response is a Trade array.
{
"code": 0,
"data": [
{
"id": 10854280,
"asset_pair_name": "XIN-USDT",
"price": "70",
"amount": "1",
"taker_side": "ASK",
"maker_order_id": 58284908,
"taker_order_id": 58284909,
"maker_fee": "0.0008",
"taker_fee": "0.07",
"side": "SELF_TRADING",
"inserted_at": "2019-04-16T12:00:01Z"
},
{
"id": 10854263,
"asset_pair_name": "XIN-USDT",
"price": "75.7",
"amount": "12.743149",
"taker_side": "BID",
"maker_order_id": null,
"taker_order_id": 58284888,
"maker_fee": null,
"taker_fee": "0.0025486298",
"side": "BID",
"inserted_at": "2019-04-15T06:20:57Z"
}
],
"page_token":"dxfv"
}
Withdrawal
Withdrawal
Attrubute Name |
Type |
Description |
Example |
id |
number |
id of deposit |
|
customer_id |
string |
id of customer |
|
asset_uuid |
string |
uuid of asset |
|
amount |
string |
amount |
|
state |
string |
deposit status, one of "CONFIRMED"/"UNCONFIRMED" |
|
recipient_id |
string |
id of recipient |
|
completed_at |
string |
completed time |
|
inserted_at |
string |
withdraw time |
|
is_internal |
boolean |
whether is internal withdrawal |
|
target_address |
string |
address of target |
|
note |
string |
content of note |
Get withdrawals of user
Required read permission of wallet
GET /viewer/withdrawals
Parameters
Name |
Type |
Require |
Description |
Example |
page_token |
string |
false |
request page after this page token |
|
limit |
string |
false |
default 50 |
|
kind |
string |
false |
kind: on_chain, off_chain, internal |
|
asset_symbol |
string |
false |
asset symbol |
BTC |
Response is a Withdrawal array.
{
"data": [{
"id": 10,
"customer_id": "10",
"asset_symbol": "ETH",
"amount": "5",
"state": "CONFIRMED",
"note": "2018-03-15T16:13:45.610463Z",
"txid": "0x4643bb6b393ac20a6175c713175734a72517c63d6f73a3ca90a15356f2e967da0",
"completed_at": "2018-03-15T16:13:45.610463Z",
"inserted_at": "2018-03-15T16:13:45.610463Z",
"is_internal": true,
"target_address": "0x4643bb6b393ac20a6175c713175734a72517c63d6f7"
}],
"page_token":"dxvf"
}
Create withdrawal of user
Required write permission of wallet
POST /viewer/withdrawals
Parameters
Name | Type | Require | Description | Example |
---|---|---|---|---|
symbol | string | true | asset symbol | BTC |
target_address | string | true | target address | 3PumsXwUSakZomHXMcY93RrVRJ7PAi2ida |
amount | string | true | amount | 2.52 |
memo | string | false | memo |
Response is a Withdrawal.
{
"code":0,
"message":"",
"data":[
{
"id":1,
"customer_id":7,
"asset_uuid":"50293b12-5be8-4f5b-b31d-d43cdd5ccc29",
"amount":"100",
"recipient":null,
"state":"PENDING",
"is_internal":true,
"note":"asdsadsad",
"kind":"on_chain",
"txid":"asdasdasdsadsadsad",
"confirms":5,
"inserted_at":null,
"updated_at":null,
"completed_at":null,
"commision":null,
"explain":""
}
]
}
Deposit
Deposit
Attrubute Name |
Type |
Description |
Example |
id |
number |
id of deposit |
|
customer_id |
string |
id of customer |
|
asset_symbol |
string |
symbol of asset |
|
amount |
string |
amount |
|
state |
string |
deposit status, one of "CONFIRMED"/"UNCONFIRMED" |
|
memo |
string |
momo |
|
txid |
string |
txid of deposit |
|
confirmed_at |
string |
confirmed time |
|
inserted_at |
string |
deposit time |
|
confirms |
number |
number of confirm |
Deposit of user
Required read permission of wallet
GET /viewer/deposits
Parameters
Name |
Type |
Require |
Description |
Example |
page_token |
string |
false |
request page after this page token |
|
limit |
string |
false |
defalut 50 |
|
kind |
string |
false |
air_drop, big_holder_dividend, default, eosc_to_eos, internal, equally_airdrop, referral_mining, one_holder_dividend, single_customer, snapshotted_airdrop, trade_mining |
|
asset_symbol |
string |
false |
asset symbol |
BTC |
Response example
{
"code": 0,
"page_token": "NQ==",
"data": [{
"id": 6,
"amount": "14.0",
"confirms": 100,
"txid": "513b80e5619155b24fbf0412d59f6256f86b0d69",
"is_internal": false,
"inserted_at": "2018-02-14T11:23:54.000Z",
"updated_at": "2018-09-21T08:28:57.000Z",
"kind": "default",
"memo": "",
"state": "WITHHOLD",
"asset_symbol": "BTS"
}, {
"id": 5,
"amount": "25.0",
"confirms": 100,
"txid": "72e03037d144dae3d32b68b5045462b1049a0755",
"is_internal": false,
"inserted_at": "2018-02-16T11:39:58.000Z",
"updated_at": "2018-11-09T10:20:09.000Z",
"kind": "default",
"memo": "",
"state": "WITHHOLD",
"asset_symbol": "BTS"
}]
}
Get deposite address of one asset of user
Required read permission of wallet
GET /viewer/assets/:asset_symbol/address
Response example
{
"code":0,
"message":"",
"data":{
"id":1,
"chain":"BTC",
"value":"1EVzaFkkNNXq6RJh2oywwJMn8JPiq8ikDi",
"memo":""
}
}
Comments
0 comments
Please sign in to leave a comment.