Overview
Welcome to Developer API Documents
API EntryPoint: (https://www.cbx.one/api/v2/tickers)
Authentication
This document is a description of the CBX Developer API authentication method.
The CBX Developer API is classified into the Public API and the Private API. Calling the Private API requires a token which contains user information to identify the user.
The Token should be included in the Header when requesting. The example is as follows:
curl "https://API_SERVER/viewer/accounts" \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoiT3BlbkFQSSIsInN1YiI6ImNlZTg4YWIwYmM2OTQzNTc4NGI3ZGIwNTQ1ZTg1NjQ3Iiwibm9uY2UiOjE1Mjc2NjUyNjIxNjgzOTEwMDB9.YNpae4v_-OU7h2sknRPa3XPhDcC3p-To1WxbWV4Vpro'
How to get API Key and API Secret
Developers can generate API Keys and API Secrets on the CBX Settings page.
Token generation method
The CBX API token is a JWT Token. Please refer to the official documentation for JWT: https://jwt.io/
Developers need to include the value of sub and nonce in the payload of JWT Token and use their own API Secret as a key to sign the JWT Token.
- sub: (String) User's API Key
- nonce: (Number) A nanosecond unix timestamp, 19 bits. For example: 1527665262168391000. Your timestamp must be within 30 seconds of the api service time or your request will be considered expired and rejected. The same nonce can only be used once.
Signature Algorithm is HS256.
Please set Claim type to MapClaim.
Token generation example
JWT Header
{
"typ": "JWT",
"alg": "HS256"
}
JWT Payload
{
"type": "OpenAPI",
"sub": "cee88ab0bc69435784b7db0545e85647",
"nonce": 1527665262168391000
}
Using private key testsecret to sign.
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoiT3BlbkFQSSIsInN1YiI6ImNlZTg4YWIwYmM2OTQzNTc4NGI3ZGIwNTQ1ZTg1NjQ3Iiwibm9uY2UiOjE1Mjc2NjUyNjIxNjgzOTEwMDB9.YNpae4v_-OU7h2sknRPa3XPhDcC3p-To1WxbWV4Vpro
You can generate a token on the jwt.io website and parse the token for verification.
- Note: when signing, the password cannot be base64 encoded, which may result in failure to pass the Token verification.
Rate Limit
The current limit for each individual IP access is: 500 requests / Every 5 seconds.
The access limit for each user account is: 2000 requests / hour.
For the scenario of quantitative trading, you can contact customer service to adjust the quota.
API Response
This document describes the structure of the API return value.
HTTP CODE
The HTTP CODE in the Developer API response follows the RFC convention . The normal return value code is 2xx, and the error response will return the corresponding code depending on different situation.
Response Struct
{
"data": {
...
},
"errors": [
{
"code": 10001,
"message": "system error"
},
{
"code": 10002,
"message": "system error"
},
]
}
To see the definition of specific error code please refer to Error Description
Data Structs
All numbers in CBX Pro API is a float number in String format
Account
Account represents the state of one asset.
ATTRUBUTE NAME | TYPE | DESCRIPTION | EXAMPLE |
---|---|---|---|
asset_uuid | String | asset uuid of this account | BTC |
balance | String | balance, this is a float number in String fromat | 10.034 |
locked_balance | String | locked balance, this is a float number in String fromat | 10.034 |
Ticker
Ticker is the current state of one market, with 24 hour trading data
ATTRUBUTE NAME | TYPE | DESCRIPTION | EXAMPLE |
---|---|---|---|
market_uuid | String | uuid of market | btceth |
bid | Bid | latest bid | |
ask | Ask | 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 | 100 |
daily_change_perc | String | change percentage in last 24h | 0E-16 |
Bid
ATTRUBUTE NAME | TYPE | DESCRIPTION | EXAMPLE |
---|---|---|---|
price | String | bid price | |
amount | String | bid amount |
Ask
ATTRUBUTE NAME | TYPE | DESCRIPTION | EXAMPLE |
---|---|---|---|
price | String | ask price | |
amount | String | ask amount |
Order
ATTRUBUTE NAME | TYPE | DESCRIPTION | EXAMPLE |
---|---|---|---|
id | String | id of order | |
market_uuid | String | uuid of market | |
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"/"CANCLED" |
Trade
ATTRUBUTE NAME | TYPE | DESCRIPTION | EXAMPLE |
---|---|---|---|
trade_id | String | id of trade | |
market_uuid | String | uuid of market | |
price | String | deal price | |
amount | String | amount | |
taker_side | String | order side, one of "ASK"/"BID" |
Withdrawal
ATTRUBUTE NAME | TYPE | DESCRIPTION | EXAMPLE |
---|---|---|---|
id | String | 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 withdrawl | |
target_address | String | address of target | |
note | String | content of note |
Deposit
ATTRUBUTE NAME | TYPE | DESCRIPTION | EXAMPLE |
---|---|---|---|
id | String | 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" | |
note | String | content of note | |
txid | String | txid of deposit | |
confirmed_at | String | confirmed time | |
inserted_at | String | deposit time | |
confirms | Int | number of confirm |
PageInfo
ATTRUBUTE NAME | TYPE | DESCRIPTION | EXAMPLE |
---|---|---|---|
start_cursor | String | start cursor of pages | |
end_cursor | String | end cursor of pages | |
has_next_page | Boolean | whether has next page | |
has_previous_page | Boolean | whether has previous page |
Error Codes
CODE | DESCRIPTION |
---|---|
10001 | "syntax error" |
10002 | "cannot query fields" |
10003 | "service timeout" |
10004 | "response error" |
10005 | "internal error" |
10006 | "invalid credentials" |
10007 | "params error" |
10008 | "invalid otp" |
10009 | "invalid asset pin" |
10010 | "email or password wrong" |
10011 | "system error" |
10012 | "invalid password reset token" |
10013 | "resouce not found" |
10014 | "Current broker does not support password auth." |
10015 | "Current broker does not support cookie auth." |
10016 | "broker not support login with third-party authentication" |
10017 | "favourite broker market not existed" |
10018 | "invalid token" |
10019 | "failed to create token" |
10022 | "invalid auth schema" |
10023 | "unauthenticated" |
10024 | "invalid otp secret" |
10025 | "missing otp code" |
10026 | "invalid asset pin reset token" |
10026 | "invalid asset pin reset token" |
10027 | "invalid verification state" |
10028 | "invalid otp reset token" |
30000 | "Unknown Error" |
30001 | "Unknown Asset" |
30002 | "Venezia Error" |
30003 | "Invalid Field" |
30004 | "Insufficient Balance" |
30005 | "Perimission Denied" |
30006 | "You are not credible enough to create withdrawal." |
30007 | "Current broker does not support admin withdrawal now." |
30008 | "Memo Not Found" |
30009 | "Withdraw Suspended" |
40001 | "Market not found" |
40002 | "Price too low" |
40003 | "Amount too low" |
40004 | "Filled amount too large" |
40000 | "Unknown Error" |
Public API
Ping
Get Server timestamp
GET /ping
{
"timestamp": 1527665262168391000
}
Tickers
Ticker is the state of a market
Tickers of all market
GET /tickers
Response is a Ticker Collection
[
{
"volume": "190.4925000000000000",
"open": "0.0777371200000000",
"market_uuid": "38dd30bf-76c2-4777-ae2a-a3222433eef3",
"market_id": "ETH-BTC",
"low": "0.0742925600000000",
"high": "0.0789150000000000",
"daily_change_perc": "-0.3789180767180466680525339760",
"daily_change": "-0.0002945600000000",
"close": "0.0774425600000000", // last price
"bid": {
"price": "0.0764777900000000",
"amount": "6.4248000000000000"
},
"ask": {
"price": "0.0774425600000000",
"amount": "1.1741000000000000"
}
}
]
Ticker of one market
GET /markets/{market_id}/ticker
Parameters
NAME | DESCRIPTION | EXAMPLE | REQUIRE |
---|---|---|---|
market_id | market id | ETH-BTC | true |
Response is a Ticker object
{
"volume": "190.4925000000000000",
"open": "0.0777371200000000",
"market_uuid": "38dd30bf-76c2-4777-ae2a-a3222433eef3",
"market_id": "ETH-BTC",
"low": "0.0742925600000000",
"high": "0.0789150000000000",
"daily_change_perc": "-0.3789180767180466680525339760",
"daily_change": "-0.0002945600000000",
"close": "0.0774425600000000", // last price
"bid": {
"price": "0.0764777900000000",
"amount": "6.4248000000000000"
},
"ask": {
"price": "0.0774425600000000",
"amount": "1.1741000000000000"
}
}
Order Book
Order Book is the ask orders and bid orders collection of a market
OrderBook of a market
GET /markets/{market_id}/depth
Parameters
NAME | DESCRIPTION | EXAMPLE | REQUIRE |
---|---|---|---|
market_id | market id | ETH-BTC | true |
Response is a OrderBook
{
"market_id": "EOS-BTC",
"bids": [
{
"price": "42",
"order_count": 4,
"amount": "23.33363711"
}
],
"asks": [
{
"price": "45",
"order_count": 2,
"amount": "4193.3283464"
}
]
}
Market Trade
Trades of a market
Only returns 50 latest trades
GET /markets/{market_id}/trades
Parameters
NAME | DESCRIPTION | EXAMPLE | REQUIRED |
---|---|---|---|
market_id | market id | ETH-BTC | true |
after | ask for the server to return trades after the cursor | dGVzdGN1cmVzZQo= | false |
before | ask for the server to return trades before the cursor | dGVzdGN1cmVzZQo= | false |
first | slicing count | 20 | false |
last | slicing count | 20 | false |
Response is a Trade collection
{
"edges": [
{
"node": {
"taker_side": "BID",
"price": "46.1450000000000000",
"market_id": "EOS-BTC",
"id": 1,
"amount": "0.2465480000000000"
},
"cursor": "dGVzdGN1cmVzZQo="
}
],
"page_info": {
"end_cursor": "dGVzdGN1cmVzZQo=",
"start_cursor": "dGVzdGN1cmVzZQo=",
"has_next_page": true,
"has_previous_page": false
}
}
Market
All Markets
GET /markets
[
{
"uuid": "d2185614-50c3-4588-b146-b8afe7534da6",
"quoteScale": 8,
"quoteAsset": {
"uuid": "0df9c3c3-255a-46d7-ab82-dedae169fba9",
"symbol": "BTC",
"name": "Bitcoin"
},
"name": "BTG-BTC",
"baseScale": 4,
"baseAsset": {
"uuid": "5df3b155-80f5-4f5a-87f6-a92950f0d0ff",
"symbol": "BTG",
"name": "Bitcoin Gold"
}
}
]
Private API
Account
Balance of all assets
GET /viewer/accounts
Response is an Account Collection type.
[
{
"asset_id": "BTC",
"balance": "0",
"locked_balance": "0"
}
]
Order
Get user orders in a market
GET /viewer/orders
Parameters
NAME | DESCRIPTION | EXAMPLE | REQUIRED |
---|---|---|---|
market_id | market id | ETH-BTC | true |
after | ask for the server to return orders after the cursor | dGVzdGN1cmVzZQo= | false |
before | ask for the server to return orders before the cursor | dGVzdGN1cmVzZQo= | false |
first | slicing count | 20 | false |
last | slicing count | 20 | false |
side | order side | one of "ASK"/"BID" | false |
state | order state | one of "CANCELED"/"FILLED"/"PENDING" | false |
Response is Order collection
{
"edges": [
{
"node": {
"id": 10,
"market_id": "ETH-BTC",
"price": "10.00",
"amount": "10.00",
"filled_amount": "9.0",
"avg_deal_price": "12.0",
"side": "ASK",
"state": "FILLED"
},
"cursor": "dGVzdGN1cmVzZQo="
}
],
"page_info": {
"end_cursor": "dGVzdGN1cmVzZQo=",
"start_cursor": "dGVzdGN1cmVzZQo=",
"has_next_page": true,
"has_previous_page": false
}
}
Get one order
[haven't been up online...]
GET /viewer/orders/{order_id}
Parameters
NAME | DESCRIPTION | EXAMPLE | REQUIRED |
---|---|---|---|
order_id | id of order | 45 | true |
Response is Order collection
{
"id": 10,
"market_uuid": "d2185614-50c3-4588-b146-b8afe7534da6",
"price": "10.00",
"amount": "10.00",
"filled_amount": "9.0",
"avg_deal_price": "12.0",
"side": "ASK",
"state": "FILLED"
}
Create Order
POST /viewer/orders
Parameters
NAME | DESCRIPTION | EXAMPLE | REQUIRE |
---|---|---|---|
market_id | market uuid | d2185614-50c3-4588-b146-b8afe7534da6 | true |
side | order side | one of "ASK"/"BID" | true |
price | order price | string | true |
amount | order amount | string, must larger than 0 | true |
Response is an order
{
"id": 10,
"market_uuid": "BTC-EOS",
"price": "10.00",
"amount": "10.00",
"filled_amount": "9.0",
"avg_deal_price": "12.0",
"side": "ASK",
"state": "FILLED"
}
Cancle Order
POST /viewer/orders/{order_id}/cancel
Parameters
NAME | DESCRIPTION | EXAMPLE | REQUIRE |
---|---|---|---|
order_id | id of the order | id1 | true |
Response is an order
{
"id": 10,
"market_uuid": "BTC-EOS",
"price": "10.00",
"amount": "10.00",
"filled_amount": "9.0",
"avg_deal_price": "12.0",
"side": "ASK",
"state": "FILLED"
}
Cancle All Orders
POST /viewer/orders/cancel_all
Parameters
NAME | DESCRIPTION | EXAMPLE | REQUIRE |
---|---|---|---|
market_id | market uuid | d2185614-50c3-4588-b146-b8afe7534da6 | true |
Response is the cancelled orders
{
"id": 10,
"market_uuid": "d2185614-50c3-4588-b146-b8afe7534da6",
"price": "10.00",
"amount": "10.00",
"filled_amount": "9.0",
"avg_deal_price": "12.0",
"side": "ASK",
"state": "FILLED"
}
Trade
Trades of user
GET /viewer/trades
Parameters
NAME | DESCRIPTION | EXAMPLE | REQUIRED |
---|---|---|---|
market_id | market id | ETH-BTC | false |
after | ask for the server to return trades after the cursor | dGVzdGN1cmVzZQo= | false |
before | ask for the server to return trades before the cursor | dGVzdGN1cmVzZQo= | false |
first | slicing count | 20 | false |
last | slicing count | 20 | false |
Response is a Trade collection
{
"edges": [
{
"node": {
"viewer_side": "ASK" // ASK, BID, SELF_TRADING
"taker_side": "BID",
"price": "46.1450000000000000",
"market_id": "ETH-BTC",
"id": 1,
"amount": "0.2465480000000000"
},
"cursor": "dGVzdGN1cmVzZQo="
}
],
"page_info": {
"end_cursor": "dGVzdGN1cmVzZQo=",
"start_cursor": "dGVzdGN1cmVzZQo=",
"has_next_page": true,
"has_previous_page": false
}
}
Withdrawal
Get withdrawals of user
Required read permission of wallet
GET /viewer/withdrawals
Parameters
NAME | DESCRIPTION | EXAMPLE | REQUIRE |
---|---|---|---|
first | slicing count | 20 | false |
after | ask for the server to return withdrawals after the cursor | dGVzdGN1cmVzZQo= | fasle |
Response is a Withdrawal collection
{
"edges": [
{
"node": {
"id": 10,
"customer_id": "10",
"asset_id": "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"
},
"cursor": "dGVzdGN1cmVzZQo="
}
],
"page_info": {
"end_cursor": "dGVzdGN1cmVzZQo=",
"start_cursor": "dGVzdGN1cmVzZQo=",
"has_next_page": true,
"has_previous_page": false
}
}
Deposit
Deposit of user
Required read permission of wallet
GET /viewer/deposits
Parameters
NAME | DESCRIPTION | EXAMPLE | REQUIRE |
---|---|---|---|
first | slicing count | 20 | false |
after | ask for the server to return deposit after the cursor | dGVzdGN1cmVzZQo= | fasle |
Response is a Deposit collection
{
"edges": [
{
"node": {
"id": 10,
"customer_id": "10",
"asset_id": "ETH",
"amount": "5",
"state": "CONFIRMED",
"note": "2018-03-15T16:13:45.610463Z",
"txid": "0x4643bb6b393ac20a6175c713175734a72517c63d6f73a3ca90a15356f2e967da0",
"confirmed_at": "2018-03-15T16:13:45.610463Z",
"inserted_at": "2018-03-15T16:13:45.610463Z",
"confirms": 5
},
"cursor": "dGVzdGN1cmVzZQo="
}
],
"page_info": {
"end_cursor": "dGVzdGN1cmVzZQo=",
"start_cursor": "dGVzdGN1cmVzZQo=",
"has_next_page": true,
"has_previous_page": false
}
}
Comments
0 comments
Please sign in to leave a comment.