Interface Description
Feedback Email
Email: api@bg.exchange
request address
HTTP request address
HOST: https://api.bg.exchange/hk
WEBSOCKET request address
WebSocket private channel (DEPRECATED):wss://ws.bg.exchange
WebSocket public channel (DEPRECATED):wss://ws.bg.exchange/ws
- WebSocket public channel V2:
wss://ws.bg.exchange/v2/ws
- WebSocket private channel V2:
wss://ws.bg.exchange/v2/ws
Response Status
{
"code":1087,
"message": "No data found"
}
{
"code":40001,
"message": "ACCESS_KEY cannot be empty"
}
{
"code":500,
"message":"Internal Server Error"
}
Status Code | Meaning | Example |
---|---|---|
200 | Success Request | |
400 | Bad Request -- The client should not repeat this request without modification. | message string |
401 | Unauthorized -- Your API key is wrong, See Authentication Description | message string |
500 | Internal Server Error -- We had a problem with our server. Try again later. | message string |
Glossary
noun | suggestion |
---|---|
currency | currency, such as BTC, USDT,HKD, USD |
product | trading product, such as BTC_HKD |
Account Information
GET get all account balance information
Get all the trading account information of the user
Speed limit: 10 times/s
Speed limit rules: ApiKey
HTTP request
GET HOST/v1/accounts
Authentication information
For authentication information of private information, please refer to Authentication Instructions
[
{
"available": "10.0001",
"balance": "11.0001",
"currency": "BTC",
"hold": "1.0"
}
]
Parameter name | Parameter description | Type |
---|---|---|
available | Available Quota | string |
hold | Freeze Quota | string |
balance | balance, including the available amount is the sum of the frozen amount | string |
currency | Asset name | string |
GET get single account balance information
Get the trading account information specified by the user
Speed limit: 10 times/s
Speed limit rules: ApiKey
HTTP request
GET HOST/v1/accounts/{currency}
Authentication information
For authentication information of private information, please refer to Authentication Instructions
Parameter name | Parameter description | Required | Data type |
---|---|---|---|
currency | Asset name, for example: BTC | true | string |
{
"available": "10.0001",
"balance": "11.0001",
"currency": "BTC",
"hold": "1.0"
}
Parameter name | Parameter description | Type |
---|---|---|
available | Available Quota | string |
hold | Freeze Quota | string |
balance | balance, including the sum of available quota and frozen quota | string |
currency | Asset name | string |
Transfer Of Funds
POST transfer from fund account to transaction account
Transfer funds from the fund account to the designated trading account
Speed limit: 10 times/s
Speed limit rules: ApiKey
HTTP request
POST HOST/v1/deposits/accounttrue
Authentication information
For authentication information of private information, please refer to Authentication Instructions
{
"amount": 100,
"currency": "HKD"
}
Parameter name | Parameter description | Required | Data type |
---|---|---|---|
amount | transfer amount | true | string |
currency | Transfer asset name | true | string |
{
"amount": 100,
"currency": "HKD"
}
Parameter name | Parameter description | Type |
---|---|---|
amount | transfer amount | string |
currency | Transfer asset name | string |
POST transfer from transaction account to fund account
Transfer the funds from the trading account to the capital account. After the transfer, you can carry out the cash withdrawal operation.
Speed limit: 10 times/s
Speed limit rules: ApiKey
HTTP request
POST HOST/v1/withdrawals/accounttrue
Authentication information
For authentication information of private information, please refer to Authentication Instructions
REQUEST EXAMPLE
{
"amount": 100,
"currency": "HKD"
}
Parameter name | Parameter description | Required | Data type |
---|---|---|---|
amount | transfer amount | true | string |
currency | Transfer asset name | true | string |
{
"amount": 100,
"currency": "HKD"
}
Parameter name | Parameter description | Type |
---|---|---|
amount | transfer amount | string |
currency | Transfer asset name | string |
Product
GET get all known trading products
Get all trading product information
Speed Limit: None
Speed limit rules: None
HTTP request
GET HOST/v1/products
[
{
"product": "ETH_USD",
"base_currency": "ETH",
"quote_currency": "USD",
"display_name": "ETH_USD",
"status": "on",
"maker_fees_rate": "0.01",
"taker_fees_rate": "0.02",
"quote_precision": "5",
"trade_precision": "8",
"amount_precision": "6",
"max_buy_price_rate": "1.000000",
"max_sell_price_rate": "1.000000",
"max_trade_usd_per_order": "",
"min_trade_usd_per_order": "",
"max_market_taker_trade_rate": "1.000000",
"min_market_taker_trade_rate": "1.000000",
"max_market_trade_usd_per_order": "",
"min_market_trade_usd_per_order": ""
}
]
product
: product
base_currency
: base asset name
quote_currency
: quote asset name
display_name
: The display name of the transaction product, which is used as the unique identifier of the transaction product when placing an order
status
: trading product status
- on
: has been launched, the product is open for trading, and orders can be placed and traded normally.
- off
: offline. This product closes all transactions, and orders that already have pending orders will be automatically canceled by the system.
- pause
: Trading is paused, the product closes some trades, but existing pending orders will not be canceled
amount_precision
: transaction currency amount unit precision
quote_precision
: Quotation currency quantity unit precision
trade_precision
: trade currency price unit precision
maker_fees_rate
: Maker fee rate
taker_fees_rate
: taker fee rate
max_buy_price_rate
: The rate at which the limit buy price cannot be higher than the latest price. If the rate exceeds the rate, the order will fail.
max_sell_price_rate
: The rate at which a limit sell order cannot be lower than the latest price. If the ratio is exceeded, the order will fail to be placed.
max_trade_usd_per_order
: The maximum order amount per order at the limit price. The amount will be converted into USD
for calculation.
min_trade_usd_per_order
: The minimum order amount per order at the limit price. The amount will be converted into USD
for calculation.
max_market_taker_trade_rate
: The rate at which the market buy price cannot be higher than the latest price. If the rate exceeds the rate, the order will fail.
min_market_taker_trade_rate
: The rate at which market taker orders cannot be lower than the latest price. If the ratio is exceeded, the order will fail to be placed.
max_market_trade_usd_per_order
: The minimum order amount for a single order at the market price. The amount will be converted into USD
for calculation.
min_market_trade_usd_per_order
: The minimum order amount for a single order at the market price. The amount will be converted into USD
for calculation.
Parameter name | Parameter description | Type |
---|---|---|
product | product | string |
base_currency | base asset | string |
quote_currency | Price asset name | string |
display_name | display name | string |
amount_precision | trading currency amount unit precision | string |
quote_precision | quote currency quantity unit precision | string |
trade_precision | trade currency price unit precision | string |
maker_fees_rate | Seller fee rate | string |
taker_fees_rate | taker fee rate | string |
max_buy_price_rate | The buying price cannot be higher than the latest price (%) | string |
max_sell_price_rate | The selling price cannot be lower than the latest price (%) | string |
max_trade_usd_per_order | The maximum amount of a single order | string |
min_trade_usd_per_order | Single minimum order amount | string |
max_market_taker_trade_rate | The upper limit of taker trade price (%) | string |
min_market_taker_trade_rate | Minimum limit of taker trade price (%) | string |
max_market_trade_usd_per_order | The maximum amount of a single order | string |
min_market_trade_usd_per_order | Single minimum order amount | string |
status | status | string |
GET Get Single Product Details
Get the specified trading product information
Speed Limit: None
Speed limit rules: None
HTTP request
GET HOST/v1/products/{product}
Parameter name | Parameter description | Required | Data type |
---|---|---|---|
product | commodity, for example: ETH_USD | true | string |
[
{
"product": "ETH_USD",
"base_currency": "ETH",
"quote_currency": "USD",
"display_name": "ETH_USD",
"status": "on",
"maker_fees_rate": "0.01",
"taker_fees_rate": "0.02",
"quote_precision": "5",
"trade_precision": "8",
"amount_precision": "6",
"max_buy_price_rate": "1.000000",
"max_sell_price_rate": "1.000000",
"max_trade_usd_per_order": "",
"min_trade_usd_per_order": "",
"max_market_taker_trade_rate": "1.000000",
"min_market_taker_trade_rate": "1.000000",
"max_market_trade_usd_per_order": "",
"min_market_trade_usd_per_order": ""
}
]
product
: product
base_currency
: base asset name
quote_currency
: quote asset name
display_name
: The display name of the transaction product, which is used as the unique identifier of the transaction product when placing an order
status
: trading product status
- on
: has been launched, the product is open for trading, and orders can be placed and traded normally.
- off
: offline. This product closes all transactions, and orders that already have pending orders will be automatically canceled by the system.
- pause
: Trading is paused, the product closes some trades, but existing pending orders will not be canceled
amount_precision
: transaction currency amount unit precision
quote_precision
: Quotation currency quantity unit precision
trade_precision
: trade currency price unit precision
maker_fees_rate
: Maker fee rate
taker_fees_rate
: taker fee rate
max_buy_price_rate
: The rate at which the limit buy price cannot be higher than the latest price. If the rate exceeds the rate, the order will fail.
max_sell_price_rate
: The rate at which a limit sell order cannot be lower than the latest price. If the ratio is exceeded, the order will fail to be placed.
max_trade_usd_per_order
: The maximum order amount per order at the limit price. The amount will be converted into USD
for calculation.
min_trade_usd_per_order
: The minimum order amount per order at the limit price. The amount will be converted into USD
for calculation.
max_market_taker_trade_rate
: The rate at which the market buy price cannot be higher than the latest price. If the rate exceeds the rate, the order will fail.
min_market_taker_trade_rate
: The rate at which market taker orders cannot be lower than the latest price. If the ratio is exceeded, the order will fail to be placed.
max_market_trade_usd_per_order
: The minimum order amount for a single order at the market price. The amount will be converted into USD
for calculation.
min_market_trade_usd_per_order
: The minimum order amount for a single order at the market price. The amount will be converted into USD
for calculation.
Parameter name | Parameter description | Type |
---|---|---|
product | product | string |
base_currency | base asset | string |
quote_currency | Price asset name | string |
display_name | display name | string |
amount_precision | trading currency amount unit precision | string |
quote_precision | quote currency quantity unit precision | string |
trade_precision | trade currency price unit precision | string |
maker_fees_rate | Seller fee rate | string |
taker_fees_rate | taker fee rate | string |
max_buy_price_rate | The buying price cannot be higher than the latest price (%) | string |
max_sell_price_rate | The selling price cannot be lower than the latest price (%) | string |
max_trade_usd_per_order | The maximum amount of a single order | string |
min_trade_usd_per_order | Single minimum order amount | string |
max_market_taker_trade_rate | The upper limit of taker trade price (%) | string |
min_market_taker_trade_rate | Minimum limit of taker trade price (%) | string |
max_market_trade_usd_per_order | The maximum amount of a single order | string |
min_market_trade_usd_per_order | Single minimum order amount | string |
status | status | string |
Public Data V2
GET Kline
Get K-line data. The K-line data is grouped and returned according to the requested granularity, and the most recent 2,000 K-line data can be retrieved.
Speed Limit: None
Speed limit rules: None
HTTP request
GET HOST/public/v2/products/{product}/candles
parameter name | required | type | description |
---|---|---|---|
product | true | string | path parameter commodity, such as: ETH_USD |
interval | false | string | Default time granularity 1min Reference value: [1min, 5min, 15min, 30min, 60min, 4hour, 1day, 1week, 1mon] For details, please refer to K Line Channel Subscription |
from | true | long | start time, request data after this timestamp (seconds) |
to | true | long | end time, the data (seconds) before the requested timestamp |
size | false | int | default 500, maximum 1000[1,1000] |
GET /public/v2/products/ETH_USDT/candles?interval=1min&from=1639584000&to=1639584000&size=100
{
"code": 200,
"data":
[
{
"id": 1690952460,
"open": "3.5334",
"close": "3.5334",
"high": "3.5334",
"low": "3.5334",
"vol": "0",
"count": 0,
"filled_size": "0"
},
{
"id": 1690952520,
"open": "3.5334",
"close": "3.5334",
"high": "3.5334",
"low": "3.5334",
"vol": "0",
"count": 0,
"filled_size": "0"
}
],
"message": "OK"
}
parameter name | type | description |
---|---|---|
close | string | The last transaction price during this K-line period |
high | string | The highest transaction price during this K-line |
low | string | The lowest transaction price during this K-line period |
open | string | The first transaction price during this K-line period |
filled_size | string | turnover |
count | int | The number of transactions during this k-line period |
vol | string | volume |
id | long | unique id |
GET order book
Get Order-book data. Order-book data is sorted by price from high to low, and those with the same price are sorted by time.
Speed Limit: None
Speed limit rules: None
HTTP request
GET HOST/public/v2/products/{product}/orderbook
parameter name | required | type | description |
---|---|---|---|
product | true | string | path parameter commodity, such as: ETH_USD |
interval | false | string | Indicator period Default value 0 Valid value range 0-11 Please refer to Deep Channel Subscription |
GET /public/v2/products/ETH_USDT/orderbook?interval=0
{
"code": 200,
"data":
{
"bids":
[
[
"5", //price
"3.6" //quantity
],
[
"3.5334",
"3"
]
],
"asks":
[],
"seq_id": 18867339
},
"message": "OK"
}
parameter name | type | description |
---|---|---|
seq_id | string | ordered and unique id |
bids | [] | buyer |
asks | [] | seller |
GET 24-hour market data of all currency pairs
Get all product market information
Speed Limit: None
Speed limit rules: None
HTTP request
GET HOST/public/v2/products/overview/tickers
GET /public/v2/products/overview/tickers
{
"code": 200,
"data":
[
{
"id": 1691132221,
"product": "BTC_USDT",
"open": "7.13",
"close": "3.2713",
"high": "7.13",
"low": "2.9313",
"vol": "1979.89",
"count": 0,
"change": "-3.8587",
"seq_id": 22757,
"filled_size": "6916.093957",
"change_percent": "-0.5412"
}
],
"message": "OK"
}
parameter name | type | description |
---|---|---|
close | int | 24-hour latest transaction price |
high | int | The highest transaction price within 24 hours |
low | int | The lowest transaction price within 24 hours |
open | int | The first transaction price started 24 hours ago |
filled_size | string | turnover within 24 hours |
vol | string | Trading volume within 24 hours |
change | string | 24 hour price change |
change_percent | string | 24 hour price change (percentage) |
seq_id | long | unique and ordered id |
count | int | 24-hour transaction count |
product | string | commodity, for example: ETH_USD |
id | long | unique id |
GET single currency pair 24-hour market data
Obtain product market information
Speed Limit: None
Speed limit rules: None
HTTP request
GET HOST/public/v2/products/{product}/ticker
parameter name | required | type | description |
---|---|---|---|
product | true | string | path parameter commodity, such as: ETH_USD |
GET /public/v2/products/ETH_USDT/ticker
{
"code": 200,
"data":
{
"id": 1691132024,
"product": "ETH_USDT",
"open": "7.13",
"close": "3.2713",
"high": "7.13",
"low": "2.9313",
"vol": "1979.89",
"count": 0,
"change": "-3.8587",
"seq_id": 22757,
"filled_size": "6916.093957",
"change_percent": "-0.5412"
},
"message": "OK"
}
parameter name | type | description |
---|---|---|
close | int | 24-hour latest transaction price |
high | int | The highest transaction price within 24 hours |
low | int | The lowest transaction price within 24 hours |
open | int | The first transaction price started 24 hours ago |
filled_size | string | turnover within 24 hours |
vol | string | Trading volume within 24 hours |
change | string | 24 hour price change |
change_percent | string | 24 hour price change (percentage) |
seq_id | long | unique and ordered id |
count | int | 24-hour transaction count |
product | string | commodity, for example: ETH_USD |
id | long | unique id |
GET single currency pair real-time transaction data
Get the latest deals list for products
Speed Limit: None
Speed limit rules: None
HTTP request
GET HOST/public/v2/products/{product}/trades
parameter name | required | type | description |
---|---|---|---|
product | true | string | path parameter commodity, such as: ETH_USD |
size | false | int | size per request: default value 500 maximum value 1000 |
GET /public/v2/products/ETH_USDT/trades?size=1
{
"code": 200,
"data":
[
{
"vol": "0.1",
"ts": 1691029846352,
"price": "5",
"direction": "sell",
"id": 17078143
}
],
"message": "OK"
}
parameter name | type | description |
---|---|---|
direction | string | transaction direction buy / sell |
price | string | transaction price |
vol | string | volume |
id | string | unique id |
ts | long | transaction time stamp |
Currency Information
GET Get all known currencies
Get information list of all currencies
Speed Limit: None
Speed limit rules: None
HTTP request
GET HOST/v1/currencies
[
{
"currency": "ETH",
"min_size": "0",
"status": "on",
"max_precision": "10",
"type": "crypto",
"deposit_status": "on",
"withdraw_status": "on",
"accuracy": "8",
"details": [
{
"network_confirmations": "12",
"sort_order": "3",
"display_name": "ETH",
"deposit_status": "on",
"accuracy": "8",
"withdraw_status": "on"
}
]
}
]
currency
: currency name, which can uniquely identify the currency
accuracy
: fiat deposit and withdrawal accuracy
max_precision
: Maximum precision. Take the range in [18,-18]
- When
max_precision >= 0
, it means that the currency precision is max_precision digits after the decimal point; - When
max_precision < 0
, it means that the precision of the currency is an integer, and the precision is the abs(max_precision) subdivision of 10
min_size
: minimum deposit and withdrawal amount
status
: currency status
type
: Currency type, fiat
is fiat currency, crypto
is digital currency
details
: chain information, only digital currency type will have this part of information
deposit_status
: fiat deposit status
withdraw_status
: fiat withdrawal status
dispaly_name
: display namenetwork_confirmations
: minimum number of network confirmationscurrency
: currency name, which can uniquely identify the currencyaccuracy
: crypto deposit and withdrawal accuracydeposit_status
: crypto deposit statuswithdraw_status
: crypto withdrawal status
Parameter name | Parameter description | Type |
---|---|---|
currency | currency name | string |
accuracy | fiat deposit and withdrawal accuracy | string |
max_precision | maximum precision | string |
min_size | Minimum deposit and withdrawal amount | string |
status | currency status | string |
type | currency type | string |
details | chain information | string |
deposit_status | fiat deposit status | string |
withdraw_status | fiat withdrawal status | string |
GET get single currency information
Get the information of the specified currency
Speed Limit: None
Speed limit rules: None
HTTP request
GET HOST/v1/currencies/{currency}
Parameter name | Parameter description | Required | Data type |
---|---|---|---|
currency | currency name, for example: BTC | true | string |
[
{
"currency": "ETH",
"min_size": "0",
"status": "on",
"max_precision": "10",
"type": "crypto",
"deposit_status": "on",
"withdraw_status": "on",
"accuracy": "8",
"details": [
{
"network_confirmations": "12",
"display_name": "ETH",
"accuracy": "8",
"deposit_status": "on",
"withdraw_status": "on"
}
]
}
]
currency
: currency name, which can uniquely identify the currency
accuracy
: fiat deposit and withdrawal accuracy
max_precision
: Maximum precision. Take the range in [18,-18]
- When
max_precision >= 0
, it means that the currency precision is max_precision digits after the decimal point; - When
max_precision < 0
, it means that the precision of the currency is an integer, and the precision is the abs(max_precision) subdivision of 10
min_size
: minimum deposit and withdrawal amount
status
: currency status
type
: Currency type, fiat
is fiat currency, crypto
is digital currency
details
: chain information, only digital currency type will have this part of information
deposit_status
: fiat deposit status
withdraw_status
: fiat withdrawal status
dispaly_name
: display namenetwork_confirmations
: minimum number of network confirmationscurrency
: currency nameaccuracy
: crypto deposit and withdrawal accuracydeposit_status
: crypto deposit statuswithdraw_status
: crypto withdrawal status
Parameter name | Parameter description | Type |
---|---|---|
currency | currency name | string |
accuracy | fiat deposit and withdrawal accuracy | string |
max_precision | maximum precision | string |
min_size | Minimum deposit and withdrawal amount | string |
status | currency status | string |
type | currency type | string |
details | chain information | string |
deposit_status | fiat deposit status | string |
withdraw_status | fiat withdrawal status | string |
Transactions And Orders
POST to create a new order
Orders can only be placed if your account has sufficient funds.
Speed limit: 10 times/s
Speed limit rules: ApiKey
HTTP request
POST HOST/v1/orders
Authentication information
For authentication information of private information, please refer to Authentication Instructions
{
"product": "BTC_USDT",
"side": "buy",
"type": "limit",
"stp": "dc",
"price": "2.00",
"size": "3.3000000000000000000",
"client_oid": "QZ_2020-jj"
}
common parameters
product
: Must be an existing product. For example BTC_USD
. A list of products is available via products.
side
: buy
buys, sell
sells.
type
: order type
limit
: limit ordermarket
: market order
client_oid
: Optional, default "0", user-defined order number, used for users to manage their own orders. The ID is non-unique, a string type with a length of no more than 32 characters, and must be composed of elements in uppercase and lowercase letters A-Z/a-z, numbers 0-9, underline_, and dash-, and special symbols other than those are not supported
stp
: ie self trade prevention
. BGE prohibits users from dealing with themselves. Users can use the stp
option to specify the order processing strategy when the self-transaction scenario occurs.
dc
: iedecrease and cancel
(default). When matching occurs with the same user order matching, the party with the larger quantity will be executed with thedecrease
command, and the party with the smaller amount will be executed with thecancel
command. decrease or Or the quantity of cancel is the minimum value of the self-dealing matching of two orders.co
: iecancle oldest
, when matching occurs with the same user order matching, the earlier pending order will be executedcancle
command. New orders will continue to execute the normal transaction matching process.cn
: that iscancle newest
, when matching occurs with the same user order matching, the latest order will be executedcancle
command, the earlier pending order still stays in the order book, and the normal transaction matching process will be executed.cb
: that iscancle both
, when the matching of the same user order occurs, the two matching orders will be executedcancle
command.
time_in_force
: optional, transaction command, currently supports GTC
. The default is GTC
limit order parameters
price
: item price
size
: the quantity to buy or sell
market order parameters
size
: expected transaction size. Require side
to be sell
, which means selling at the latest transaction price and expecting the maximum number of items sold.
funds
: Expected transaction amount. side
needs to be buy
, which means buying at the latest transaction price and expecting to spend the maximum amount of assets.
Parameter name | Parameter description | Required | Data type |
---|---|---|---|
product | commodity, for example: ETH_USD | true | string |
side | buy/sell | true | string |
type | limit: limit order/market: market order | true | string |
stp | Self-transaction: dc: reduce and cancel (default) co: cancel the oldest cn: cancel the newest cb: cancel both | true | string |
time_in_force | trade command,GTC | false | string |
funds | Amount of quote currency to use | false | string |
price | price per coin | false | string |
size | Amount to buy or sell | false | string |
client_oid | User-defined order number | false | string |
{
"order_id": 129149436110880967,
"client_oid": "Order_ower_1233"
}
order_id
: the order number generated by BGE
client_oid
: user-defined order number
Parameter name | Parameter description | Type |
---|---|---|
order_id | The order number generated by BGE | string |
client_oid | User-defined order number, default "0" | string |
GET query a single order according to the system order number
Get the specified order information.
Speed limit: 10 times/s
Speed limit rules: ApiKey
HTTP request
GET HOST/v1/orders/{order_id}
Authentication information
For authentication information of private information, please refer to Authentication Instructions
Parameter name | Parameter description | Required | Data type |
---|---|---|---|
order_id | order ID | true | string |
{
"filled_size": "0.0000000000000000000",
"filled_fees": "1.00",
"filled_amount": "0.000000000000000000",
"filled_average_price": "0",
"created_at": "2021-12-14T03:19:15Z",
"updated_at": "2022-01-04T06:57:34Z",
"price": "2.00",
"size": "3.3000000000000000000",
"product": "BTC_USDT",
"order_id": "127738628653088481",
"funds": "0.0000000000000000000",
"type": "limit",
"side": "buy",
"status": "7",
"client_oid": "QZ_2020-jj"
}
status
: transaction status, value range 0-7
- 0: order has been received
- 1: The order has been submitted
- 2: The order is partially executed
- 3: The order has been completely filled
- 4: The order is canceled
- 5: The order has been canceled
- 6: Order transaction failed
- 7: The order is reduced
Parameter name | Parameter description | Type |
---|---|---|
filled_fees | filling fee | string |
filled_size | transaction amount | string |
filled_amount | Amount of transaction | string |
filled_average_price | average transaction price | string |
funds | Amount of quote currency to use | string |
order_id | order number | string |
price | price per unit of base currency | string |
product | product | string |
side | buy/sell | string |
size | Amount of base currency to buy/sell | string |
status | status | string |
type | limit: limit order/market: market order | string |
created_at | created time | string |
updated_at | updated time | string |
client_oid | User-defined order number | string |
GET Query a single order by user-defined order number
When the custom order corresponds to multiple system orders, only the latest system order will be returned.
Speed limit: 10 times/s
Speed limit rules: ApiKey
HTTP request
GET HOST/v1/orders/single/{client_oid}
Authentication information
For authentication information of private information, please refer to Authentication Instructions
Parameter name | Parameter description | Required | Data type |
---|---|---|---|
client_oid | User-defined order number | true | string |
client_oid
: When the custom order corresponds to multiple system orders, only the latest system order will be returned
{
"filled_size": "0.0000000000000000000",
"filled_fees": "1.00",
"filled_amount": "0.000000000000000000",
"filled_average_price": "0",
"created_at": "2021-12-14T03:19:15Z",
"updated_at": "2022-01-04T06:57:34Z",
"price": "2.00",
"size": "3.3000000000000000000",
"product": "BTC_USDT",
"order_id": "127738628653088481",
"funds": "0.0000000000000000000",
"type": "limit",
"side": "buy",
"status": "7",
"client_oid": "QZ_2020-jj"
}
status
: transaction status, value range 0-7
- 0: order has been received
- 1: The order has been submitted
- 2: The order is partially executed
- 3: The order has been completely filled
- 4: The order is canceled
- 5: The order has been canceled
- 6: Order transaction failed
- 7: The order is reduced
Parameter name | Parameter description | Type |
---|---|---|
filled_fees | filling fee | string |
filled_size | transaction amount | string |
filled_amount | Amount of transaction | string |
filled_average_price | average transaction price | string |
funds | Amount of quote currency to use | string |
order_id | order number | string |
price | price per unit of base currency | string |
product | product | string |
side | buy/sell | string |
size | Amount of base currency to buy/sell | string |
status | status | string |
type | limit: limit order/market: market order | string |
created_at | created time | string |
updated_at | updated time | string |
client_oid | User-defined order number | string |
GET Get Transaction Details
Qualified transaction details can be obtained according to different query conditions
Speed limit: 10 times/s
Speed limit rules: ApiKey
HTTP request
GET HOST/v1/fills
Authentication information
For authentication information of private information, please refer to Authentication Instructions
- If
order_id
exists, the transaction details of the order will be searched first, and other parameters will be ignored. - If
order_id
does not exist, all transaction details of the store will be queried in pagination according to the parameter combination. Among them, the maximum value oflimit
is 1000, and the order details of more than 1000 items will not be queried - If
order_id
exists, the query condition ignores client_oid - When
client_oid
corresponds to multiple system orders, only the details of the latest system order will be returned
Parameter name | Parameter description | Required | Data type |
---|---|---|---|
after | is used for pagination. Set end cursor to after date. | false | integer(int64) |
before | is used for pagination. set start cursor to before date | false | integer(int64) |
limit | limits the number of returned results, the default is 100, the maximum is 1000 | false | integer(int32) |
product | product id | false | string |
order_id | order id | false | string |
client_oid | User-defined order number | false | string |
[
{
"product": "BTC_USDT",
"order_id": "12808732377541664481",
"liquidity": "maker",
"price": "19.5600000000000000000",
"size": "0.937686000000000000",
"fee": "0",
"created_at": "2022-01-04T10:17:03Z",
"updated_at": "2022-01-04T10:17:03Z",
"side": "sell"
}
]
Parameter name | Parameter description | Type |
---|---|---|
created_at | order creation time | string |
updated_at | order update time | string |
fee | The fee paid according to the current amount filled in | string |
liquidity | liquidity: marker, taker | string |
order_id | order number | string |
price | price per unit of base currency | string |
product | product number | string |
side | buy/sell | string |
size | Amount of base currency to buy/sell | string |
GET Get current unfinished orders
Get orders that have not been executed
Speed limit: 10 times/s
Speed limit rules: ApiKey
HTTP request
GET HOST/v1/orders
Authentication information
For authentication information of private information, please refer to Authentication Instructions
This interface can query the details of a single order, or multiple orders based on the product
- If
order_id
exists, the order details will be searched first, other parameters will be ignored. - If
order_id
does not exist, all order details will be queried in pagination according to the parameter combination. Among them, the maximum value oflimit
is 1000, and the order details of more than 1000 items will not be queried - If
order_id
exists, the query condition ignores client_oid
Parameter name | Parameter description | Required | Data type |
---|---|---|---|
after | is used for pagination. Set end cursor to after date. | false | integer(int64) |
before | is used for pagination. set start cursor to before date | false | integer(int64) |
limit | limits the number of returned results, the default is 100, the maximum is 1000 | false | integer(int32) |
order_id | order id | false | string |
client_oid | User-defined order number | false | string |
product | product id | false | string |
[
{
"price": "19.5600000000000000000",
"size": "35.447206000000000000",
"product": "BTC_USDT",
"order_id": "128087977541664481",
"funds": "592.668000000000000000",
"type": "limit",
"side": "sell",
"status": "2"
}
]
status
: transaction status, value range 0-7
- 0: order has been received
- 1: The order has been submitted
- 2: The order is partially executed
- 3: The order has been completely filled
- 4: The order is canceled
- 5: The order has been canceled
- 6: Order transaction failed
- 7: The order is reduced
Parameter name | Parameter description | Type |
---|---|---|
funds | Amount of quote currency to use | string |
order_id | order number | string |
price | price per unit of base currency | string |
product | product number | string |
side | buy/sell | string |
size | Amount of base currency to buy/sell | string |
status | status | string |
type | limit: limit order/market: market order | string |
DELETE Cancel a single order according to the system order number
Cancel the specified outstanding order
Speed limit: 10 times/s
Speed limit rules: ApiKey
HTTP request
DELETE HOST/v1/orders/{order_id}
Authentication information
For authentication information of private information, please refer to Authentication Instructions
Parameter name | Parameter description | Required | Data type |
---|---|---|---|
order_id | order id | true | string |
"1277087538632480481"
Parameter name | Parameter description | Data type |
---|---|---|
order_id | order id | string |
DELETE Cancel a single order according to the user-defined order number
A single order can be canceled. If the custom order corresponds to multiple system orders, cancel the latest order. If the cancellation application is successful, the corresponding system order number will be returned.
Speed limit: 10 times/s
Speed limit rules: ApiKey
HTTP request
DELETE HOST/v1/orders/single/{client_oid}
Authentication information
For authentication information of private information, please refer to Authentication Instructions
Parameter name | Parameter description | Required | Data type |
---|---|---|---|
client_oid | User-defined order number | true | string |
"1277087538632480481"
A list of IDs of orders that are about to be canceled
DELETE Cancel all orders by item
This method is an asynchronous method. When the user receives the interface return, it does not mean that all orders have been canceled successfully. After BGE receives the request, it will query all unfilled orders corresponding to the commodity ID under the user account, and cancel these orders asynchronously. Users can query the transaction status of a single order through /orders/{order_id}.
Speed limit: 10 times/s
Speed limit rules: ApiKey
HTTP request
DELETE HOST/v1/orders
product
: the product ID to be revoked, such as "BTC_USD"
Parameter name | Parameter description | Required | Data type |
---|---|---|---|
product | commodity | true | string |
A list of IDs of orders that are about to be canceled
WEBSOCKET
Welcome to the BGE digital currency exchange WebSocket subscription message protocol. The protocol allows you to subscribe to and receive market data, trading information and other relevant information in real time through a WebSocket connection.
Hope this document can help you quickly understand our digital currency exchange WebSocket subscription message protocol. If you have any questions or need further assistance, please do not hesitate to contact our technical support team. I wish you a happy use!
WEBSOCKET basic instructions
WebSocket is a network protocol for full-duplex communication over a single TCP connection, which provides a means of real-time data transfer between a client and a server. By using WebSocket, you can subscribe and receive real-time market data and other information from digital currency exchanges in real time.
Connection instructions
Before subscribing to messages, you need to establish a WebSocket connection. Connection instructions are as follows:
When subscribing to a public channel, use the address of the public service; when subscribing to a private channel, use the address of the private service
- Public channel: The public channel is a channel broadcast to all clients connected to the exchange, including market conditions, transaction depth and other information. For the access method, please refer to: WEBSOCKET PUBLIC V2
- Private channel: A private channel refers to a channel that only pushes personal-related information to specific clients, such as order notifications, account balances, etc. For the access method, please refer to: WEBSOCKET PRIVATE V2
Please select the corresponding service address to connect to public or private channels according to your needs.
Subscription Limits
Each connection can send up to 50 messages in 1s, otherwise the connection will be closed forcibly
In order to maintain the stability and fairness of the connection, we have set a limit on sending messages, and each connection can send up to 50 messages per second. If you send more than 50 messages within 1 second, the connection will be forcibly closed, please be aware of this limit.
keep the connection
We will send ping messages regularly, expecting you to return pong messages as a response, if you do not receive your response for more than 30s, the server will close the connection
At the same time, you need to pay attention to the following situations:
Network problems: If there are network problems, the system will automatically disconnect.
Connection timeout: If the user does not subscribe within 30 seconds after the connection is successful or the server does not push data to the user within 30 seconds after the subscription, the system will automatically disconnect.
In order to ensure the liveness of the connection, we will regularly send ping messages in JSON format to the client: {"ping": timestamp}
. You need to send a {"pong": timestamp}
text message promptly after receiving the ping message to indicate that the connection is alive. If we do not receive a response from you within 30 seconds, we will close the connection and recommend the following:
Reply a
{"pong": timestamp}
immediately after receiving a{"ping": timestamp}
message.Expect a literal string
{"ping": timestamp}
as heartbeat message. If not received within N seconds, issue an error or reconnect.The timestamp in the pong message you reply should use the timestamp in the received ping message.
ping message example
{
"ping": 1635065532000
}
pong message example
{
"pong": 1635065532000
}
request error
Regardless of the private channel or public channel, when the server fails to process the request you send, the server will return a unified error message, which is convenient for the client to process.
Error messages mainly consist of two parts: error code and message. Codes are generic, but messages may vary.
For error codes and messages, please refer to: Status Code Comparison Table, Other Error Status Code Comparison Table
Error Message Response Parameter Description
parameter name | type | description |
---|---|---|
event | string | event name sent by user event list |
msg | string | error message |
code | int | status code status code comparison table |
Description of common error codes
Error code
400
: Usually you need to check whether the request parameters you provide are correct, or whether there are required parameters that are not filled.Error code
401
: Usually you need to ensure that you have received a successful login response, and this error will occur when you subscribe to a private channel without logging in.Error code
500
: It is usually an internal server error. It is recommended that you try again later.
Bad request example
1
The request structure used in this example is wrong, please replace it with your actual request parameters.
{
"event": "sub",
"para": {
"biz": "market",
"type": "percent10",
"product": "ETH_USDT"
},
"zip": true
}
Bad request response example
1
{
"event": "sub",
"code": "400",
"msg": "Invalid request: {\"event\":\"sub\",\"para\":{\"biz\":\"market\",\"type\":\"percent10\ ",\"pairCode\":\"ETH_USDT\"},\"zip\":true}"
}
Bad request example
2
The access_key value used in this example is empty, please ensure that the required parameters are filled.
{
"event": "login",
"params": {
"type": "api",
"access_key": "",
"access_sign": "sign",
"access_timestamp": 14000000000
}
}
Bad request response example
2
{
"event": "login",
"code": 40001,
"msg": "ACCESS_KEY cannot be empty"
}
WEBSOCKET public channel V2
sequence number seq_id
description
seq_id
is a serial number of the exchange market. When a user uses one or more WebSockets to connect to the same channel, in addition to the real-time transaction data, he will receive data pushes with the same serial number, and the user needs to handle the duplication by himself. data, aseq_id
can be used to build a sequence of messages, which will allow the user to detect packet loss and ordering of messages.seq_id
is a monotonically increasing number with a minimum value of 0.
K-line channel
Subscribe or request to get K-line (the latest K-line) data push
K-line chart interval parameters:
min -> minute; hour -> hour; day -> day; week -> week; mon -> month
- 1min
- 5min
- 15min
- 30min
- 60min
- 4 hours
- 1 day
- 1week
- 1mon
Field Description:
id
message unique idopen
the first transaction price during this K-line periodclose
the last transaction price during this K-line periodlow
the lowest transaction price during this K-line periodhigh
is the highest transaction price during this K-line periodfilled_size
the transaction volume during this K-linevol
is the trading volume during this K-lineseq_id
unique and ordered idcount
is the number of transactions during this K-line periodinterval
K-line intervalproduct
trading pair
subscription
request example
{
"event": "sub",
"biz": "market",
"type": "candles",
"product": "BTC_USDT",
"interval": "15min",
"zip": false
}
Response example
{
"biz": "market",
"type": "candles",
"ts": 1666851880448,
"code": 200,
"status": "OK",
"event": "sub",
"product": "BTC_USDT",
"interval": "15min"
}
unsubscribe
request example
{
"event": "unsub",
"biz": "market",
"type": "candles",
"product": "BTC_USDT",
"interval": "15min",
"zip": false
}
Response example
{
"biz": "market",
"type": "candles",
"ts": 1666851880448,
"code": 200,
"status": "OK",
"event": "unsub",
"product": "BTC_USDT",
"interval": "15min"
}
Push data
Push data example
{
"id": "1689144300",
"biz": "market",
"type": "candles",
"data":
{
"id": 1689144300,
"open": "3.7366",
"close": "3.7366",
"high": "3.7366",
"low": "3.7366",
"filled_size": "0",
"vol": "0",
"count": 0,
"seq_id": 112588635
},
"product": "BTC_USDT",
"interval": "15min"
}
request data
Parameter Description:
id
the unique id of each candlestick message- ix timestamp of
from
start time - ix timestamp of
to
end time interval
K-line intervalproduct
trading pair
Get the K-line data request example of the specified range
{
"event": "req",
"biz": "market",
"type": "candles",
"product": "BTC_USDT",
"interval": "15min",
"zip": false,
"from": 1687561511,
"to": 1688641511
}
Get the K-line data response example in the specified range
{
"biz": "market",
"type": "candles",
"product": "BTC_USDT",
"ts": 1690252632272,
"code": 200,
"status": "OK",
"data":
[
{
"id": 1688398200,
"open": "3.3706",
"close": "3.3706",
"high": "3.3706",
"low": "3.3706",
"filled_size": "0",
"vol": "0",
"count": 0
},
{
"id": 1688399100,
"open": "3.3706",
"close": "3.3706",
"high": "3.3706",
"low": "3.3706",
"filled_size": "0",
"vol": "0",
"count": 0
}
],
"event": "req",
"interval": "15min"
}
Close channel
Subscribe to obtain real-time transaction incremental push data of products
Get the latest transaction data, and push the transaction data when there is transaction data. Each push may contain multiple transaction data.
Field Description:
id
message unique idts
transaction timestampdirection
transaction directionprice
transaction pricevol
volume
subscription
request example
{
"event": "sub",
"biz": "market",
"type": "fills",
"product": "BTC_USDT",
"zip": false
}
Response example
{
"biz": "market",
"type": "fills",
"product": "BTC_USDT",
"ts": 1690165577416,
"code": 200,
"status": "OK",
"event": "sub"
}
unsubscribe
request example
{
"event": "unsub",
"biz": "market",
"type": "fills",
"product": "BTC_USDT",
"zip": false
}
Response example
{
"biz": "market",
"type": "fills",
"ts": 1666851880448,
"code": 200,
"status": "OK",
"event": "unsub",
"product": "BTC_USDT"
}
Push data
Push data example
{
"id": "310529",
"biz": "market",
"type": "fills",
"data":
[
{
"vol": "0.79",
"ts": 1689152279117,
"price": "3.4134",
"direction": "buy",
"id": 310529000
}
],
"product": "BTC_USDT"
}
Deep Channel
Subscribe to obtain product order book incremental push data
Push once every 500 milliseconds at the fastest, and also push when no event is triggered, bids and asks may be empty arrays if there is no data in the handicap
OrderBook subscription interval parameters: [The current gear supports the maximum precision, the current gear supports the maximum depth]:
- 0 : [0.0000000000000000001, 150]
- 1 : [0.00001, 150]
- 2 : [0.0001, 150]
- 3 : [0.001, 150]
- 4 : [0.01, 150]
- 5 : [0.1, 150]
- 6 : [0.0000000000000000001, 20]
- 7 : [0.00001, 20]
- 8 : [0.0001, 20]
- 9 : [0.001, 20]
- 10 : [0.01, 20]
- 11 : [0.1, 20]
Explanation: interval=5, the buyer's price in bids pushed can only be accurate to one decimal place, and the maximum array size of bids is 150
Field Description:
id
message unique idbiz
line of businesstype
typedata.seq_id
is ignoreddata.bids
buyersdata.bids[][0]
bid pricedata.bids[][1]
number of buyersdata.asks
sellerdata.asks[][0]
ask pricedata.asks[][1]
number of sellersdata.product
trading pairdata.interval
slots
subscription
request example
{
"event": "sub",
"biz": "market",
"type": "orderbook",
"product": "BTC_USDT",
"interval": "0",
"zip": false
}
Response example
{
"biz": "market",
"type": "orderbook",
"ts": 1666851880448,
"code": 200,
"status": "OK",
"event": "sub",
"product": "BTC_USDT",
"interval": 0
}
unsubscribe
request example
{
"event": "unsub",
"biz": "market",
"type": "orderbook",
"product": "BTC_USDT",
"interval": "0",
"zip": false
}
Response example
{
"biz": "market",
"type": "orderbook",
"ts": 1666851880448,
"code": 200,
"status": "OK",
"event": "unsub",
"product": "BTC_USDT",
"interval": 0
}
Push data
Push data example
{
"id": "1689143926",
"biz": "market",
"type": "orderbook",
"data":
{
"seq_id": 112588640, //ordered and unique id
"bids": //buyer
[
[
"3.7366", //price
"0.66" //quantity
],
[
"3.6866",
"0.98"
],
[
"3.4666",
"0.33"
],
[
"3.3766",
"0.76"
],
[
"3.3666",
"0.7"
],
[
"3.1966",
"0.75"
],
[
"3.1766",
"0.06"
],
[
"3.0666",
"0.91"
],
[
"3.0266",
"0.73"
]
],
"asks": //Seller
[
[
"3.9966", //price
"0.9" //quantity
]
]
},
"product": "BTC_USDT",//trading pair
"interval": "0"
}
Deep depth channel
Subscribe to obtain product depth map incremental push data
Explanation: Each buy and sell order takes up to 200 orders within 10% of the average price, sell 1 order within 10% of the upward price fluctuation, and buy 1 order within 10% downward fluctuation
Push once every 500 milliseconds at the fastest, and also push when no event is triggered, bids and asks may be empty arrays if there is no data in the handicap
Field Description:
id
message unique idbiz
line of businessseq_id
is ignoredtype
typedata.bids
buyer depthdata.bids[][0]
Bid depth pricedata.bids[][1]
the number of bids in depthdata.asks
depth of asksdata.asks[][0]
deep ask pricedata.asks[][1]
depth number of asksdata.seq_id
ordered and unique iddata.product
trading pair
subscription
request example
{
"event": "sub",
"biz": "market",
"type": "percent10",
"product": "BTC_USDT",
"zip": false
}
Response example
{
"biz": "market",
"type": "percent10",
"ts": 1666851880448,
"code": 200,
"status": "OK",
"event": "sub",
"product": "BTC_USDT"
}
unsubscribe
request example
{
"event": "unsub",
"biz": "market",
"type": "percent10",
"product": "BTC_USDT",
"zip": false
}
Response example
{
"biz": "market",
"type": "percent10",
"product": "BTC_USDT",
"ts": 1690193555943,
"code": 200,
"status": "OK",
"event": "unsub"
}
Push data
Push data example
{
"id": "1689143539", //The unique id of the message
"biz": "market",
"seq_id": 112588640, //ordered and unique id
"type": "percent10", //business type
"data":
{
"bids": //buyer
[
[
"3.8646667", //price
"0" //quantity
]
],
"asks": //Seller
[
[
"3.8685333", //price
"0" //quantity
],
[
"3.8704666",
"0"
]
],
"seq_id": 112588640
},
"product": "BTC_USDT"
}
Quote channel
Obtain product 24-hour ticker incremental push data
Field Description:
id
message unique idopen
started the first transaction price 24 hours agoclose
24 hours latest transaction pricelow
The lowest transaction price within 24 hourshigh
The highest transaction price within 24 hoursfilled_size
turnover within 24 hoursvol
volume in 24 hoursseq_id
unique and ordered idcount
24-hour transaction countchange
24 hour price changechange_percent
24h price change (percentage)
subscription
request example
{
"event": "sub",
"biz": "market",
"type": "ticker",
"product": "BTC_USDT",
"zip": false
}
Response example
{
"biz": "market",
"type": "ticker",
"ts": 1666851880448,
"code": 200,
"status": "OK",
"event": "sub",
"product": "BTC_USDT"
}
unsubscribe
request example
{
"event": "unsub",
"biz": "market",
"type": "ticker",
"product": "BTC_USDT",
"zip": false
}
Response example
{
"biz": "market",
"type": "ticker",
"ts": 1689946788754,
"code": 200,
"status": "OK",
"event": "unsub",
"product": "BTC_USDT"
}
Push data
Push data example
{
"id": "1689144487",
"biz": "market",
"type": "ticker",
"product": "BTC_USDT",
"data":
[
{
"id": 1689144487,
"seq_id": 112588640,
"open": "3.7366",
"close": "3.7366",
"high": "3.7366",
"low": "3.7366",
"filled_size": "0",
"vol": "0",
"count": 0,
"change": "0",
"change_percent": "0"
}
]
}
Request the latest market data for the specified trading pair
Get the latest market data request example for a specified trading pair
{
"event": "req",
"biz": "market",
"type": "ticker",
"product": "BTC_USDT",
"zip": false
}
Example of getting the latest market data response for a specified trading pair
{
"biz": "market",
"type": "ticker",
"ts": 1689133337870,
"code": 200,
"status": "OK",
"data":
{
"id": 1689133336,
"seq_id": 112588640,
"open": "3.7366",
"close": "3.7366",
"high": "3.7366",
"low": "3.7366",
"filled_size": "0",
"vol": "0",
"count": 0,
"change": "0",
"change_percent": "0"
},
"event": "req",
"product": "BTC_USDT"
}
Public channel Request field description
Parameter name | Type | Mandatory | Description | Reference value |
---|---|---|---|---|
event | string | yes | request event | event |
biz | string | yes | line of business | line of business |
type | string | yes | business type | type |
product | string | yes | trading pair | BTC_USDT |
interval | string | no | frequency | 1min |
zip | bool | yes | whether to enable gzip | true, false |
Response field description of public channel
Parameter name | Type | Mandatory | Description | Reference value |
---|---|---|---|---|
event | string | yes | request event | event |
biz | string | yes | line of business | line of business |
type | string | yes | business type | type |
product | string | yes | trading pair | BTC_USDT |
interval | string | no | frequency | 1min |
code | int | yes | error code | |
status | string | yes | error code status | can be ignored |
ts | long | yes | unix timestamp | ignorable |
data | json | no | business data | refer to specific business data instructions |
List of public channel events
Event Name | Type | Description |
---|---|---|
sub | string | Subscribe to events, initiated by the client |
unsub | string | unsubscribe event, initiated by the client |
req | string | request data event, initiated by the client |
Public Channel Biz List
Biz Name | Type | Description |
---|---|---|
market | string | spot market |
List of Public Channel Types
Type Name | Type | Description |
---|---|---|
fills | string | transaction data |
candles | string | candlestick data |
orderbook | string | order book |
ticker | string | 24 hour ticker |
percent10 | string | depth |
WEBSOCKET private channel V2
Private channel login authentication
Login authentication is required before subscribing to a private channel. Only authenticated users can subscribe to the user's asset information and order status change information.
Note: If no login authentication operation is performed, subscribing to a private channel will return an error message
Login request example
{
"event": "login",
"params": {
"type": "api",
"access_key": "de0535f81d51c998b7fbcf00f189f294",
"access_sign": "sign",
"access_timestamp": 14000000000
}
}
Login success response example status code comparison table
{
"ts": 1690364037503,
"code": 200,
"status": "OK",
"event": "login"
}
Login failure response example Please refer to the general error description
Login request parameter description
parameter name | required | type | description |
---|---|---|---|
params.type | yes | string | authentication method: api :apiKey authentication; |
params.access_key | Yes | string | Authentication Description |
params.access_sign | Yes | string | Authentication Description |
params.access_timestamp | yes | long | authentication description |
event | yes | string | event name event list |
Login response parameter description
parameter name | type | description |
---|---|---|
event | string | event name event list |
status | string | status information can be ignored |
code | int | status code status code comparison table |
ts | long | unix timestamp |
Private channel assets
Subscriber's asset changes will be pushed only when there is data update. Currently only supports subscription by product.
Please refer to Common Request Parameter Description and General Response Parameter Description for request and response parameter description
Subscribe to asset data
Subscription request example
{
"event": "sub",
"biz": "exchange",
"type": "assets",
"product": "ETH_USDT",
"zip": false
}
Subscription success response example
{
"biz": "exchange",
"type": "assets",
"product": "ETH_USDT",
"ts": 1690357632710,
"code": 200,
"status": "OK",
"event": "sub"
}
Asset push data example, this example is just to illustrate the data structure, the actual push data may only contain asset information of one currency
{
"biz": "exchange",
"type": "assets",
"product": "ETH_USDT",
"data":
[
{
"currency": "USDT",
"available": "999970.5238",
"hold": "29.4762"
},
{
"currency": "ETH",
"available": "999970.5238",
"hold": "29.4762"
}
]
}
parameter name | type | description |
---|---|---|
product | string | product name/trading pair |
$data.currency | string | currency name |
$data.available | string | available quantity |
$data.hold | string | hold amount |
Request the user's asset data for a single trading pair
Request a single trading pair asset data example
{
"event": "req",
"biz": "exchange",
"type": "assets",
"product": "BTC_USDT",
"zip": false
}
Request a single transaction pair asset data response example
{
"biz": "exchange",
"type": "assets",
"product": "BTC_USDT",
"ts": 1690357632710,
"code": 200,
"status": "OK",
"event": "req",
"data":
[
{
"currency": "USDT",
"available": "999970.5238",
"hold": "29.4762"
},
{
"currency": "BTC",
"available": "999970.5238",
"hold": "29.4762"
}
]
}
parameter name | type | description |
---|---|---|
product | string | product name/trading pair |
ts | long | unix timestamp |
$data.currency | string | currency name |
$data.available | string | available quantity |
$data.hold | string | hold amount |
Private Channel Orders
The status change of the subscription user's order will be pushed only when there is data update. Currently supports order status change subscription for all trading pairs. Supports asynchronous query of the user's current entrusted order data for a single trading pair.
Please refer to Common Request Parameter Description and General Response Parameter Description for request and response parameter description
Note: The order data supports subscribing to the full amount of trading pairs. When subscribing to orders of all trading pairs at once, please note that the product
parameter uses all
(ignoring case)
Subscription order transaction pair order data
Subscribe to order data for all trading pairs
Subscription order trading pair order request example
{
"event": "sub",
"biz": "exchange",
"type": "orders",
"product": "ETH_USDT",
"zip": false
}
Subscribe to all trading pairs order request example
{
"event": "sub",
"biz": "exchange",
"type": "orders",
"product": "all",
"zip": false
}
Subscription order transaction pair order response success example
{
"biz": "exchange",
"type": "orders",
"product": "ETH_USDT",
"ts": 1690363716709,
"code": 200,
"status": "OK",
"event": "sub"
}
Subscribe to all transaction pairs order response success example
{
"biz": "exchange",
"type": "orders",
"product": "all",
"ts": 1690363716709,
"code": 200,
"status": "OK",
"event": "sub"
}
Subscribe to all trading pairs order data failure response example error code comparison table
{
"biz": "exchange",
"type": "orders",
"product": "all",
"ts": 1690362052646,
"code": 500,
"status": "FAIL",
"event": "sub"
}
Subscription order trading pair push order data example
{
"biz": "exchange",
"type": "orders",
"product": "BTC_USDT",
"data": [
{
"orders_id": "179577241915696235",
"product": "BTC_USDT",
"side": "buy",
"price": "3.53340000",
"size": "1.00000000",
"filled_amount": "0.00000000",
"funds": "1.00000000",
"filled_size": "0.00000000",
"type": "limit",
"status": "1",
"client_oid": ""
}
]
}
Subscribe to all trading pairs to push orders and send data examples
{
"biz": "exchange",
"type": "orders",//Note that this is different from a single trading pair
"product": "all",//Note that this is different from a single trading pair
"data":
[
//....Structure reference single transaction pair push order data example
]
}
*Request a single transaction pair for the current entrusted order data, if the request fails, a failed response will be returned. *
Request the user's single transaction pair current entrusted order data example
{
"event": "req",
"biz": "exchange",
"type": "orders",
"product": "BTC_USDT",
"zip": false
}
An example of a successful response to requesting a single transaction from the user for the current entrusted order data
{
"biz": "exchange",
"type": "orders",
"product": "BTC_USDT",
"ts": 1690375715106,
"code": 200,
"status": "OK",
"data":
[
//....Structure reference single transaction pair push order data example
],
"event": "req"
}
Parameter name | Parameter description | Type |
---|---|---|
orders_id | order ID | string |
product | commodity | string |
side | buy/sell | string |
price | price per unit of base currency | string |
size | Amount of base currency to buy/sell | string |
filled_amount | filled amount | string |
funds | Amount of quote currency to use | string |
filled_size | transaction amount | string |
type | limit: limit order/market: market order/ | string |
status | status | string |
client_oid | default "0", user-defined order number | string |
status
: transaction status, value range 0-7
- 0: order has been received
- 1: The order has been submitted
- 2: The order is partially executed
- 3: The order has been completely filled
- 4: The order is canceled
- 5: The order has been canceled
- 6: Order transaction failed
- 7: The order is reduced
Private channel general request parameter description
parameter name | required | type | description |
---|---|---|---|
biz | is | string | subscription module type |
type | yes | string | subscription business type |
product | yes | string | product information |
event | yes | string | event name event list |
zip | yes | bool | whether to enable gzip |
Private channel general response parameter description
Parameter name | Type | Mandatory | Description | Reference value |
---|---|---|---|---|
event | string | yes | request event | event |
biz | string | yes | line of business | line of business |
type | string | yes | business type | type |
product | string | yes | trading pair | BTC_USDT |
code | number | yes | error code | |
status | string | yes | error code status | |
ts | long | yes | unix timestamp |
Private channel event list
Event Name | Type | Description |
---|---|---|
sub | string | Subscribe to events, initiated by the client |
login | string | login event, initiated by the client |
unsub | string | unsubscribe event, initiated by the client |
req | string | request event, initiated by the client |
Private Channel Biz List
Biz Name | Type | Description |
---|---|---|
exchange | string | spot transaction |
Private Channel Type List
Type Name | Type | Description | Whether to support data push subscription for all trading pairs |
---|---|---|---|
assets | string | asset changes | no |
orders | string | order status change | yes |
Authentication information
Each user can create up to 50 APIKeys;
Do not disclose your APIKey to anyone else to avoid loss of assets. It is recommended to bind the APIKey to an IP address for better security of your account. Multiple IP addresses are separated in English, and a maximum of 10 IP addresses are supported. API not bound to an IP address is only valid for 180 days;
Please note that binding an APIKey to a third-party platform may pose security risks that you should act with caution;
To access the private information interface, the following request headers will have to be added
Header Name | Meaning |
---|---|
ACCESS-KEY | API KEY created by the user on the BGE platform |
ACCESS-SIGN | Signature for the request, which is generated based on the user-created API KEY to authenticate the request’s legitimacy ACCESS-SING generation algorithm |
ACCESS-TIMESTAMP | Request time, usually the current timestamp Example:2022-01-08T07:19:56.339Z ,or a millisecond timestamp |
ACCESS-SING generation algorithm
requestPath
: Consistent with the path in the documentation, e.g. /v1/products
queryString
: List of request parameters. Note: Parameters needs to be orderly arranged. See remarks
params
: When the request is GET
or DELETE
or WEBSOCKET channel for authentication, fill in ""
Parameter Name | Parameter Type | Description |
---|---|---|
method | string | GET or POST or DELETE;"" when calculating ws sign |
secretKey | string | API KEY name created by the user on BGE |
requestPath | string | Request path; "" for ws sign calculation |
queryString | string | Request parameter; "" for ws sign calculation |
params | string | Transfer data content; "" for ws sign calculation |
timestamp | string | Current timestamp e.g.2022-01-08T07:19:56.339Z ,or millisecond timestamp |
Sign http request
String timestamp=OpenAPiUtils.createTimestamp();
String sign=OpenAPiUtils.createSign(OpenAPiUtils.POST,
"43767b4dec6e78e07c81f89af47018dc3ab57585721bf57a389f7637a9d0506b",
"/v1/accounts",
"",
s,timestamp);
Sign web socket request
String timestamp=OpenAPiUtils.createTimestamp();
String sign=OpenAPiUtils.createSign("","43767b4dec6e78e07c81f89af47018dc3ab57585721bf57a389f7637a9d0506b","","","",timestamp);
Generation algorithm tool class
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.HmacUtils;
public class OpenAPiUtils {
public static final String GET = "GET";
public static final String POST = "POST";
public static final String DELETE = "DELETE";
public static final Gson gson = new Gson();
public static String createTimestamp() {
return Instant.now().toString();
}
/**
* 获取当前时间戳 例:2022-01-08T07:19:56.339Z
* @return
*/
public static String createTimestamp() {
return Instant.now().toString();
}
/**
* sign
* @param method POST or GET or DELETE
* @param secretKey for example:HKBGE-xxxxx
* @param requestPath for example:/v1/orders
* @param queryString Request parameters
* @param body string empty when method is `GET`
* @param timestamp for example:2022-01-08T07:19:56.339Z
* @return string
*/
public static String createSign(String method, String secretKey, String requestPath, String queryString, String body, String timestamp) {
String sign = "";
method = method.toUpperCase();
if (timestamp == null) {
timestamp = Instant.now().toString();
}
if (method.equals("POST")) {
sign = generate(timestamp, method, requestPath, queryString, body, secretKey, "HmacSHA256");
}
if (method.equals("GET") || method.equals("DELETE")) {
sign = generate(timestamp, method, requestPath, queryString, "", secretKey, "HmacSHA256");
}
if ("".equalsIgnoreCase(method)) {
sign = generate(timestamp, method, requestPath, queryString, "", secretKey, "HmacSHA256");
}
return sign;
}
public static String generate(final String timestamp, String method, final String requestPath,
String queryString, String body, final String secret, final String alg) {
body = StringUtils.defaultIfBlank(body, StringUtils.EMPTY);
queryString = StringUtils.isEmpty(queryString) ? "" : "?" + queryString;
final String preHash = timestamp + method + requestPath + queryString + body;
return encodeBase64(alg, secret, preHash);
}
public static String encodeBase64(final String alg, final String secret, final String data) {
Validate.notNull(alg, "SignatureAlgorithm cannot be null.");
Validate.notNull(data, "Signing Secret cannot be null.");
switch (alg) {
case "HmacMD5":
return Base64.encodeBase64String(new HmacUtils("HmacMD5", secret).hmac(data));
case "HmacSHA1":
return Base64.encodeBase64String(new HmacUtils("HmacSHA1", secret).hmac(data));
case "HmacSHA224":
return Base64.encodeBase64String(new HmacUtils("HmacSHA224", secret).hmac(data));
case "HmacSHA256":
try {
return Base64.encodeBase64String(new HmacUtils("HmacSHA256",
secret.getBytes("UTF-8")).hmac(data.getBytes("UTF-8")));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e.getMessage());
}
case "HmacSHA384":
return Base64.encodeBase64String(new HmacUtils("HmacSHA384", secret).hmac(data));
case "HmacSHA512":
return Base64.encodeBase64String(new HmacUtils("HmacSHA512", secret).hmac(data));
default:
throw new IllegalArgumentException("The '" + alg.name() + "' algorithm cannot be used for signing.");
}
}
}
When calculating data signatures, the parameters must be transmitted in the same order as the signature string, and the queryString must not start with “?” or end with “&” to avoid authentication failure. For example:
when calculating the signature for GET "http://api.bg.exchange/hk/v1/demo?a=2&b=3"
- Correct: preHash = ... + "a=2&b=3" + ...;
- Incorrect: preHash = ... + "b=3&a=2" + ...;
- Incorrect: preHash = ... + "?b=3&a=2" + ...;
- Incorrect: preHash = ... + "b=3&a=2&" + ...;
Add the api key, sign and timestamp generated by the user on BGE to the http request header.
Fill in the HTTP HEADERS in requests
RequestBuilders.post("/openapi/exchange/BTC_USDT/orders")
.header("ACCESS-KEY", "HKBGE-6fc437d24902cce8635806b6d79921f2")
.header("ACCESS-SIGN", sign)
.header("ACCESS-TIMESTAMP", timestamp)
.characterEncoding("UTF-8")
.content(s.getBytes(StandardCharsets.UTF_8))
.contentType(MediaType.APPLICATION_JSON_VALUE)
Data Dictionary
WEBSOCKET error code comparison table
Error code | Instructions |
---|---|
200 | Success |
400 | Invalid Request |
401 | Not logged in |
500 | System error, please try again later |
User authentication error code comparison table
Error code | Instructions |
---|---|
40001 | ACCESS_KEY cannot be empty |
40002 | ACCESS_SIGN cannot be empty |
40003 | ACCESS_TIMESTAMP cannot be empty |
40005 | Invalid ACCESS_TIMESTAMP |
40006 | Invalid ACCESS_KEY |
40008 | Request timestamp expired |
40010 | API verification failed |
40012 | Invalid API User |
40013 | User banned |
40014 | User frozen |
40015 | Invalid IP request |
40016 | API_KEY has expired |
Business error code comparison table
amount limit value
is the upper and lower limit of the transaction amount/quantity configured by the product. In order to protect the market stability, BGE has limited the transaction limit according to the real-time market conditions, and the specific amount will fluctuate in real time with the market transaction situation.
Error code | Instructions |
---|---|
999 | The query data is empty |
1000 | No login |
1001 | Parameter error |
1006 | Currency information does not exist |
1008 | K line does not exist |
1009 | Quote does not exist |
1050 | Pair does not exist |
1051 | Notch depth does not exist |
1053 | Order has been blocked |
1054 | Less than the minimum order quantity |
1055 | Amount is less than balance |
1056 | Greater than the maximum order quantity |
1057 | Market order amount is invalid |
1058 | Failed to place an order |
1059 | Order does not exist |
1060 | Cancellation failed |
1061 | Order canceled |
1062 | Order completed |
1063 | Cancellation failed |
1099 | Currency does not exist |
1029 | Transferred amount is greater than transferable amount |
1049 | The user requests the interface too frequently |
1100 | Insufficient balance available |
1064 | KYC verification failed |
1065 | You have been frozen and cannot place an order |
1066 | Transaction password invalid |
1067 | Price, Price ≥ ${amount limit value} |
1068 | Price, Price ≤ ${amount limit value} |
1069 | Transaction amount precision is incorrect |
1070 | Quantity precision is incorrect |
1071 | Incorrect price precision |
1072 | The order quantity cannot be less than or equal to 0 |
1073 | The order price cannot be less than or equal to 0 |
1074 | Insufficient account balance |
1075 | Quantity, Amount ≥ ${amount limit value} |
1076 | Quantity, Amount ≤ ${amount limit value} |
1077 | Amount, Total ≥ ${amount limit value} |
1078 | Quantity, Amount ≥ ${amount limit value} |
1079 | Amount, Total ≤ ${amount limit value} |
1080 | Quantity, Amount ≤ ${amount limit value} |
1081 | The market order buy order has reached the highest transaction limit price, and the order has been automatically canceled |
1082 | The sell order of the market order has reached the minimum transaction limit price, and the order has been automatically canceled |
1083 | Failed to obtain user data |
1084 | No current order |
1085 | Exceeded the maximum number of orders |
1087 | No data found |
1088 | No way to verify user identity |
1089 | One of order_id or product cannot be empty |
1090 | client_oid already exists |
1091 | client_oid does not meet the rules |
1092 | The available balance of the current trading account is insufficient, whether to automatically transfer the ${0} in the fund account to the trading account, and initiate an order |
1093 | Insufficient account balance |
1094 | Transfer fail |
1095 | The quantity is too large |
1096 | Account does not exist |
1097 | System timeout |
1098 | The system is busy |
Public Data (DEPRECATED)
GET Kline
The k-line chart of historical products, the data is returned in the form of an array, and each object guarantees [close
, count
, high
, low
, open
, turnOver
, vol
]
Speed Limit: None
Speed limit rules: None
HTTP request
GET HOST/public/v1/products/{product}/candles
parameter name | required | type | description |
---|---|---|---|
product | true | string | path parameter commodity, example: ETH_USD commodity, example: ETH_USD |
period | true | string | indicator period [1min,5min,15min,30min,60min,4hour,1day,1week,1mon] |
start | true | string | timestamp milliseconds start (milliseconds) |
end | true | string | end (milliseconds) |
size | false | string | The data length defaults to 500, and the maximum is 1000[1,1000] |
{
"code": 200,
"data": [
{
"close": 11.9,
"count": 2,
"high": 11.9,
"id": 1639584000,
"low": 11,
"open": 11,
"turnOver": 22.9,
"vol": 2
}
],
"interval": "1day",
"msg": "success",
"productId": "ETH_USDT",
"ts": 1639650753079
}
parameter name | type | description |
---|---|---|
close | int | closing price |
high | int | highest price |
low | int | lowest price |
open | int | opening price |
turnOver | string | TurnOver |
vol | string | transaction volume |
productId | string | product, for example: ETH_USD |
GET order book
order book
Speed Limit: None
Speed limit rules: None
HTTP request
GET HOST/public/v1/products/{product}/orderbook
parameter name | required | type | description |
---|---|---|---|
product | true | string | path parameter commodity, for example: ETH_USD |
interval | true | string | Indicator period Valid value range step0-step11 Please refer to Deep Channel Subscription |
{
"interval": "step1",
"status": "ok",
"ts": 1641378313942,
"type": "orderBook",
"tick": {
"seqId": 9996,
"id": 1641378313,
"bids": [
[1, 65]
],
"asks": [
[48349.99, 5.3795],
[48562.27, 94.1076],
[48998.82, 49.924],
[49322.83, 15.03636],
[49324.72, 8.1281],
[49334.76, 82.7552],
[49342.59, 44.9204],
[49364.66, 28.5769],
[49365.2, 6.2237],
[49390.8, 44.7102],
[49414.67, 92.3859],
[49428.24, 46.7245],
[49430.6, 66.2994],
[49435.96, 68.4281],
[49437.07, 20.5226],
[49443.47, 51.3443],
[49444.4, 73.2709],
[49448.78, 41.5535],
[49454.19, 77.954],
[49458.74, 29.2196],
[49477.83, 50.3074],
[49492.03, 93.2679],
[49500.02, 11.1431],
[49506.89, 74.3294],
[49519.14, 45.8255],
[49525.62, 19.6835],
[49538.88, 97.1741],
[49544.83, 70.238],
[49551.81, 38.3689],
[49557.84, 69.0679],
[49565.77, 55.5486],
[49571.15, 55.1521],
[49589.14, 83.2236],
[49590.11, 1.5069],
[49593.9, 45.1853],
[49601.42, 21.826],
[49602.74, 2.7914],
[49609.3, 79.3817],
[49615.55, 81.7304],
[49653.07, 12.2331],
[49662.5, 68.8741],
[49675.13, 31.3474],
[49686.03, 6.1158],
[49690.92, 79.5905],
[49699.37, 91.9541],
[49719.33, 80.5142],
[49724.29, 61.7956],
[49726.37, 96.1342],
[49752.36, 71.4982],
[49769.78, 49.3641],
[49785.77, 43.4184],
[49815.95, 91.9892],
[49820.16, 74.1338],
[49847.76, 20.297],
[49888.07, 76.3738],
[49888.44, 8.6581],
[49907.97, 12.634],
[49932.43, 63.1484],
[49951.37, 5.0352],
[49952.08, 81.9681],
[49958.58, 99.3703],
[49977.74, 62.3056],
[49986.53, 34.2252],
[49998.03, 47.7642],
[49998.3, 88.6624]
],
"ts": 1641378313486,
"version": 1641378313,
"type": "orderBook",
"pairCode": "BTC_USDT",
"interval": "1"
}
}
parameter name | type | description |
---|---|---|
interval | string | gear |
status | string | status code |
ts | string | timestamp |
type | string | type |
seqId | string | ordered and unique id |
id | string | message unique id |
bids | [] | buyer |
asks | [] | seller |
pairCode | string | commodity, for example: ETH_USD |
GET 24-hour market data of all currency pairs
Market overview, get a snapshot of trades (quote changes), best bid/ask prices and 24-hour volume.
Speed Limit: None
Speed limit rules: None
HTTP request
GET HOST/public/v1/products/{product}/tickers
Parameter name | Required | Type | Description |
---|---|---|---|
product | true | string | path parameter commodity, for example: ETH_USD |
{
"type": "overview",
"code": 200,
"ts": 1641378730830,
"msg": "success",
"data": [{
"open": "19.56",
"close": "48174.19",
"low": "1",
"high": "54969.49",
"turnOver": "2397481368.57161866",
"count": 0,
"vol": "49659.154689",
"pairCode": "BTC_USDT",
"change": "48154.63",
"changePercent": "2461.8931492842535787"
}, {
"open": "11.9",
"close": "11.9",
"low": "11.9",
"high": "11.9",
"turnOver": "0",
"count": 0,
"vol": "0",
"pairCode": "ETH_USDT",
"change": "0",
"changePercent": "0"
}]
}
parameter name | type | description |
---|---|---|
close | int | closing price |
high | int | highest price |
low | int | lowest price |
open | int | opening price |
turnOver | string | TurnOver |
vol | string | transaction volume |
pairCode | string | commodity, for example: ETH_USD |
GET 24-hour market data of single currency pair
Get a snapshot of the last deal (quote), best bid/ask and 24-hour volume.
Speed Limit: None
Speed limit rules: None
HTTP request
GET HOST/public/v1/products/{product}/ticker
Parameter name | Required | Type | Description |
---|---|---|---|
product | true | string | path parameter commodity, for example: ETH_USD |
{
"ch": "market.ETH_USDT.detail",
"status": "ok",
"tick": {
"open": "11.9",
"close": "11.9",
"low": "11.9",
"high": "11.9",
"turnOver": "0",
"count": 0,
"vol": "0",
"pairCode": "ETH_USDT",
"change": "0",
"changePercent": "0"
},
"ts": 1641378912756
}
parameter name | type | description |
---|---|---|
close | int | closing price |
high | int | highest price |
low | int | lowest price |
open | int | opening price |
turnOver | string | TurnOver |
vol | string | transaction volume |
GET single currency pair real-time transaction
Get the latest deals list for products
Speed Limit: None
Speed limit rules: None
HTTP request
GET HOST/public/v1/products/{product}/trade
Parameter name | Required | Type | Description |
---|---|---|---|
product | true | string | path parameter commodity, for example: ETH_USD |
{
"status": "ok",
"tick": {
"data": [{
"direction": "sell",
"id": 28730000,
"price": "11.9",
"ts": 1639585820376,
"vol": "1"
}],
"id": 1641379110358,
"ts": 1641379110358
},
"ts": 1641379110358
}
parameter name | type | description |
---|---|---|
direction | string | buy / sell |
price | string | price |
vol | string | volume |
GET single currency pair multiple real-time transactions
Get the latest deals list for products
Speed Limit: None
Speed limit rules: None
HTTP request
GET HOST/public/v1/products/{product}/trades
parameter name | required | type | description |
---|---|---|---|
product | true | string | path parameter commodity, for example: ETH_USD |
size | false | int | data length default 500, maximum 1000[1,1000] |
{
"data": [{
"data": [{
"direction": "buy",
"id": 28470000,
"price": "11",
"ts": 1639585820373,
"vol": "1"
}],
"id": 2847,
"ts": 1639585820373,
"type": "fills"
}, {
"data": null,
"id": 2871,
"ts": 1639585820376,
"type": "fills"
}, {
"data": [{
"direction": "sell",
"id": 28730000,
"price": "11.9",
"ts": 1639585820376,
"vol": "1"
}],
"id": 2873,
"ts": 1639585820376,
"type": "fills"
}],
"status": "ok",
"ts": 1641379702364
}
parameter name | type | description |
---|---|---|
direction | string | buy / sell |
price | string | price |
vol | string | volume |
WEBSOCKET PUBLIC(DEPRECATED)
Candles Subscribe/UnSubscribe
Subscribe
sub request
{
"event": "sub",
"params": {
"biz": "market",
"type": "candles",
"product": "ETH_BNB",
"interval": "30min"
},
"zip": true
}
Request parameters
parameter name | required | type | description |
---|---|---|---|
params .biz | is | string | |
params.type | yes | string | subscription type |
params .product | is | string | currency pair |
params.interval | is | string | period |
event | is | string | event Subscribe |
zip | yes | bool | whether to enable gzip |
sub response
{
"channel": "subscribe",
"biz": "market",
"type": "candles",
"product": "ETH_BNB",
"interval": "30min",
"ts": 1639655425910,
"status": "ok"
}
return parameters
parameter name | type | description |
---|---|---|
type | string | subscription type |
interval | string | interval |
product | string | currency pair |
data .open | string | The first transaction price during this K-line period |
data .close | string | The last transaction price of this K-line period |
data .low | string | The lowest transaction price during this K-line period |
data .high | string | The highest transaction price during this K-line |
data .vol | string | Trading volume during this K-line |
data .turnOver | string | Turnover during this K-line |
data .id | int | unique and ordered id |
data .count | int | Number of transactions during this K-line period |
UnSubscribe
unsub request
{
"event": "unsub",
"params": {
"biz": "market",
"type": "candles",
"product": "ETH_BNB",
"interval": "1day"
},
"zip": true
}
Request parameters
parameter name | required | type | description |
---|---|---|---|
params .biz | is | string | |
params.type | yes | string | subscription type |
params .product | is | string | currency pair |
params.interval | is | string | period |
event | is | string | event UnSubscribe |
zip | yes | bool | whether to enable gzip |
unsub response
{
"channel": "unsubscribe",
"biz": "market",
"type": "candles",
"product": "ETH_BNB",
"interval": "1day",
"ts": 1639655425910,
"status": "ok"
}
return parameters
parameter name | type | description |
---|---|---|
type | string | subscription type |
interval | string | interval |
product | string | currency pair |
data .open | string | The first transaction price during this K-line period |
data .close | string | The last transaction price of this K-line period |
data .low | string | The lowest transaction price during this K-line period |
data .high | string | The highest transaction price during this K-line |
data .vol | string | Trading volume during this K-line |
data .turnOver | string | Turnover during this K-line |
data .id | int | unique and ordered id |
data .count | int | Number of transactions during this K-line period |
data .seqId | int | ordered and unique id |
Feed Stream
feed stream
{
"id": 1688954400,
"type": "candles",
"pairCode": "BTC_USDT",
"product": "BTC_USDT",
"data":
{
"open": 3.1406,
"close": 3.0466,
"high": 4.0007,
"low": 3.0051,
"turnOver": 51642.553798,
"vol": 14765.94,
"count": 52144,
"seqId": 111322735,
"id": 1688954400
},
"interval": "30min",
"SeqId": 111322735
}
Fills Subscribe/UnSubscribe
Subscribe
sub request
{
"event": "sub",
"params": {
"biz": "market",
"type": "fills",
"product": "ETH_USDT"
},
"zip": false
}
parameter name | required | type | description |
---|---|---|---|
params .biz | is | string | |
params.type | yes | string | subscription type type |
params .product | is | string | currency pair |
event | is | string | event Subscribe |
zip | yes | bool | whether to enable gzip |
sub response
{
"channel": "subscribe",
"biz": "market",
"type": "fills",
"product": "ETH_USDT",
"ts": 1641384262679,
"status": "ok"
}
UnSubscribe
parameter name | required | type | description |
---|---|---|---|
params .biz | is | string | |
params.type | yes | string | subscription type type |
params .product | is | string | currency pair |
params.interval | is | string | period |
event | is | string | event Subscribe |
zip | yes | bool | whether to enable gzip |
sub request
{
"event": "unsub",
"params": {
"biz": "market",
"type": "fills",
"product": "ETH_USDT"
},
"zip": false
}
unsub response
{
"biz": "market",
"channel": "unsubscribe",
"product": "ETH_USDT",
"type": "fills",
"status": "ok",
"ts": 1689041894440
}
Feed Stream
parameter name | type | description |
---|---|---|
id | int | unsigned integer unique id of this message |
type | string | subscription type |
interval | string | interval |
product | string | currency pair |
pairCode | string | ignore |
data.price | string | price |
data .vol | string | volume |
data.ts | int | timestamp |
data.direction | string | direction |
data .id | int | transaction id |
feed stream
{
"id": 323241,
"type": "fills",
"pairCode": "BTC_USDT",
"data":
[
{
"ts": 1689152406185,
"id": 323241000,
"vol": "0.04",
"price": "3.6733",
"direction": "buy"
}
],
"product": "BTC_USDT",
"ts": 1689152412845
}
OrderBook Subscribe/UnSubscribe
sub request
{
"event": "sub",
"params": {
"biz": "market",
"type": "orderBook",
"product": "ETH_USDT",
"interval": "1"
},
"zip": false
}
Subscribe
parameter name | required | type | description |
---|---|---|---|
params .biz | is | string | |
params.type | yes | string | subscription type |
params .product | is | string | currency pair |
params.interval | is | string | period |
event | is | string | event |
zip | yes | bool | whether to enable gzip |
sub response
{
"biz": "market",
"channel": "subscribe",
"interval": "1",
"product": "ETH_USDT",
"type": "orderBook",
"status": "ok",
"ts": 1689934070509
}
UnSubscribe
parameter name | required | type | description |
---|---|---|---|
params .biz | is | string | |
params.type | yes | string | subscription type |
params .product | is | string | currency pair |
params.interval | is | string | period |
event | is | string | event |
zip | yes | bool | whether to enable gzip |
unsub request
{
"event": "unsub",
"params": {
"biz": "market",
"type": "orderBook",
"product": "ETH_USDT",
"interval": "1"
},
"zip": false
}
unsub response
{
"biz": "market",
"channel": "unsubscribe",
"interval": "1",
"product": "ETH_USDT",
"type": "orderBook",
"status": "ok",
"ts": 1689934273388
}
Feed Stream
feed stream
{
"id": 1689934071,
"type": "orderBook",
"pairCode": "ETH_USDT",
"product": "ETH_USDT",
"ts": 1689934071000,
"version": 1689934071,
"seqId": 0,
"interval": "1",
"bids": [
[3781.85, 0.30656],
[3781.78, 0.0219],
[360, 4.59207],
[10, 11]
],
"asks": [
[3835, 0.19948],
[3836.98, 0.00026],
[3837.33, 0.4445],
[3839, 0.2]
]
}
Percent10 Subscribe\Unsubscribe
Subscribe
sub request
{
"event": "sub",
"params":
{
"biz": "market",
"type": "percent10",
"product": "ETH_USDT"
},
"zip": false
}
parameter name | required | type | description |
---|---|---|---|
params .biz | is | string | |
params.type | yes | string | subscription type |
params .product | is | string | currency pair |
event | is | string | event |
zip | yes | bool | whether to enable gzip |
sub response
{
"biz": "market",
"channel": "subscribe",
"product": "ETH_USDT",
"type": "percent10",
"status": "ok",
"ts": 1689934871904
}
UnSubscribe
unsub request
{
"event": "unsub",
"params":
{
"biz": "market",
"type": "percent10",
"product": "ETH_USDT"
},
"zip": false
}
parameter name | required | type | description |
---|---|---|---|
params .biz | is | string | |
params.type | yes | string | subscription type |
params .product | is | string | currency pair |
params .pairCode | is | string | currency pair (ignore) |
event | is | string | event |
zip | yes | bool | whether to enable gzip |
unsub response
{
"biz": "market",
"channel": "unsubscribe",
"product": "ETH_USDT",
"type": "percent10",
"status": "ok",
"ts": 1689934879610
}
Feed Stream
feed stream
{
"id": 1689934879,
"type": "percent10",
"pairCode": "ETH_USDT",
"product": "ETH_USDT",
"ts": 1689934879000,
"version": 1689934879,
"seqId": 0,
"bids": [
[11.994, 0.10124]
],
"asks": [
[12.006, 0]
]
}
Ticker Subscribe\UnSubscribe
Subscribe
sub request
{
"event": "sub",
"params": {
"biz": "market",
"type": "ticker",
"product": "ETH_USDT"
},
"zip": false
}
parameter name | required | type | description |
---|---|---|---|
params .biz | is | string | |
params.type | yes | string | subscription type |
params .product | is | string | currency pair |
event | is | string | event |
zip | yes | bool | whether to enable gzip |
sub response
{
"id": "",
"channel": "subscribe",
"biz": "market",
"type": "ticker",
"product": "ETH_USDT",
"interval": "",
"ts": 1641387679813,
"status": "ok"
}
UnSubscribe
unsub request
{
"event": "unsub",
"params": {
"biz": "market",
"type": "ticker",
"product": "ETH_USDT"
},
"zip": false
}
parameter name | required | type | description |
---|---|---|---|
params .biz | is | string | |
params.type | yes | string | subscription type |
params .product | is | string | currency pair |
event | is | string | event |
zip | yes | bool | whether to enable gzip |
unsub response
{
"biz": "market",
"channel": "unsubscribe",
"product": "BTC_USDT",
"type": "ticker",
"status": "ok",
"ts": 1689935550687
}
Feed Stream
parameter name | type | description |
---|---|---|
type | string | subscription type |
ts | int | timestamp |
product | string | currency pair |
msg | string | ignore |
code | int | ignore |
data .open | string | The first transaction price started 24 hours ago |
data .close | string | 24-hour latest transaction price |
data .low | string | The lowest transaction price within 24 hours |
data .high | string | The highest transaction price within 24 hours |
data .vol | string | Trading volume within 24 hours |
data .turnOver | string | turnover within 24 hours |
data .count | int | Number of transactions in 24 hours |
data .change | int | 24-hour price change |
data .changePercent | int | 24-hour price change (percentage) |
data .pairCode | string | ignore |
feed stream
{
"code": 200,
"msg": "success",
"ts": 1689935550508,
"type": "ticker",
"product": "BTC_USDT",
"data":
{
"pairCode": "BTC_USDT",
"open": "3.2934",
"close": "3.01",
"high": "4.003",
"low": "2.9758",
"turnOver": "25483.2032",
"vol": "7355.4",
"count": 0,
"change": "-0.2834",
"changePercent": "-0.0861"
}
}
Request Candles
req request
{
"event": "req",
"params": {
"biz": "market",
"type": "candles",
"product": "BTC_USDT",
"interval": "1day",
"size": 301,
"from": 1613692800,
"to": 1639699200
},
"zip": false
}
Parameter name | Required | Type | Description |
---|---|---|---|
params.biz | is | string | |
params.type | is | string | type |
params.product | is | string | currency pair |
params.interval | is | string | period |
params.from | is | string | start time |
params.to | is | string | end time |
event | is | string | event |
zip | yes | bool | whether to enable gzip |
return structure
parameter name | type | description |
---|---|---|
biz | string | Quote |
ts | int | timestamp |
product | string | currency pair |
interval | string | interval 1day |
event | string | req |
data .open | string | The first transaction price during this K-line period |
data .close | string | The last transaction price of this K-line period |
data .low | string | The lowest transaction price during this K-line period |
data .high | string | The highest transaction price during this K-line |
data .vol | string | Trading volume during this K-line |
data .turnOver | string | Turnover during this K-line |
data .id | int | unique and ordered id |
data .count | int | Number of transactions during this K-line period |
req response
{
"biz": "market",
"product": "BTC_USDT",
"ts": 1689936708184,
"type": "candles",
"interval": "1day",
"event": "req",
"data":
[
{
"count": 2265,
"turnOver": 2802.082564,
"vol": 810.94,
"id": 1689782400,
"high": 4.003,
"open": 3.2934,
"low": 3.0103,
"close": 3.2399
},
{
"count": 25441,
"turnOver": 29922.563131,
"vol": 8627.47,
"id": 1689868800,
"high": 3.9711,
"open": 3.2399,
"low": 2.9758,
"close": 3.8212
}
]
}
Request Ticker
Request structure
parameter name | required | type | description |
---|---|---|---|
params.biz | is | string | |
params.type | no | string | type |
params.product | no | string | currency pair |
event | is | string | event |
zip | yes | bool | whether to enable gzip |
req request
{
"event": "req",
"params": {
"biz": "market",
"type": "ticker",
"product": "ETH_USDT"
},
"zip": false
}
return parameters
parameter name | type | description |
---|---|---|
biz | string | Quote |
type | string | ticker |
ts | int | timestamp |
product | string | currency pair |
event | string | req |
data .open | string | The first transaction price started 24 hours ago |
data .close | string | 24-hour latest transaction price |
data .low | string | The lowest transaction price within 24 hours |
data .high | string | The highest transaction price within 24 hours |
data .vol | string | Trading volume within 24 hours |
data .turnOver | string | turnover within 24 hours |
data .count | int | Number of transactions in 24 hours |
data .change | int | 24-hour price change |
data .changePercent | int | 24-hour price change (percentage) |
req response
{
"biz": "market",
"product": "BTC_USDT",
"ts": 1689937681602,
"type": "ticker",
"event": "req",
"data":
{
"open": "3.2934",
"close": "3.3483",
"low": "2.9758",
"high": "4.003",
"turnOver": "39507.143672",
"count": 0,
"vol": "11384.41",
"pairCode": "BTC_USDT",
"change": "0.0549",
"changePercent": "0.0167"
}
}
WEBSOCKET PRIVATE(DEPRECATED)
Login
Perform WS channel user authentication. Only authenticated channels can subscribe to the user's asset information and order status change information
Subscribe
request
{
"event": "login",
"params": {
"type": "api",
"access-key": "de0535f81d51c998b7fbcf00f189f294",
"access-sign": "sign",
"access-timestamp": 14000000000
}
}
Request parameters
parameter name | required | type | description |
---|---|---|---|
params.type | is | string | authentication method: api : apiKey authentication; token : token authentication |
params.access-key | is | string | authentication description |
params.access-sign | is | string | authentication description |
params.access-timestamp | is | long | authentication description |
event | is | string | event name event list |
response
{
"result": "login",
"data":
{
"result": true
}
}
parameter name | type | description |
---|---|---|
result | string | Data Channels |
data.result | bool | Whether the subscription is successful |
Assets
Subscribe to user's asset changes. Currently only supports subscription by product. Subscription to full asset change information is under development.
Subscribe
request
{
"event": "sub",
"params": {
"biz": "exchange",
"type": "assets",
"product": "ETH_BTC",
"zip": false
}
}
Request parameters
parameter name | required | type | description |
---|---|---|---|
params.biz | is | string | subscription module type |
params.type | is | string | subscription business type |
params.product | is | string | product information |
event | is | string | event name event list |
zip | yes | bool | whether to enable gzip |
response
{
"channel": "subscribe",
"biz": "exchange",
"type": "assets",
"product": "ETH_BTC",
"data": {
"result": true
}
}
return parameters
parameter name | type | description |
---|---|---|
channel | string | data channel |
biz | string | Business Line |
type | string | protocol type |
product | string | product name |
data.result | bool | Whether the subscription is successful |
feed
{
"biz": "exchange",
"type": "assets",
"product": "BTC_USDT",
"zip": false,
"data": [
{
"symbol": "BTC",
"available": 100805.8,
"hold": 13.2
}
]
}
push data
parameter name | type | description |
---|---|---|
channel | string | data channel |
biz | string | Business Line |
type | string | protocol type |
product | string | product name |
$data.currency | string | currency name |
$data.available | bigdecimal | available quantity name |
$data.hold | bigdecimal | Currency name of the frozen quantity |
Orders
Subscribe to status changes for all orders
Subscribe
request
{
"event": "sub",
"params": {
"biz": "exchange",
"type": "orders",
"product": "all",
"zip": false
}
}
Request parameters
parameter name | required | type | description |
---|---|---|---|
params.biz | is | string | subscription module type |
params.type | is | string | subscription business type |
params.product | is | string | product name |
event | is | string | event name event list |
zip | yes | bool | whether to enable gzip |
response
{
"channel": "subscribe",
"biz": "exchange",
"type": "orders",
"product": "all",
"data": {
"result": true
}
}
return parameters
parameter name | type | description |
---|---|---|
channel | string | data channel |
biz | string | Business Line |
type | string | protocol type |
product | string | product name |
data.result | bool | Whether the subscription is successful |
parameter name | parameter description | type | schema |
---|---|---|---|
order_id | order number | string | |
product | commodity | string | |
side | buy/sell | string | |
price | price per unit of base currency | string | |
size | Amount of base currency to buy/sell | string | |
filled_amount | Amount of transaction | string | |
funds | Amount of quote currency to use | string | |
filled_size | transaction amount | string | |
type | limit: limit order/market: market order/ | string | |
status | status | string | |
client_oid | default "0", user-defined order number | string |
status
: transaction status, value range 0-7
- 0: order has been received
- 1: The order has been submitted
- 2: The order is partially executed
- 3: The order has been completely filled
- 4: The order is canceled
- 5: The order has been canceled
- 6: Order transaction failed
- 7: The order is reduced
feed
{
"biz": "exchange",
"type": "orders",
"data": {
"order_id": "124645019749408967",
"product": "BTC_USDT",
"side": "buy",
"price": "60000",
"size": "1",
"filled_amount": "0",
"funds": "1",
"filled_size": "0",
"type": "limit",
"status": "1",
"client_oid": ""
}
}
push data
parameter name | type | description |
---|---|---|
channel | string | data channel |
biz | string | Business Line |
type | string | protocol type |
product | string | product name |
$data | object | order details |
Event list
Event Name | Type | Description |
---|---|---|
sub | string | Subscribe to events, initiated by the client |
login | string | login event, initiated by the client |
Biz list
Biz Name | Type | Description |
---|---|---|
exchange | string | spot transaction |
List of Types
Type Name | Type | Description |
---|---|---|
assets | string | asset changes |
orders | string | order status change |