Introduction
API Introduction
Welcome to the BKEX Global API!
This document is the only official documentation for BKEX Global API, and the capabilities provided by BKEX GlobalAPI will be continuously updated here. Please pay attention to it in time.
You can switch document languages by clicking on the language button at the top right.
On the right side of the document are examples of request parameters and response results.
Update your subscription
BKEX Global will notify you of API additions, updates, downlines, and other information in advance through announcements.
You can click on here view announcement.
Contact Us
If you have any questions or suggestions during the use, you can choose any of the following ways to contact us:
- Contact Official Telegram @BKEX_ANGEL.
- Send email to support@bkex.com.
Quick Start
Access preparation
If you want to use the API, please log in to the web terminal, complete the API key application and permissions configuration, and then develop and trade according to the document details.
You can click on here to create API key。
Each account can create up to five Api Keys, and each Api Key can be used to set up three types of access rights: Read, Trade and Withdraw.
The competencies are described below:
- Read permission: Read permission is used to query the data interface, such as: order query, transaction query and so on.
- Transaction permissions: transaction permissions are used to place orders, cancel orders, and transfer class interfaces.
- Withdraw permission: Permission to withdraw coins is used to create and cancel orders for withdrawing coins.
Be sure to remember the following information after successful creation:
Access Key
API Access KeySecret Key
The key used to encrypt the signature authentication(Visible only on application)
Interface type
BKEX Global provides users with two interfaces, allowing you to choose the appropriate method for checking quotes, trading or withdrawing cash, depending on your usage scenario and preferences.
REST API
REST, which stands for Representational State Transfer, is a popular HTTP-based communication mechanism, where each URL represents a resource.
One-time operations such as transactions or asset withdrawals are recommended to developers using the REST API.
WebSocket API
WebSocket is a new protocol in HTML5. It implements full-duplex communication between client and server, with a simple handshake you can establish a client-server connection. The server can proactively push information to clients based on business rules.
It is recommended that developers use the WebSocket API to obtain information on market conditions and buying and selling depths.
interface authentication
Both types of interfaces include public and private interfaces.
The public interface can be used to obtain basic information and quotes data. The public interface can be used without authentication.
The private interface can be used for transaction management and account management. Each private request must be signed using your API Key for signature verification.
Access URLs
REST API
https://api.bkex.com
Websocket Feed
wss://api.bkex.com
Signature authentication
Signature note
API requests can be tampered with during transmission over the internet. To ensure that requests are not altered, private interfaces other than the public ones (Base Information, Quote Data) must use your API Key.
Encryption is done to verify that the parameter or parameter value has not changed during transmission.
Each API Key needs to have the appropriate permissions to access the appropriate interface, and each newly created API Key Permissions need to be assigned. Before using an interface, review the permission types for each interface and make sure your API Key has the appropriate permissions.
What is required for a legitimate request:
- Method request address: i.e. access server address api.bkex.com, e.g. https://api.bkex.com/v2/u/order/create.
- API Access Key (X_ACCESS_KEY): The Access Key in the API Key you are requesting.
- Required and optional parameters: Each method has a set of required and optional parameters that define the API calls. These parameters and their meanings can be found in the description of each method.
- Signature: The value calculated cryptographically to ensure that the signature is valid and has not been tampered with.
Encryption method
Specification of requests to calculate signatures Because when using HMAC for signature calculations, calculating with different content can result in Completely different. So before you perform the signature calculation, please normalize the request. The following is an example of a request for an order detail.
Order Request URL
https://api.bkex.com/v2/u/order/create?volume=0.12&direction=ASK&price=7126.4285&symbol=BTC_USDT
Sort the parameters in ASCII order
direction=ASK&price=7126.4285&symbol=BTC_USDT&volume=0.12
The ranked request parameters are encrypted with HMAC SHA256 using secretKey.
550ac73ace8c34372e0e1dd6631e890c7bd16697af8bb4e2908e966b50aba4e0
Constructing an http request using
- Use the X_ACCESS_KEY header to store access key information.
- Use the X_SIGNATURE header to store the generated signature information.
Then send an http request
Enumeration definition
Trading pair
A trading pair consists of the base currency and the quoted currency. Take the trading pair BTC_USDT for example, BTC is the base currency and USDT is the quoted currency.
Accounts
Different accounts are required for different operations
Account types include:
- WALLET: Spot account
- OTC:OTC account
- GENERAL:Account for Super Contract
Order and transaction related ID description
- orderId : the unique number of the order
- tradeId : The unique number of the transaction
Order Type
Direction of buying and selling:
- BID: Buy
- ASK: Sell
Order type:
- LIMIT : Limit order, this type of order needs to specify the order price, order quantity.
- MARKET : Market order, this type of order only needs to specify the amount or quantity of the order, do not need to specify the price , the order will be filled directly with the counterparty when it enters into a match until the amount or quantity falls below the minimum amount or quantity of the transaction For the stop.
- STOP_LIMIT : A take profit stop order sets the order above or below the market price when the order reaches the The price is triggered before you are officially in the matchmaking queue.
Query order sorting rules:
- TIME_ASC :Ascending by time.
- TIME_DESC : Descending by time.
- PRICE_ASC : ascending order by price.
- PRICE_DESC : descending order by price.
Order Status
- -1 : Stop-limit order not triggered, this status order is in the matchmaking queue.
- 0 : Waiting to be filled, this status order is in the matchmaking queue.
- 1 : Filled. This status order is not in the matchmaking queue and the full quantity of the order has been filled by the market.
- 2 : Cancelled. This status order is not in the pinch order, this status order may have a partial quantity and was successfully cancelled.
- 3 : Partially Filled, this status order is in the matchmaking queue and part of the order quantity has been filled by the market. Waiting for the rest of the transaction.
Access Description
Interface Overview
Interface Classification | Category Links | Overview |
---|---|---|
Basics | /v2/common/* | Basic class interface, including currency, pair and other interfaces | .
Quotes | /v2/q/* | Public quote class interface, including transaction, depth, quotes, etc. | .
Account Classes | /v2/u/account/* | Account class interface, including account information, etc. |
Wallet class | /v2/u/wallet/* | Wallet withdrawals, deposit and withdrawal records | .
Order Class | /v2/u/order/* | Order class interface, including placing orders, withdrawals, order inquiries, deal inquiries, etc. |
Frequency limit rules
- Limits each API Key to 10 times in 1 second .
- If the interface does not require an API Key, then each IP is limited to 10 times in 1 second .
- The individual interfaces have separate frequency limit rules .
- Exceeding the frequency limit number will result in a 5-10 second ban .
For example:
- Asset order class interface calls are limited according to the user: 1 second and 10 times .
- Frequency limit according to IP for market class interface calls: 1 second and 10 times .
Request Format
There are currently only two methods: GET and POST
- GET request: all the parameters are in the path parameter
- POST request, with all parameters sent in form-data format in the body of the request
Return Format
All interfaces are in JSON format. There are three fields at the top of JSON: msg
, code
and
data
. The first two fields represent the request status and information, the actual business data is in the data
field .
Here is an example of a return format:
{ "msg": "success", "code": "0", "data": // per API response data in nested JSON object }
Parameter Name | Data Types | Description |
---|---|---|
msg | string | API information returned | .
code | int | Interface status returned, 0 represents success |
data | object | Interface returns data subject | .
Error Code
Error Code | Description |
---|---|
75 | Incorrect trade priceSpread |
76 | Incorrect trade order priceSpread precision |
77 | Incorrect request param |
1005 | Not Enough balance |
1801 | Amount too small |
1931 | Quantity of ordering exceeds the limit |
2002 | Trading pair error |
2025 | Trading direction error |
2027 | The trading pair is not currently open for orders |
2031 | The number of precision not correct |
2033 | The trading pair is not currently open for BID orders |
2034 | This trading pair is not open for BID orders |
2035 | The trading pair is not currently open for ASK orders |
2036 | This trading pair is not open for ASK orders |
2037 | Please make trade after some time |
2041 | Price should be empty for market order |
2042 | The stop-limit orders of the trading pair exceeds the limit |
2043 | The total of stop-limit orders exceeds the limit |
6006 | Visit too frequently. Please try again later |
7019 | Cannot find order, cannot cancel |
7020 | You can not cancel the order now |
Sample code
Basic Information
Get all pairs
.This interface returns all symbols supported by BKEX Global.
curl "https://api.bkex.com/v2/common/symbols"
HTTP requests
- GET
/v2/common/symbols
.
Request Parameters
This interface does not accept any parameters.
Response:
{
"msg": "success",
"code": "0",
"data": [
{
"symbol": "BTC_USDT",
"supportTrade": true,
"volumePrecision": 4,
"pricePrecision": 4,
"minimumTradeVolume": 0.001,
"tradeSet":"USDT"
},
{
"symbol": "ETH_USDT",
"supportTrade": false,
"volumePrecision": 4,
"pricePrecision": 4,
"minimumTradeVolume": 0.01,
"tradeSet":"USDT"
}
]
}
Return field
Field names | Data Types | Description |
---|---|---|
symbol | string | Trading pair |
supportTrade | boolean | Whether or not the transaction is supported |
volumePrecision | integer | Precision (number of decimal places) of the number of orders placed for a transaction |
pricePrecision | integer | Accuracy of trade to order price (decimal places) |
minimumTradeVolume | decimal | Minimum number of orders placed in previous currency pairs | .
tradeSet | string | Trading area | .
Get all currencies
This interface returns all currencies supported by BKEX Global.
curl "https://api.bkex.com/v2/common/currencys"
HTTP request
- GET
/v2/common/currencys
.
Request Parameters
This interface does not accept any parameters.
Response:
{
"msg": "success",
"code": "0",
"data": [
{
"currency": "ETH",
"maxWithdrawOneDay": 2000,
"maxWithdrawSingle": 2000,
"minWithdrawSingle": 0.1,
"supportDeposit": true,
"supportTrade": true,
"supportWithdraw": true,
"withdrawFee": 0.008
},
{
"currency": "BTC",
"maxWithdrawOneDay": 100,
"maxWithdrawSingle": 100,
"minWithdrawSingle": 0.01,
"supportDeposit": true,
"supportTrade": true,
"supportWithdraw": true,
"withdrawFee": 0.008
}
]
}
Return field
Field names | Data Types | Description |
---|---|---|
currency | string | Currency |
maxWithdrawOneDay | decimal | Same day maximum withdrawal limit |
maxWithdrawSingle | decimal | Maximum limit for single withdrawal |
minWithdrawSingle | decimal | Minimum number of withdrawals in a single transaction |
supportDeposit | boolean | Whether or not to support deposit | .
supportTrade | boolean | Whether or not to support trade |
supportWithdraw | boolean | Whether or not to support withdrawal |
withdrawFee | decimal | Withdrawal fees |
Get the server timestamp
.This interface returns the server's current timestamp. That is, the total number of milliseconds from 00:00:00:0 milliseconds on January 1, 1970 UTC to the present.
curl "https://api.bkex.com/v2/common/timestamp"
HTTP request
- GET
/v2/common/timestamp
.
Request Parameters
This interface does not accept any parameters.
Response:
{
"code": 0,
"data": 1588652674630,
"msg": "success"
}
Return field
Field names | Data Types | Description |
---|---|---|
data | long | Timestamp |
quotes data
K-line data (candlestick)
This interface returns historical K-line data.
HTTP requests
- GET
/v2/q/kline
curl "https://api.bkex.com/v2/q/kline?period=1m&size=200&symbol=BTC_USDT&from=1529739295000&to=1532331295000"
Request Parameters
Parameters | Data Types | Is it necessary | Default values | Description | Range of values |
---|---|---|---|---|---|
symbol | string | true | NA | Trading pair | BTC_USDT |
period | string | false | 1m | Returns the data time granularity, which is the time interval for each candle | .1m, 5m, 15m, 30m, 1h, 4h, 6h, 12h, 1d, 1w |
from | long | true | NA | The start timestamp in milliseconds | .1529739295000 |
to | long | true | NA | The end timestamp in milliseconds | 1532331295000 |
size | integer | false | 500 | The number of K-line data bars | .[1, 1000] |
Response:
{
"msg": "success",
"code": "0",
"data": [
{
"symbol": "BTC_USDT",
"volume": 12321.1234,
"open": 4124.3,
"close": 3873.213,
"low": 3521.1,
"high": 4521.5,
"quoteVolume": 71031537.978665,
"ts": 1529739295000
}
]
}
Response data
Field names | Data Types | Description |
---|---|---|
symbol | string | Trading pair |
volume | decimal | Transaction volume in base currency |
open | decimal | Opening price for this phase |
close | decimal | Closing price for the period |
low | decimal | Lowest price at this stage | .
high | decimal | Highest price at this stage |
quoteVolume | decimal | Volumes in quoted currencies | ts | long | Time stamp of Singapore time in milliseconds |
24-hour trade statistics
This interface provides the last 24 hours of pair market information.
HTTP requests
- GET
/v2/q/tickers
curl "https://api.bkex.com/v2/q/tickers?symbol=BTC_USDT"
request parameter
Parameters | Data Types | Is it necessary | Default values | Description | Range of values |
---|---|---|---|---|---|
symbol | string | false | NA | Trading pair | BTC_USDT,ETH_USDT... |
Response:
{
"msg": "success",
"code": "0",
"data": [
{
"symbol": "BTC_USDT",
"tradeSet": "USDT",
"close": 7145.0407,
"open": 7145.0407,
"high": 7145.0407,
"low": 7145.0407,
"volume": 3124.1231,
"quoteVolume": 23131.847291,
"change": 0.12,
"ts": 1529739295000
}
]
}
Response data
Field names | Data Types | Description |
---|---|---|
symbol | string | Trading pair |
tradeSet | string | Trading area |
volume | decimal | Transaction volume in base currency |
open | decimal | Opening price for this phase |
close | decimal | Last price at this stage |
quoteVolume | decimal | Lowest price at this stage |
high | decimal | Highest price at this stage |
vol | decimal | Volumes in quoted currencies |
change | decimal | 24-hour ups and downs |
ts | long | Time stamp of Singapore time in milliseconds |
Last sale price
This interface provides trading pairs with the latest current transaction prices
HTTP requests
- GET
/v2/q/ticker/price
curl "https://api.bkex.com/v2/q/ticker/price?symbol=BTC_USDT"
Request Parameters
Parameters | Data Types | Is it necessary | Default values | Description | Range of values |
---|---|---|---|---|---|
symbol | string | false | NA | Trading pair | BTC_USDT,ETH_USDT... |
Response:
{
"msg": "success",
"code": "0",
"data": [
{
"symbol": "BTC_USDT",
"price": 7145.0407
}
]
}
Response data
Field names | Data Types | Description |
---|---|---|
symbol | string | Trading pair |
price | decimal | Current Transaction Prices |
Trade pair order book
This interface returns the current depth data for the specified trading pair.
HTTP requests
- GET
/v2/q/depth
curl "https://api.bkex.com/v2/q/depth?symbol=BTC_USDT&depth=20&precision=4"
Request Parameters
Parameters | Data Types | Must | Default values | Description | Range of values |
---|---|---|---|---|---|
symbol | string | true | NA | Trading pair | BTC_USDT |
depth | integer | false | 50 | Number of depths returned | [1-50] |
precision | integer | false | Trading Pair Default Accuracy | Price Accuracy | [1-10] |
Response:
{
"msg": "success",
"code": "0",
"data": {
"bid": [
[7964, 0.0678], // [Price, quantity]
[7963, 0.9162],
...
],
"ask": [
[7979, 0.0736],
[7980, 1.0292],
...
]
}
}
Response data
Field names | Data Types | Description |
---|---|---|
bid | object | All current buy orders [price, volume] |
ask | object | All current sell orders [price, volume] |
Recent Transaction History
This interface returns the latest transaction record of the specified pair.
HTTP requests
- GET
/v2/q/deals
curl "https://api.bkex.com/v2/q/deals?symbol=BTC_USDT&size=20"
Request Parameters
Parameters | Data Types | Is it necessary | Default values | Description |
---|---|---|---|---|
symbol | string | true | NA | BTC_USDT |
size | integer | false | NA | [1-50] |
Response:
{
"msg": "success",
"code": "0",
"data": [
{
"symbol": "BTC_USDT",
"price": 7145.0407,
"volume": 0.5344,
"direction": "B",
"ts": 1529739295000
}
]
}
Response data
Field names | Data Types | Description |
---|---|---|
symbol | string | Trading pair |
volume | decimal | Volume in Base Currencies |
price | decimal | Traded price in quoted currency |
direction | string | Trade Direction: "B" or "S", "B" is Buy, "S" is Sell |
ts | long | Time stamp of Singapore time in milliseconds |
Account Related
API Key Permission Information
Query the permission information for the current API Key
HTTP request
- GET
/v2/u/api/info
.
Request Parameters
This interface does not accept any parameters.
Response:
{
"msg": "success",
"code": "0",
"data": {
"asset": true,
"contract": true,
"contractType": 1,
"deal": true,
"endTime": 1591537150000
}
}
response data
Parameter Name | Data Types | Examples | Description |
---|---|---|---|
asset | boolean | true | Whether or not assets (wallet accounts, fiat currency accounts) are searchable |
deal | boolean | true | Whether you can make a trade using this API key |
contract | boolean | true | Whether to enable contract-related permissions | .
contractType | integer | 1 | Contract Permissions (0: Query, 1: Query and Trade) |
Account Balance
API Key Permissions: Read
Check the balance of a given currency or all of them, wallet and OTC account support
HTTP requests
- GET
/v2/u/account/balance
Request Parameters
Parameter Name | Is it necessary | Type | Description | Default values | Range of values |
---|---|---|---|---|---|
currencys | false | string | Currency | NA | BTC,ETH... |
Response:
{
"msg": "success",
"code": "0",
"data": {
"WALLET": [
{
"currency": "BTC",
"available": "0.1",
"frozen": "0.1",
"total": "0.2"
},
{
"currency": "USDT",
"available": "1.2",
"frozen": "0",
"total": "1.2"
}
]
}
}
Response data
Field names | Data Types | Description |
---|---|---|
WALLET | string | Wallet account type, WALLET/OTC/GENERAL |
Fields in the account
Field names | Data Types | Description |
---|---|---|
currency | string | Currency |
available | decimal | Available balance |
frozen | decimal | Frozen balance |
total | decimal | Full balance |
Top-ups and withdrawals
Deposit Address Lookup
API Key Permissions: Read
HTTP requests
- GET
/v2/u/wallet/address
.
curl "https://api.bkex.com/v2/u/wallet/address?currency=ETH"
Request Parameters
Field names | Is it necessary | Type | Field Description | Range of values |
---|---|---|---|---|
currency | true | string | Currency | ETH,BTC... |
Response:
{
"msg": "success",
"code": "0",
"data": [
{
"currency": "BTC",
"address": "1m4k2yUKTSrX6SM9FGgvwMybAbYtRVi2N",
"memo": ""
}
]
}
Response Data
Field names | Data Types | Field Description | |
---|---|---|---|
currency | string | Currency | |
address | string | Deposit Address | |
memo | string | Deposit Address Labels |
Recharge Record
API Key Permissions: Read
Checking Recharge Record
HTTP requests
- GET
/v2/u/wallet/depositRecord
.
Request Parameters
Parameter Name | Is it necessary | Type | Description | Default values | Range of values |
---|---|---|---|---|---|
currency | true | string | Currency | BTC | |
from | false | long | Beginning timestamp, in milliseconds | 1532331295000 | |
to | false | long | End timestamp, in milliseconds | .1532331295000 | |
Size | false | integer | Query record size | 10 | 10-100 |
page | false | integer | Number of pages | 1 |
Response:
{
"msg": "success",
"code": "0",
"data": [
{
"id": "117121312313",
"currency": "BTC",
"hash": "6ea95a124371c685e000b968ace1c024f2d67bf73a97b43cf94ab6572fa529",
"volume": 0.1234,
"fromAddress": "1LMhQnpvwiiRSn2NPPxaQLVyBzdGcXvi",
"toAddress": "1LMhQnpvwiiRSn2NPPxaQLVyBzdGcXvi",
"confirmed": 3,
"state": 0,
"createTime": 1532331295000
}
]
}
Response data
Parameter Name | Data Types | Description |
---|---|---|
id | string | Business ID |
currency | string | Currency |
hash | string | Exchange Hash |
volume | decimal | Number of pieces |
fromAddress | string | Beginning address |
toAddress | string | Top-up Address |
confirmed | integer | Certainties |
state | integer | Status |
createTime | .long | Initiation time |
- Top-up status definition:
Status | Description |
---|---|
-1 | Failure |
0 | Acknowledged |
3 | Confirmation in progress |
Withdraw records
.API Key Permissions: Read
Check your cash withdrawal history
HTTP requests
- GET
/v2/u/wallet/withdrawRecord
.
Request Parameters
Parameter Name | Is it necessary | Type | Description | Default values | Range of values |
---|---|---|---|---|---|
currency | false | string | Currency | BTC | |
from | false | long | Beginning timestamp, in milliseconds | 1532331295000 | |
to | false | long | Timestamp | .1532331295000 | |
Size | false | integer | Query record size | 10 | 10-100 |
page | false | integer | Number of pages | 1 |
Response:
{
"msg": "success",
"code": "0",
"data": [
{
"id": "117121312313",
"currency": "BTC",
"hash": "6ea95a124371c685e000b968ace1c024f2d67bf73a97b43cf94ab6572fa529",
"volume": 0.1234,
"fromAddress": "1LMhQnpvwiiRSn2NPPxaQLVyBzdGcXvi",
"toAddress": "1LMhQnpvwiiRSn2NPPxaQLVyBzdGcXvi",
"fee": 0.0001,
"state": 0,
"createTime": 1532331295000
}
]
}
Response Data
Parameter Name | Data Types | Description |
---|---|---|
id | string | Business ID |
currency | string | Currency |
hash | string | Exchange Hash |
volume | decimal | Number of pieces |
fromAddress | string | Beginning address |
toAddress | string | Top-up Address |
fee | decimal | Number of fees |
state | integer | Status |
createTime | .long | Initiation time |
- Drawing status definition:
Status | Description |
---|---|
-1 | Failure |
0 | Acknowledged |
1 | Submitted |
2 | Cancelled |
5 | Awaiting confirmation |
Spot trading
Order
.API Key Permissions: Transactions
Send a new order
HTTP request
- POST
/v2/u/order/create
{
"volume": 0.1,
"price": 7000.12,
"direction": "ASK",
"symbol": "BTC_USDT",
"source": "WALLET",
"type": "STOP_LIMIT",
"stopPrice": 6900,
"operator": "gte",
}
Request Parameters
Parameter Name | Data Types | Is it necessary | Default values | Description |
---|---|---|---|---|
symbol | string | true | NA | BTC_USDT |
volume | decimal | true | NA | Number of orders placed |
price | decimal | false | NA | Order price |
direction | string | true | NA | Direction of order, ASK, BID |
source | string | false | WALLET | Order source account, default is wallet account (bar account will be supported later) |
type | string | false | LIMIT | Order type, which can be (LIMIT,LIMIT_MAKER, MARKET, STOP_LIMIT) |
stopPrice | decimal | false | NA | Stop-limit Order Trigger Price |
operator | string | false | NA | Stop-limit order trigger price operator gte - greater than and equal (>=), lte - less than and equal (<=) |
Response:
{
"code": 0,
"msg": "Create Order Successfully",
"data": "20180623123334234234"
}
Response data
code is 0, which means the order is successful, and the returned data object is the order number after the order is successful.
Cancel Order
API Key Permissions: Transactions
This interface sends a request to cancel the order.
HTTP requests
- POST
/v2/u/order/cancel
Request Parameters
Parameter Name | Is it necessary | Type | Description |
---|---|---|---|
orderId | true | string | Order ID |
Response:
{
"code": 0,
"msg": "success",
"data": "201908231244212312123"
}
Response Data
code is 0, which means the cancellation was successful, and data returns the order Id
Query the current unfinished order
.API Key Permissions: Read
{
"symbol": "BTC_USDT",
"direction": "ASK",
"source": "WALLET",
"type": "LIMIT",
"sortingWay": "TIME_ASC",
"page": 1,
"size": 10
}
HTTP requests
- GET
/v2/u/order/openOrders
Request Parameters
Parameter Name | Data Types | Is it necessary | Default values | Description |
---|---|---|---|---|
symbol | string | true | NA | Trade pair, BTC_USDT |
direction | string | false | NA | Specify orders that return only one direction, sell as ASK, buy as BID |
source | string | false | WALEET | Order Source Account Type |
type | string | false | NA | Order Type |
sortingWay | string | false | NA | Sorting rules, with values (TIME_ASC, TIME_DESC, PRICE_ASC, PRICE_DESC) |
page | integer | false | 1 | Query page number |
Size | integer | false | 10 | Returns the number of orders, maximum 100. |
Response:
{
"msg": "success",
"code": "0",
"data": [
{
"id": "201806232342422123123",
"symbol": "BTC_USDT",
"type": "STOP_LIMIT",
"totalVolume": 1.123,
"price": "7000.3241",
"direction": "ASK",
"dealVolume": 0.1,
"frozenVolumeByOrder": 1.123,
"source": WALLET,
"stopPrice": 6900,
"operator": ">=",
"status": 0,
"createdTime": 1530604762277
}
]
}
Response data
Field names | Data Types | Description |
---|---|---|
id | string | Order id |
symbol | string | Trading pair, e.g. BTC_USDT |
price | string | Order price |
createdTime | .long | Time stamp of order creation time in milliseconds | .
type | string | Order Type |
totalVolume | decimal | Total number of orders placed |
direction | string | Order Direction |
dealVolume | decimal | Number traded |
frozenVolumeByOrder | decimal | Frozen quantity of orders placed |
source | string | Order Source Account Type |
stopPrice | decimal | Stop-limit Order Trigger Price |
operator | string | Stop-limit Order Operator |
status | string | 0: Pending orders, 1: Completed, 2: Cancelled, 3: Partially filled |
Query Unfinished Order Details
API Key Permissions: Read
HTTP request
- GET
/v2/u/order/openOrder/detail
Request Parameters
Parameter Name | Data Types | Is it necessary | Default values | Description |
---|---|---|---|---|
orderId | string | true | NA | Order ID |
Response:
{
"msg": "success",
"code": "0",
"data":{
"id": "201806232342422123123",
"symbol": "BTC_USDT",
"type": "STOP_LIMIT",
"totalVolume": 1.123,
"price": "7000.3241",
"direction": "ASK",
"dealVolume": 0.1,
"frozenVolumeByOrder": 1.123,
"source": "WALLET",
"stopPrice": 6900,
"operator": ">=",
"status": 0,
"createdTime": 1530604762277,
"updateTime": 1530604762277
}
}
Response data
Field names | Data Types | Description |
---|---|---|
id | string | Order id |
symbol | string | Trading pair, e.g. BTC_USDT |
price | string | Order price |
createdTime | .long | Time stamp of order creation time in milliseconds | .
type | string | Order Type |
totalVolume | decimal | Total number of orders placed |
direction | string | Order Direction |
dealVolume | decimal | Number traded |
frozenVolumeByOrder | decimal | Frozen quantity of orders placed |
source | string | Order Source Account Type |
stopPrice | decimal | Stop-limit Order Trigger Price |
operator | string | Stop-limit Order Operator |
status | string | 0: Pending, 3: Partially Sold |
createdTime | .long | Pending order time |
updateTime | .long | Last updated | .
Query history orders
API Key Permissions: Read
{
"symbol": "BTC_USDT",
"direction": "ASK",
"type": "LIMIT",
"sortingWay": "TIME_ASC",
"filterCancelAll": true,
"page": 1,
"size": 10,
"startTime": 1532331295000,
"endTime": 1532331295000
}
HTTP requests
- GET
/v2/u/order/historyOrders
.
Request Parameters
Parameter Name | Data Types | Is it necessary | Default values | Description |
---|---|---|---|---|
symbol | string | true | NA | Trade pair, BTC_USDT |
direction | string | false | NA | Specify orders that return only one direction, sell as ASK, buy as BID | type | string | false | NA | Order Type | sortingWay | string | false | NA | Sorting rules, with values (TIME_ASC, TIME_DESC, PRICE_ASC, PRICE_DESC) | filterCancelAll | boolean | false | NA | Does it filter orders that are not filled at all | ?
page | integer | false | 1 | Query page number |
Size | integer | false | 10 | Returns the number of orders, maximum 100. |
startTime | long | false | NA | Beginning time stamp in milliseconds |
endTime | long | false | NA | Cut-off time stamp in milliseconds |
Response:
{
"msg": "success",
"code": "0",
"data": [
{
"id": "201806232342422123123",
"symbol": "BTC_USDT",
"type": "STOP_LIMIT",
"totalVolume": 1.123,
"price": "7000.3241",
"direction": "ASK",
"dealVolume": 0.1,
"frozenVolumeByOrder": 1.123,
"dealAvgPrice": 2341,
"source": "WALEET",
"stopPrice": 6900,
"operator": ">=",
"createdTime": 1530604762277,
"updateTime": 1530604762277,
"status": 0
}
]
}
Response data
Field names | Data Types | Description |
---|---|---|
id | string | Order id |
symbol | string | Trading pair, e.g. BTC_USDT |
price | string | Order price |
type | string | Order Type |
totalVolume | decimal | Total number of orders placed |
direction | string | Order Direction |
dealVolume | decimal | Number traded |
frozenVolumeByOrder | decimal | Frozen quantity of orders placed |
dealAvgPrice | decimal | Average transaction price | source | decimal | Order Source Account Type |
stopPrice | decimal | Stop-limit Order Trigger Price |
operator | string | Stop-limit Order Operator |
createdTime | .long | Time stamp of order creation time in milliseconds | .
updateTime | .long | Time stamp of the last modification time of the order in milliseconds | .
status | string | 1: completed, 2: withdrawn |
Batch order
API Key Permissions: Transactions
Up to 20 orders in a batch
[
{
"volume": 0.1,
"price": 7000.12,
"direction": "ASK",
"symbol": "BTC_USDT",
"source": "WALLET",
"type": "STOP_LIMIT",
"stopPrice": "6900",
"operator": "lte"
},
"volume": 0.1,
"price": 7000.12,
"direction": "ASK",
"symbol": "BTC_USDT",
"source": "WALEET",
"type": "STOP_LIMIT",
"stopPrice": "6900",
"operator": "lte"
}
]
HTTP requests
- POST
/v2/u/order/batchCreate
Request Parameters
Parameter Name | Is it necessary | Type | Description | Default values | Range of values |
---|---|---|---|---|---|
orders | true | string | JSON format string |
Response:
{
"code":0,
"msg": "success",
"data":
{
"success": 2,
"fail": 0,
"results": ["2019062312313131231","2019063123131312313"]
}
}
Response Data
Parameter Name | Data Types | Description | |
---|---|---|---|
success | integer | Number of successes | |
fail | integer | Number of failures | |
results | string | Sets of successful order numbers | .
Batch order cancellation
API Key Permissions: Transactions
.This interface sends cancellation requests for multiple orders (based on id) at the same time.
HTTP requests
- POST
/v2/u/order/batchCancel
[
"2018062321121231231","2018062321121231232"
]
Request Parameters
Parameter Name | Is it necessary | Type | Description | Default values | Range of values |
---|---|---|---|---|---|
orders | true | string | JOSN format string, order ID set:["2018062321121231231"] , "2018062321121231231"] |
Response:
{
"code": 0,
"msg": "success",
"data":
{
"success": 2,
"fail": 0,
"results": ["2019062312313131231"]," 2019063123131312313"]
}
}
Response Data
Parameter Name | Data Types | Description | |
---|---|---|---|
success | integer | Number of successes | |
fail | integer | Number of failures | |
results | string | A collection of order numbers for successful order cancellation | .
Contract transaction
Public Information Interface
Get depth data
API Key Permissions: no signature required.
Frequency limit (according to IP limit): 20 times / S.
HTTP request
- GET
/fapi/v2/market/depth
curl "https://fapi.bkex.com/fapi/v2/market/depth?symbol=btc_usdt"
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | query | string | true | none | Transaction pair | |
limit | query | int | false | none | 交易对 | 默认20,{5, 10, 20, 50,100,200} |
Response:
{
"code": 0,
"msg": "success",
"data": {
"bid": [
[
"40522.82",
"3.65"
],
[
"40521.18",
"4.07"
]
],
"ask": [
[
"40525.66",
"2.82"
],
[
"40527.3",
"4.49"
]
]
}
}
Response Data
Parameter Name | Data Types | Examples | Description |
---|---|---|---|
bid | array | ["40522.82", "3.65"] | Buying direction: [price, quantity] |
ask | array | ["40525.66", "2.82"] | Selling direction: [price, quantity] |
Get depth data(all symbol)
API Key Permissions: no signature required.
Frequency limit (according to IP limit): 20 times / S.
HTTP request
- GET
/fapi/v2/market/deepAll
curl "https://fapi.bkex.com/fapi/v2/market/deepAll?limit=5"
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
limit | query | int | false | none | 交易对 | 默认10,{5, 10, 20, 50} |
Response:
{
"code": 0,
"msg": "success",
"data": [
{
"symbol": "atom_usdt",
"bid": [
[
"9.870000",
"2459"
],
[
"9.864000",
"1332"
]
],
"ask": [
[
"9.874000",
"1065"
],
[
"9.875000",
"1331"
]
]
},
{
"symbol": "uni_usdt",
"bid": [],
"ask": []
}
]
}
Response Data
Parameter Name | Data Types | Examples | Description |
---|---|---|---|
symbol | string | btc_usdt | 币对名称 |
bid | array | ["40522.82", "3.65"] | Buying direction: [price, quantity] |
ask | array | ["40525.66", "2.82"] | Selling direction: [price, quantity] |
Quotes interface
Get K-line data
API Key permissions: no signature required
Frequency limit (according to IP limit): 20 times / s.
HTTP Request
- GET
/fapi/v2/market/candle
curl "https://fapi.bkex.com/fapi/v2/market/candle?symbol=btc_usdt&period=M1"
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | query | string | true | none | Transaction pair | |
period | query | string | true | none | Return the time granularity of data, that is, the time interval of each candle | Value range:M1 M5 M15 M30 H1 H4 H6 D1 |
start | query | string | false | none | Query start timestamp, in milliseconds | |
end | query | string | false | none | Query deadline timestamp, in milliseconds | |
count | query | string | false | Default 200 | Return the number of K-line data | Value range [1, 500] |
Response:
{
"code": 0,
"msg": "success",
"data": [
{
"symbol": "btc_usdt",
"amount": "0.04",
"volume": "1618.83",
"open": "40488.78",
"close": "40469.88",
"high": "40488.78",
"low": "40469.88",
"ts": 1650937980000
},
{
"symbol": "btc_usdt",
"amount": "0.04",
"volume": "1619.55",
"open": "40469.36",
"close": "40488.78",
"high": "40488.95",
"low": "40469.36",
"ts": 1650937920000
},
{
"symbol": "btc_usdt",
"amount": "0.02",
"volume": "809.35",
"open": "40490.47",
"close": "40469.36",
"high": "40490.47",
"low": "40464.03",
"ts": 1650937860000
}
]
}
Response data
Parameter Name | Data Types | Examples | Description |
---|---|---|---|
symbol | string | btc_usdt | Transaction pair |
amount | string | "0.04" | Transaction volume in base currency |
volume | string | "809.35" | Transaction volume in quotation currency |
open | string | "40490.47" | Opening price at this stage |
close | string | "40469.36" | Closing price at this stage |
high | string | "40490.47" | Maximum price at this stage |
low | string | "40464.03" | Lowest price at this stage |
ts | long | 1650937860000 | Timestamp of the beginning of this phase |
Get the latest price
API Key Permissions: no signature required
Frequency limit (according to IP limit): 50 times / s.
HTTP request
- GET
/fapi/v2/market/ticker/price
curl "https://fapi.bkex.com/fapi/v2/market/ticker/price?symbol=btc_usdt"
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | query | string | false | NA | Transaction pair; If it is not filled in, the data of all currency pairs will be obtained |
Response:
{
"code": 0,
"msg": "success",
"data": [
{
"symbol": "btc_usdt",
"price": "40557.23"
}
]
}
Response Data
Parameter Name | Data Types | Examples | Description |
---|---|---|---|
symbol | string | btc_usdt | Transaction pair |
price | string | "40557.23" | price |
Get ticker data
API Key Permissions: no signature required
Frequency limit (according to IP limit): 20 times / s.
HTTP request
- GET
/fapi/v2/market/tickers
curl "https://fapi.bkex.com/fapi/v2/market/tickers?symbol=btc_usdt"
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | query | string | false | NA | Transaction pair; If it is not filled in, the data of all currency pairs will be obtained |
Response:
{
"code": 0,
"msg": "success",
"data": [
{
"symbol": "btc_usdt",
"amount":"2553.28",
"volume":"60609744.48039",
"open":"23775.65",
"close":"23745.15",
"high":"23852.37",
"low":"23561.12",
"lastPrice":"23745.15",
"lastAmount":"0.06",
"lastTime":1659336982046,
"change":"-0.12"
}
]
}
Response Data
Parameter Name | Data Types | Examples | Description |
---|---|---|---|
symbol | string | btc_usdt | Transaction pair |
amount | string | "0.04" | Accumulated trading volume of last 24 hours (rotating 24h), in base currency |
volume | string | "809.35" | Accumulated trading value of last 24 hours (rotating 24h), in quote currency |
open | string | "40490.47" | Opening price in the last 24 hours |
close | string | "40469.36" | Closing price in the last 24 hours |
high | string | "40490.47" | Highest price in the last 24 hours |
low | string | "40464.03" | Lowest price in the last 24 hours |
lastPrice | string | "40469.36" | Last traded price |
lastAmount | string | "0.08" | Last traded size |
lastTime | long | 1650937860000 | Timestamp of the latest transaction |
change | string | "-0.18" | Range of change (plus or minus percentage, such as -0.18 means a decrease of 0.18%) |
Get transaction history
API Key permissions: no signature required
1. Frequency limit (according to IP limit): 20 times / s.
2. The maximum number of returned entries is 200.
HTTP requests
- GET
/fapi/v2/market/deals
curl "https://fapi.bkex.com/fapi/v2/market/deals?symbol=btc_usdt"
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | query | string | true | NA | Transaction pair |
Response:
{
"code": 0,
"msg": "success",
"data": [
{
"symbol": "btc_usdt",
"amount": "0.01",
"price": "40469.36",
"side": "sell",
"time": 1650937919615
},
{
"symbol": "btc_usdt",
"amount": "0.01",
"price": "40464.03",
"side": "sell",
"time": 1650937892485
}
]
}
Response Data
Parameter Name | Data Types | Examples | Description |
---|---|---|---|
symbol | string | btc_usdt | Transaction pair |
amount | string | "0.01" | Transaction volume in base currency |
price | string | "40464.03" | Transaction price in quotation currency |
side | string | "sell" | Trading direction: "sell" or "buy", "buy" means buy, "sell" means sell |
time | long | 1650937892485 | Time stamp at closing |
Get all transaction pair information
API Key Permissions: no signature required.
Limit (according to IP limit): 50 times / s.
HTTP request
- GET
/fapi/v2/market/symbols
curl "https://fapi.bkex.com/fapi/v2/market/symbols"
Request Parameters
No parameters
Response:
{
"code": 0,
"msg": "success",
"data": [
{
"symbol": "xrp_usdt",
"supportTrade": true,
"volumePrecision": 0,
"pricePrecision": 4,
"marketMiniAmount": "100",
"limitMiniAmount": "100"
},
{
"symbol": "ltc_usdt",
"supportTrade": true,
"volumePrecision": 1,
"pricePrecision": 2,
"marketMiniAmount": "0.1",
"limitMiniAmount": "0.1"
}
]
}
Response Data
Parameter Name | Data Types | Examples | Description |
---|---|---|---|
symbol | tring | btc_usdt | Transaction pair |
supportTrade | boolean | true | Whether transactions are supported |
volumePrecision | int | 1 | Accuracy of transaction to order quantity (digits after decimal point) |
pricePrecision | int | 2 | Accuracy of transaction to order price (digits after decimal point) |
marketMiniAmount | string | "0.1", | Minimum order quantity of transaction to market price |
limitMiniAmount | string | "0.1", | Minimum order quantity of transaction price limit |
Test server connectivity
API Key Permissions: no signature required.
Limit (according to IP limit):20 times /s.
HTTP request
- GET
/fapi/v2/server/ping
curl "https://fapi.bkex.com/fapi/v2/server/ping"
Request Parameters
nothing
Response:
{
"code": 0,
"msg": "success",
"data": {
"serverTime": 1658368263053
}
}
Response data
Parameter Name | Data Types | Examples | Description |
---|---|---|---|
serverTime | long | 1658368263053 | Server time |
Get server time
API Key Permissions: no signature required.
Limit (according to IP limit):20 times /s.
HTTP requests
- GET
/fapi/v2/server/ping
curl "https://fapi.bkex.com/fapi/v2/server/time"
Request Parameters
nothing
Response:
{
"code": 0,
"msg": "success",
"data": {
"serverTime": 1658368263053
}
}
Response data
Parameter Name | Data Types | Examples | Description |
---|---|---|---|
serverTime | long | 1658368263053 | Server time |
Get tag price
API Key Permissions: no signature required.
Limit (according to IP limit):20 times /s.
HTTP request
- GET
/fapi/v2/market/index
curl "https://fapi.bkex.com/fapi/v2/market/index?symbol=btc_usdt"
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | query | string | false | NA | Transaction pair (if no symbol is sent, the marked price of all transaction pairs is returned) |
Response:
{
"code": 0,
"msg": "success",
"data": [
{
"symbol": "btc_usdt",
"marketPrice": "23296.63"
}
]
}
Response data
Parameter Name | Data Types | Examples | Description |
---|---|---|---|
symbol | string | btc_usdt | Trading pair |
marketPrice | string | 23296.63 | Mark price |
Get fund rate
API Key Permissions: no signature required.
Limit (according to IP limit):20 times /s.
HTTP request
- GET
/fapi/v2/market/fundingRate
curl "https://fapi.bkex.com/fapi/v2/market/fundingRate?symbol=eth_usdt&limit=100"
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | query | string | true | NA | Trading pair | |
startTime | query | string | false | NA | Start time | |
endTime | query | string | false | NA | End time | |
limit | query | string | fase | NA | Default value: 100 maximum value: 1000 |
Response:
{
"code": 0,
"msg": "success",
"data": [
{
"symbol": "eth_usdt",
"rate": "0.0000129",
"time": 1658370002127
}
]
}
Response data
Parameter Name | Data Types | Examples | Description |
---|---|---|---|
symbol | string | btc_usdt | Trading pair |
marketPrice | string | 0.0000129 | Capital rate |
time | long | 1658370002127 | time |
- If neither starttime nor Endtime is sent, the latest limit pieces of data are returned.
- If the amount of data between starttime and Endtime is greater than limit, the data in the case of starttime + limit is returned.
Get risk limits
API Key Permissions: no signature required.
Limit (according to IP limit):20 times /s.
HTTP request
- GET
/fapi/v2/market/riskLimit
curl "https://fapi.bkex.com/fapi/v2/market/riskLimit?symbol=eth_usdt"
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | query | string | true | NA | Trading pair |
Response:
{
"code": 0,
"msg": "success",
"data": [
{
"symbol": "btc_usdt",
"minValue": "0",
"maxValue": "500000",
"maxLeverage": 100,
"maintenanceMarginRate": "0.005"
}
]
}
Response data
Parameter Name | Data Types | Examples | Description |
---|---|---|---|
symbol | string | btc_usdt | Trading pair |
minValue | string | 0 | Minimum position value |
maxValue | string | 5000 | Maximum position value |
maxLeverage | int | 100 | Maximum available leverage |
maintenanceMarginRate | string | 0.005 | Maintain margin rate |
Get account balance
HTTP Request
- GET
/fapi/v2/account/balance
curl "https://fapi.bkex.com/fapi/v2/account/balance"
Request Parameters
None
Response:
{
"code": 0,
"msg": "success",
"data": {
"balance": "0",
"frozen": "0",
"margin": "0",
"point": "0",
"loans": "0",
"profit": "0",
"unProfit": "0",
"unLosses": "0",
"coin": "usdt"
}
}
Response data
Parameter Name | Data Types | Examples | Description |
---|---|---|---|
balance | string | 0 | balance |
frozen | string | 0 | They are frozen |
margin | string | 0 | Margin for holding positions |
point | string | 0 | integral |
loans | string | 0 | loan |
profit | string | 0 | No profit or loss was realized |
unProfit | string | 0 | Floating Profit |
unLosses | string | 0 | Floating Loss |
coin | string | usdt | currency |
Set the opening leverage
HTTP Request
- POST
/fapi/v2/account/setLeverage
curl "https://fapi.bkex.com/fapi/v2/account/riskLimit"
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | body | string | true | NA | Trading pair | |
leverage | body | int | true | NA | leverage | 1-100 |
Response:
{
"code": 0,
"msg": "success",
"data":{
"symbol": "btc_usdt",
"leverage": 100,
}
}
Response data
Parameter Name | Data Types | Examples | Description |
---|---|---|---|
symbol | string | btc_usdt | Trading pair |
leverage | int | 100 | leverage1-100 |
Get user positions
HTTP Request
- GET
/fapi/v2/account/position
curl "https://fapi.bkex.com/fapi/v2/account/position"
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | query | string | true | NA | Trading pair | |
positionID | query | string | false | NA | Position id |
Response:
{
"code": 0,
"msg": "success",
"data": [
{
"positionID": "220621102231380140005",
"symbol": "btc_usdt",
"side":1,
"leverage":20,
"price":"10000.101",
"amount":"10",
"frozenAmount":"1",
"margin":"200",
"triggerType":1,
"spPrice":"0",
"slPrice":0,
"openProfit":"0",
"updatedAt":1661763669950
}
]
}
Response data
Parameter Name | Data Types | Examples | Description |
---|---|---|---|
positionID | string | 220621102231380140005 | Position id |
symbol | string | btc_usdt | Trading pair |
side | int | 1 | Direction:1-buy,2-Sell |
leverage | int | 20 | leverage |
price | string | 0 | Average transaction price |
amount | string | 1 | Open interest |
frozenAmount | string | 0 | Closed frozen amount |
margin | string | 0 | Position margin |
triggerType | int | 1 | Take profit and stop loss trigger type: 1-transaction price,2-index price |
spPrice | string | 0 | Take profit price |
slPrice | string | 0 | Stop price |
openProfit | string | 0 | Unrealized profit and loss |
updatedAt | int | 0 | Update time |
spSlModel | int | 1 | Take Profit Stop Loss Mode. 1-All take profit and stop loss 2-Partial take profit stop loss |
spType | int | 1 | Take Profit Type. 0-no take profit set 1-limit price 2-market price |
slType | int | 1 | Stop loss type. 0-no take profit set 1-limit price 2-market price |
spTriggerPrice | string | 123.12 | Take Profit Order Price |
slTriggerPrice | string | 123.12 | Stop loss order price |
<spSlPartData> | array | Partial take profit and stop loss data | |
id | int | 220621102231380142311 | Partial Stop Loss Stop Profit Stop Loss ID |
triggerType | int | 1 | Take profit and stop loss trigger type |
spPrice | string | 123.12 | Take Profit Price |
slPrice | string | 123.12 | Stop price |
amount | string | 3.12 | Partial Take Profit Stop Loss Quantity |
spType | int | 1 | Stop loss type |
slType | int | 1 | top loss type |
spTriggerPrice | string | 123.12 | Take Profit Order Price |
slTriggerPrice | string | 123.12 | Stop loss order price |
</spSlPartData> |
Get account transaction history
HTTP Request
- GET
/fapi/v2/account/order
curl "https://fapi.bkex.com/fapi/v2/account/order"
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | query | string | true | NA | Trading pair | |
startTime | query | int | false | NA | start time ms | |
endTime | query | int | false | NA | The end time in ms. If both startTime and endTime are not sent, only the data of the last 7 days will be returned. The maximum interval between startTime and endTime is 7 days | |
limit | query | int | false | 500 | Number of result sets returned Default: 500 Maximum: 1000 |
Response:
{
"code": 0,
"msg": "success",
"data": [
{
"positionID": "220621102231380140005",
"symbol": "btc_usdt",
"side":1,
"leverage":20,
"price":"10000.101",
"amount":"10",
"frozenAmount":"1",
"margin":"200",
"triggerType":1,
"spPrice":"0",
"slPrice":0,
"openProfit":"0",
"updatedAt":1661763669950
}
]
}
Response data
Parameter Name | Data Types | Examples | Description |
---|---|---|---|
positionID | string | 220621102231380140005 | Position id |
symbol | string | btc_usdt | Trading pair |
side | int | 1 | Direction:1-buy,2-Sell |
leverage | int | 20 | leverage |
price | string | 0 | Average transaction price |
amount | string | 1 | Open interest |
frozenAmount | string | 0 | Closed frozen amount |
margin | string | 0 | Position margin |
triggerType | int | 1 | Take profit and stop loss trigger type: 1-transaction price, 2-index price |
spPrice | string | 0 | Take Profit Price |
slPrice | string | 0 | Stop price |
openProfit | string | 0 | Unrealized profit and loss |
updatedAt | int | 0 | Update time |
Query account funds statement
HTTP Request
- GET
/fapi/v2/account/balanceRecord
curl "https://fapi.bkex.com/fapi/v2/account/balanceRecord"
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | query | string | false | NA | Trading pair | |
event | query | int | false | NA | Bill type: 1: recharge, 2: debit, 3: transfer in, 4: transfer out, 9: fund charges, 201: open long, 202: open short, 204: close long, 205: close short, 206: liquidate (The event field is not sent, and returns the profit and loss capital flow of all types of accounts) | |
startTime | query | int | false | NA | Start time ms | |
endTime | query | int | false | NA | End time ms, If both startTime and endTime are not sent, only the data of the last 7 days will be returned, Only keep the last 3 months of data | |
limit | query | int | false | 500 | Number of result sets returned Default: 500 Maximum: 1000 |
Response:
{
"code": 0,
"msg": "success",
"data": [
{
"id": "220621102231380140005",
"symbol": "btc_usdt",
"event":1,
"amount":"100",
"coin":"usdt",
"note":"",
"updatedAt":1661763669950
}
]
}
Response data
Parameter Name | Data Types | Examples | Description |
---|---|---|---|
id | string | 220621102231380140005 | Transaction id |
symbol | string | btc_usdt | Trading pair |
event | int | 1 | Bill type: 1: recharge, 2: debit, 3: transfer in, 4: transfer out, 9: fund charges, 201: open long, 202: open short, 204: close long, 205: close short, 206: liquidate |
amount | string | 100 | Amount |
coin | string | usdt | Currency |
note | string | Remark | |
updatedAt | int | 0 | Update time |
User forced liquidation order history
HTTP Request
- GET
/fapi/v2/account/orderForced
curl "https://fapi.bkex.com/fapi/v2/account/orderForced"
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | query | string | false | NA | Trading pair | |
startTime | query | int | false | NA | Start time ms | |
endTime | query | int | false | NA | The end time in ms. If neither startTime nor endTime is sent, only the data of the last 7 days will be returned. The interval between startTime and endTime cannot be greater than 7 days. | |
limit | query | int | false | 50 | Number of result sets returned Default: 50 Maximum: 100 | |
action | query | int | false | 4 | Liquidation type: 4-liquidation, 5-FOK liquidation, 6-ADL automatic lightening, 9-wearing |
Response:
{
"code": 0,
"msg": "success",
"data": [
{
"id": "22052621161573001012345840025",
"symbol": "eth_usdt",
"type": 2,
"action": 6,
"side": 1,
"positionID": "220526154001021010017",
"price": "0",
"leverage": 21,
"amount": "0.1",
"frozen": "0",
"filledAmount": "0.1",
"filledPrice": "1984.5",
"filledValue": "198.45",
"triggerType": 2,
"spPrice": "0",
"slPrice": "0",
"createdAt": 1661822066000,
"updatedAt": 1653570975733,
"state": 1,
"profit": "-0.01",
"fee": "0.099225",
"pointFee": "0",
"pointProfit": "0",
"closePrice": "0"
}
]
}
Response data
Parameter Name | Data Types | Examples | Description |
---|---|---|---|
id | string | 220621102231380140005 | Order id |
symbol | string | btc_usdt | Trading pair |
type | int | 1 | Order Type: 1-Limit, 2-Market |
action | int | 4 | Liquidation type: 4-liquidation, 5-FOK liquidation, 6-ADL automatic lightening, 9-wearing |
side | int | 1 | Trading direction: 1-buy, 2-sell |
positionID | string | 1 | Position ID |
price | string | 100 | Order price, limit order is valuable |
leverage | int | 20 | Leverage |
amount | string | 1 | Order quantity |
frozen | string | 1 | Freeze Margin |
filledAmount | string | 1 | Completed |
filledPrice | string | 1 | Average transaction price |
filledValue | string | 1 | Transaction value |
triggerType | int | 1 | Take profit and stop loss trigger type: 1- transaction price, 2- index price |
spPrice | string | 1 | Default Take Profit Price |
slPrice | string | 1 | Default stop price |
state | int | 1 | Status: 1-normal, 2-completed, 3-cancelled, 4-partly traded, 5-partly traded cancelled, 6-cancelled |
profit | string | 1 | Realized profit and loss |
fee | string | 1 | Handling fee |
pointFee | string | 1 | Points (bonus) fee deduction |
pointProfit | string | 1 | Points (bonus) profit and loss deduction |
closePrice | string | 1 | Bankruptcy price |
updatedAt | int | 0 | Update time |
createdAt | int | 0 | Creation time |
Set position mode
HTTP request
- POST
/fapi/v2/position/update
Request
{
"positionClass": 2
"recvWindow": 7796,
"timestamp": 1662005739,
}
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
positionClass | body | int | true | NA | position mode | 1:sub-position 2:merge-position | recvWindow | body | int | false | 5000 | time interval window (seconds) | 1 - 60000 | timestamp | body | int | true | NA | timestamp |
Response:
{
"code": 0,
"msg": "success"
}
Response Data
None
Get position mode
HTTP request
- GET
/fapi/v2/position/info
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
recvWindow | query | int | false | 5000 | time interval window (seconds) | 1 - 60000 | timestamp | query | int | true | NA | timestamp |
Response:
{
"code": 0,
"msg": "success",
"data": 2
}
Response Data
Parameter Name | Data Types | Description |
---|---|---|
data | int | 1:sub-position 2:merge-position |
Set Take Profit and Stop Loss
HTTP request
- POST
/fapi/v2/position/setSpSl
Request
{
"slPrice": "19000",
"spPrice": "21500",
"isSetSl": true,
"isSetSp": true,
"positionID": "220715100013671016701",
"triggerType": 1,
"recvWindow": 32705,
"timestamp": 1662005739
}
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
slPrice | body | string | false | NA | stop price | spPrice | body | string | false | NA | take profit price | isSetSl | body | bool | false | NA | whether to set stop loss | isSetSp | body | bool | false | NA | whether to set take profit | positionID | body | string | true | NA | position id | triggerType | body | int | true | NA | trigger type | 1:ticker price 2:index price | spSlModel | body | int | false | 1 | Take Profit Stop Loss Mode. | 1-All take profit and stop loss 2-Partial take profit stop loss | amount | body | string | false | NA | Amount of partial take profit and stop loss.(used when partial take profit and stop loss) | spType | body | int | false | NA | Stop profit type | 1: limit price 2: market price | slType | body | int | false | NA | Stop loss type | 1: limit price 2: market price | spTriggerPrice | body | string | false | NA | Take Profit Order Price | slTriggerPrice | body | string | false | NA | Stop loss order price | recvWindow | body | int | false | 5000 | time interval window (seconds) | 1 - 60000 | timestamp | body | int | true | NA | timestamp |
Response:
{
"code": 0,
"msg": "success",
"data": {
"id": "220901120303441011478",
"symbol": "btc_usdt",
"side": 1,
"leverage": 20,
"openPrice": "20046.71",
"amount": "1",
"frozenAmount": "0",
"margin": "1002.08",
"triggerType": 1,
"spPrice": "21500",
"slPrice": "19000"
}
}
Response Data
Parameter Name | Data Types | Description |
---|---|---|
id | string | position id |
symbol | string | trading symbol |
side | int | order side. 1:buy 2:sell |
leverage | int | leverage |
openPrice | string | Average transaction price |
amount | string | The amount which has been filled |
frozenAmount | string | Closed frozen amount |
margin | string | position margin |
triggerType | int | Take Profit and Stop Loss Trigger Type. 1:ticker price 2:index price |
spPrice | string | take profit price |
slPrice | string | stop price |
spSlModel | int | Take Profit Stop Loss Mode. 1-All take profit and stop loss 2-Partial take profit stop loss |
spType | int | Take Profit Type. 0-no take profit set 1-limit price 2-market price |
slType | int | Stop loss type. 0-no take profit set 1-limit price 2-market price |
spTriggerPrice | string | Take Profit Order Price |
slTriggerPrice | string | Stop loss order price |
<spSlPartData> | array | Partial take profit and stop loss data |
id | int | Partial Stop Loss Stop Profit Stop Loss ID |
triggerType | int | Take profit and stop loss trigger type |
spPrice | string | Take Profit Price |
slPrice | string | Stop price |
amount | string | Partial Take Profit Stop Loss Quantity |
spType | int | Stop loss type |
slType | int | top loss type |
spTriggerPrice | string | Take Profit Order Price |
slTriggerPrice | string | Stop loss order price |
</spSlPartData> |
Place a New Order
HTTP request
- POST
/fapi/v2/order/open
Request
{
"customID": "test_customID_01",
"symbol": "btc_usdt",
"side": 1,
"type": 1,
"amount": "2",
"leverage": 20,
"triggerType": 1,
"price": "20270.46",
"recvWindow": 7796,
"timestamp": 1757798285
}
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
customID | body | string | true | NA | User-defined order number | `^[\.A-Z\:/a-z0-9_-]{1,36}$` | symbol | body | string | true | NA | trading symbol | type | body | int | true | NA | order type | 1:limit price 2:market price | side | body | int | true | NA | order side | 1:buy 2:sell | leverage | body | int | true | NA | leverage | 1 - 100 | price | body | string | false | NA | order price (used for limit order) | amount | body | string | true | NA | order amount | triggerType | body | int | true | NA | Take Profit and Stop Loss Trigger Type | 1:ticker price 2:index price | slPrice | body | string | false | NA | stop price | spPrice | body | string | false | NA | take profit price | isSetSl | body | bool | false | false | whether to set stop loss | isSetSp | body | bool | false | false | whether to set take profit | recvWindow | body | int | false | 5000 | time interval window (seconds) | 1 - 60000 | timestamp | body | int | true | NA | timestamp |
Response:
{
"code": 0,
"msg": "success",
"data": {
"orderID": "22090114311747401010000602280"
}
}
Response Data
Parameter Name | Data Types | Description |
---|---|---|
orderID | string | order id |
Place a Batch of Orders
HTTP request
- POST
/fapi/v2/order/batchOpen
Request
{
"items":[
{
"customID":"test_customID_002",
"symbol":"btc_usdt",
"side":1,
"type":2,
"amount":"2",
"leverage":20,
"triggerType":1,
"openType":1
},
{
"customID":"test_customID_003",
"symbol":"btc_usdt",
"side":1,
"type":2,
"amount":"2",
"leverage":20,
"triggerType":1,
"openType":1
},
{
"customID":"test_customID_004",
"symbol":"btc_usdt",
"side":1,
"type":2,
"amount":"2",
"leverage":20,
"triggerType":1,
"openType":1
}
],
"recvWindow":7796,
"timestamp":1757798285
}
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
<items> | body | array | true | NA | 1-10 | customID | body | string | true | NA | User-defined order number | `^[\.A-Z\:/a-z0-9_-]{1,36}$` | symbol | body | string | true | NA | trading symbol | type | body | int | true | NA | order type | 1:limit price 2:market price | side | body | int | true | NA | order side | 1:buy 2:sell | leverage | body | int | true | NA | leverage | 1 - 100 | price | body | string | false | NA | order price (used for limit order) | amount | body | string | true | NA | order amount | triggerType | body | int | true | NA | Take Profit and Stop Loss Trigger Type | 1:ticker price 2:index price | slPrice | body | string | false | NA | stop price | spPrice | body | string | false | NA | take profit price | isSetSl | body | bool | false | false | whether to set stop loss | isSetSp | body | bool | false | false | whether to set take profit | </items> | recvWindow | body | int | false | 5000 | time interval window (seconds) | 1 - 60000 | timestamp | body | int | true | NA | timestamp |
Response:
{
"code": 0,
"msg": "success",
"data": {
"success": {
"22090114415869401010000602284": "test_customID_002",
"22090114415869901010000602285": "test_customID_003",
"22090114415870101010000602286": "test_customID_004"
},
"fail": {}
}
}
Response Data
Parameter Name | Data Types | Description |
---|---|---|
<success> | object | success collection | map | order id:custom id | </success> | object | <fail> | object | failure collection | map | custom id:error code | </fail> | object |
Cancel order
HTTP request
- POST
/fapi/v2/order/cancel
Request
{
"customID": "test_customID_005"
"recvWindow": 17807,
"timestamp": 1662005739,
}
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | body | string | false | NA | trading symbol | orderID | body | string | false | NA | order id | customID | body | string | false | NA | custom id | positionID | body | string | false | NA | position id | recvWindow | body | int | false | 5000 | time interval window (seconds) | 1 - 60000 | timestamp | body | int | true | NA | timestamp |
Response:
{
"code": 0,
"msg": "success",
"data": {
"success": {
"22090115124192801010000602316": "test_customID_005"
},
"fail": {}
}
}
Response Data
Parameter Name | Data Types | Description |
---|---|---|
<success> | object | success collection | map | order id:custom id | </success> | object | <fail> | object | failure collection | map | order id:custom id | </fail> | object |
Cancel orders in bulk
HTTP request
- POST
/fapi/v2/order/batchCancel
Request
{
"listOrderID": [
"22090115471405601010000602461",
"22090115470116001010000602452"
],
"recvWindow": 17957,
"timestamp": 1662005739
}
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | body | string | false | NA | trading symbol | listOrderID | body | array | false | NA | List of order IDs | listCustomID | body | array | false | NA | List of custom IDs | listPositionID | body | array | false | NA | List of position IDs | recvWindow | body | int | false | 5000 | time interval window (seconds) | 1 - 60000 | timestamp | body | int | true | NA | timestamp |
Response:
{
"code": 0,
"msg": "success",
"data": {
"success": {
"22090115470116001010000602452": "test_customID_005",
"22090115471405601010000602461": "test_customID_006"
},
"fail": {}
}
}
Response Data
Parameter Name | Data Types | Description |
---|---|---|
<success> | object | success collection | map | order id:custom id | </success> | object | <fail> | object | failure collection | map | order id:custom id | </fail> | object |
Close the position
HTTP request
- POST
/fapi/v2/order/close
Request
{
"recvWindow": 5106,
"timestamp": 1692005739,
"amount": "1",
"type": 2,
"positionId": "220901161157435012531",
"price": "19345.62"
}
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
amount | body | string | true | NA | order amount | price | body | string | false | NA | Closing price(Limit use) | type | body | int | true | NA | order type | 1:limit price 2:market price | positionID | body | string | true | NA | position id | recvWindow | body | int | false | 5000 | time interval window (seconds) | 1 - 60000 | timestamp | body | int | true | NA | timestamp |
Response:
{
"code": 0,
"msg": "success",
"data": {
"orderID": "22090116125693501010000602538"
}
}
Response Data
Parameter Name | Data Types | Description |
---|---|---|
orderID | string | order id |
One-click closing
HTTP request
- POST
/fapi/v2/order/closeAll
Request
{
"symbol": "btc_usdt"
"recvWindow": 9092,
"timestamp": 1662005739,
}
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | body | string | false | NA | trading symbol | recvWindow | body | int | false | 5000 | time interval window (seconds) | 1 - 60000 | timestamp | body | int | true | NA | timestamp |
Response:
{
"code": 0,
"msg": "success",
"data": {
"listOrderID": [
"22090117082618701010000602582",
"22090117082619401010000602583",
"22090117082620301010000602584"
]
}
}
Response Data
Parameter Name | Data Types | Description |
---|---|---|
listOrderID | array | List of order IDs |
Query pending order information
HTTP request
- GET
/fapi/v2/order/unFinish
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | query | string | false | NA | trading symbol | orderID | query | string | false | NA | order id | customID | query | string | false | NA | custom id | positionID | query | string | false | NA | position id | recvWindow | query | int | false | 5000 | time interval window (seconds) | 1 - 60000 | timestamp | query | int | true | NA | timestamp |
Response:
{
"code": 0,
"msg": "success",
"data": [
{
"id": "22090117251664501010000602602",
"customID": "test-customID-01",
"symbol": "btc_usdt",
"type": 1,
"action": 0,
"side": 1,
"positionID": "220901172516645012603",
"price": "19319.44",
"leverage": 20,
"amount": "1",
"frozen": "965.97",
"filledAmount": "0",
"filledPrice": "0",
"filledValue": "",
"triggerType": 2,
"spPrice": "0",
"slPrice": "0",
"state": 0,
"profit": "",
"fee": "",
"pointFee": "",
"pointProfit": "",
"closePrice": "",
"triggerPrice": "",
"createdAt": 1662024316645,
"updatedAt": 1662024316645
}
]
}
Response Data
Parameter Name | Data Types | Description |
---|---|---|
id | string | order id | customID | string | User-defined order number | symbol | string | trading symbol | type | int | order type. 1:limit price 2:market price | action | int | order event. 0.open 1.close 2.stop loss 3.take profit 4.forced close 5.FOK 6.ADL 7.add 8.reverse open 9.wear positions | side | int | order side 1.buy 2.sell | positionID | string | position id | price | string | Order price, limit order is valuable | leverage | int | leverage | amount | string | order amount | frozen | string | Freeze Margin | filledAmount | string | filled amount | filledPrice | string | Average transaction price | filledValue | string | filled value | triggerType | int | Take Profit and Stop Loss Trigger Type. 1:ticker price 2:index price | spPrice | string | set take profit price | slPrice | string | set stop price | state | int | state. 1.normal 2.completed 4.partial deal 5.some deals have been cancelled 6.canceling | profit | string | Realized profit and loss (used for closing orders) | fee | string | handling fee | pointFee | string | Points (bonus) fee deduction | pointProfit | string | Points (bonus) profit and loss deduction | closePrice | string | bankruptcy price | triggerPrice | string | trigger price | createdAt | int | creation timestamp | updatedAt | int | update timestamp |
Query completed order details
HTTP request
- GET
/fapi/v2/order/finishedInfo
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | query | string | false | NA | trading symbol | orderID | query | string | false | NA | order id | customID | query | string | false | NA | custom id | positionID | query | string | false | NA | position id | recvWindow | query | int | false | 5000 | time interval window (seconds) | 1 - 60000 | timestamp | query | int | true | NA | timestamp |
Response:
{
"code": 0,
"msg": "success",
"data": {
"id": "22083115573193301010000601127",
"customID": "test_customID_01",
"symbol": "btc_usdt",
"type": 1,
"action": 0,
"side": 1,
"positionID": "220831155731933011128",
"price": "20270.46",
"leverage": 20,
"amount": "2",
"frozen": "0",
"filledAmount": "2",
"filledPrice": "20270.46",
"filledValue": "40540.92",
"triggerType": 1,
"spPrice": "0",
"slPrice": "0",
"state": 1,
"profit": "0",
"fee": "20.27046",
"pointFee": "0",
"pointProfit": "0",
"closePrice": "0",
"triggerPrice": "0",
"createdAt": 1661932651933,
"updatedAt": 1661932651933
}
}
Response Data
Parameter Name | Data Types | Description |
---|---|---|
id | string | order id | customID | string | User-defined order number | symbol | string | trading symbol | type | int | order type. 1.limit price 2.market price | action | int | order event. 0.open 1.close 2.stop loss 3.take profit 4.forced close 5.FOK 6.ADL 7.add 8.reverse open 9.wear positions | side | int | order side. 1:buy 2:sell | positionID | string | position id | price | string | Order price, limit order is valuable | leverage | int | leverage | amount | string | order amount | frozen | string | Freeze Margin | filledAmount | string | filled amount | filledPrice | string | Average transaction price | filledValue | string | filled value | triggerType | int | Take Profit and Stop Loss Trigger Type. 1:ticker price 2:index price | spPrice | string | set take profit price | slPrice | string | set stop price | state | int | state. 1.normal 2.completed 4.partial deal 5.some deals have been cancelled 6.canceling | profit | string | Realized profit and loss (used for closing orders) | fee | string | handling fee | pointFee | string | Points (bonus) fee deduction | pointProfit | string | Points (bonus) profit and loss deduction | closePrice | string | bankruptcy price | triggerPrice | string | trigger price | createdAt | int | creation timestamp | updatedAt | int | update timestamp |
Query the list of historical orders
HTTP request
- GET
/fapi/v2/order/finished
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbols | query | string | false | NA | trading symbol | startTime | query | int | false | 90 days ago | start timestamp | endTime | query | int | false | current timestamp | end timestamp | pageIndex | query | int | true | NA | page index | greater than 0 | pageSize | query | int | true | NA | page size | 1 - 50 | recvWindow | query | int | false | 5000 | time interval window (seconds) | 1 - 60000 | timestamp | query | int | true | NA | timestamp |
Response:
{
"code": 0,
"msg": "success",
"data": {
"total": 126,
"page": 1,
"data": [
{
"id": "22090117082620301010000602584",
"customID": "test-customID-01",
"symbol": "btc_usdt",
"type": 2,
"action": 1,
"side": 2,
"positionID": "220901170710987012573",
"price": "0",
"leverage": 20,
"amount": "3",
"frozen": "0",
"filledAmount": "3",
"filledPrice": "19928.02",
"filledValue": "59784.06",
"triggerType": 2,
"spPrice": "0",
"slPrice": "0",
"state": 1,
"profit": "-36.65",
"fee": "29.89203",
"pointFee": "0",
"pointProfit": "0",
"closePrice": "0",
"triggerPrice": "0",
"createdAt": 1662023306204,
"updatedAt": 1662023306204
}
]
}
}
Response Data
Parameter Name | Data Types | Description |
---|---|---|
total | int | total number | page | int | page | <data> | array | id | string | order id | customID | string | User-defined order number | symbol | string | trading symbol | type | int | order type. 1.limit price 2.market price | action | int | order event. 0.open 1.close 2.stop loss 3.take profit 4.forced close 5.FOK 6.ADL 7.add 8.reverse open 9.wear positions | side | int | order side. 1:buy 2:sell | positionID | string | position id | price | string | Order price, limit order is valuable | leverage | int | leverage | amount | string | order amount | frozen | string | Freeze Margin | filledAmount | string | filled amount | filledPrice | string | Average transaction price | filledValue | string | filled value | triggerType | int | Take Profit and Stop Loss Trigger Type. 1:ticker price 2:index price | spPrice | string | set take profit price | slPrice | string | set stop price | state | int | state. 1.normal 2.completed 4.partial deal 5.some deals have been cancelled 6.canceling | profit | string | Realized profit and loss (used for closing orders) | fee | string | handling fee | pointFee | string | Points (bonus) fee deduction | pointProfit | string | Points (bonus) profit and loss deduction | closePrice | string | bankruptcy price | triggerPrice | string | trigger price | createdAt | int | creation timestamp | updatedAt | int | update timestamp | </data> |
Place a conditional order
HTTP request
- POST
/fapi/v2/entrust/add
Request
{
"customID":"test-CustomID-02",
"amount": "5",
"symbol": "btc_usdt",
"side": 1,
"triggerPrice": "20646.59",
"price": "20646.59",
"leverage": 20,
"triggerType": 2,
"spSlTriggerType": 1,
"recvWindow": 66,
"timestamp": 1662005739
}
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
customID | body | string | true | NA | User-defined order number | `^[\.A-Z\:/a-z0-9_-]{1,36}$` | symbol | body | string | true | NA | trading symbol | side | body | int | true | NA | order side | 1:buy 2:sell | triggerType | body | int | true | NA | trigger type | 1:ticker price 2:index price | triggerPrice | body | string | true | NA | trigger price | amount | body | string | true | NA | order amount | price | body | string | true | NA | order price | leverage | body | int | true | NA | leverage | 1 - 100 | spSlTriggerType | body | int | true | NA | Take Profit and Stop Loss Trigger Type | 1:ticker price 2:index price | slPrice | body | string | false | NA | stop price | spPrice | body | string | false | NA | take profit price | isSetSl | body | bool | false | false | whether to set stop loss | isSetSp | body | bool | false | false | whether to set take profit | recvWindow | body | int | false | 5000 | time interval window (seconds) | 1 - 60000 | timestamp | body | int | true | NA | timestamp |
Response:
{
"code": 0,
"msg": "success",
"data": {
"id": "22090120553294601010000600015",
"symbol": "btc_usdt",
"leverage": 20,
"triggerType": 2,
"triggerPrice": "20646.59",
"status": 1,
"side": 1,
"price": "20646.59",
"startPrice": "20019.75",
"amount": "5",
"spSlTriggerType": 1,
"spPrice": "0",
"slPrice": "0",
"isSetSp": false,
"isSetSl": false,
"frozen": "5161.64",
"createdAt": 1662036932946,
"updatedAt": 1662036932946
}
}
Response Data
Parameter Name | Data Types | Description |
---|---|---|
id | string | order id | symbol | string | trading symbol | side | int | order side. 1:buy 2:sell | triggerType | int | trigger type. 1:ticker price 2:index price | triggerPrice | string | trigger price | status | int | 1:pending 2:completed 3:user cancels 4:system cancels | amount | string | order amount | price | string | order price | startPrice | string | The price at which the order was triggered | leverage | int | leverage | spSlTriggerType | int | Take Profit and Stop Loss Trigger Type | slPrice | string | stop price | spPrice | string | take profit price | isSetSl | bool | whether to set stop loss | isSetSp | bool | whether to set take profit | frozen | string | freeze margin | createdAt | int | creation timestamp | updatedAt | int | update timestamp |
Cancel conditional orders (before triggering)
HTTP request
- POST
/fapi/v2/entrust/cancel
Request
{
"symbol": "btc_usdt",
"entrustID": "22090120553294601010000600015"
"recvWindow": 7472,
"timestamp": 1662005739,
}
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | body | string | true | NA | trading symbol | entrustID | body | string | false | NA | order id | customID | body | string | false | NA | User-defined order number | recvWindow | body | int | false | 5000 | time interval window (seconds) | 1 - 60000 | timestamp | body | int | true | NA | timestamp |
Response:
{
"code": 0,
"msg": "success",
"data": [
"22090120553294601010000600015"
]
}
Response Data
Parameter Name | Data Types | Description |
---|---|---|
data | array | List of order IDs |
Query open conditional orders (before triggering)
HTTP request
- GET
/fapi/v2/entrust/unFinish
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | body | string | false | NA | trading symbol | recvWindow | query | int | false | 5000 | time interval window (seconds) | 1 - 60000 | timestamp | query | int | true | NA | timestamp |
Response:
{
"code": 0,
"msg": "success",
"data": [
{
"id": "22090121233844901010000600016",
"symbol": "btc_usdt",
"leverage": 20,
"triggerType": 2,
"triggerPrice": "20646.59",
"status": 1,
"side": 1,
"price": "20646.59",
"startPrice": "19963.5",
"amount": "5",
"spSlTriggerType": 1,
"spPrice": "0",
"slPrice": "0",
"isSetSp": false,
"isSetSl": false,
"frozen": "5161.64",
"createdAt": 1662038618449,
"updatedAt": 1662038618449
}
]
}
Response Data
Parameter Name | Data Types | Description |
---|---|---|
<data> | array | id | string | order id | symbol | string | trading symbol | side | int | order side. 1:buy 2:sell | triggerType | int | trigger type. 1:ticker price 2:index price | triggerPrice | string | trigger price | status | int | 1:pending 2:completed 3:user cancels 4:system cancels | amount | string | order amount | price | string | order price | startPrice | string | The price at which the order was triggered | leverage | int | leverage | spSlTriggerType | int | Take Profit and Stop Loss Trigger Type | slPrice | string | stop price | spPrice | string | take profit price | isSetSl | bool | whether to set stop loss | isSetSp | bool | whether to set take profit | frozen | string | freeze margin | createdAt | int | creation timestamp | updatedAt | int | update timestamp | </data> |
Query triggered conditional orders
HTTP request
- GET
/fapi/v2/entrust/finished
Request Parameters
Parameter Name | Position | Data Types | Required | Default value | Describe | Value range |
---|---|---|---|---|---|---|
symbol | body | string | false | NA | trading symbol | pageIndex | query | int | true | NA | page index | 大于0 | pageSize | query | int | true | NA | page size | 1 - 50 | recvWindow | query | int | false | 5000 | time interval window (seconds) | 1 - 60000 | timestamp | query | int | true | NA | timestamp |
Response:
{
"code": 0,
"msg": "success",
"data": {
"total": 16,
"page": 1,
"data": [
{
"id": "22090120553294601010000600015",
"symbol": "btc_usdt",
"leverage": 20,
"triggerType": 2,
"triggerPrice": "20646.59",
"status": 3,
"side": 1,
"price": "20646.59",
"startPrice": "20019.75",
"amount": "5",
"spSlTriggerType": 1,
"spPrice": "0",
"slPrice": "0",
"isSetSp": false,
"isSetSl": false,
"frozen": "5161.64",
"createdAt": 1662036932947,
"updatedAt": 1662037987010
}
]
}
}
Response Data
Parameter Name | Data Types | Description |
---|---|---|
total | int | total number | page | int | page | <data> | array | id | string | order id | symbol | string | trading symbol | side | int | order side. 1:buy 2:sell | triggerType | int | trigger type. 1:ticker price 2:index price | triggerPrice | string | trigger price | status | int | 1:pending 2:completed 3:user cancels 4:system cancels | amount | string | order amount | price | string | order price | startPrice | string | The price at which the order was triggered | leverage | int | leverage | spSlTriggerType | int | Take Profit and Stop Loss Trigger Type | slPrice | string | stop price | spPrice | string | take profit price | isSetSl | bool | whether to set stop loss | isSetSp | bool | whether to set take profit | frozen | string | freeze margin | createdAt | int | creation timestamp | updatedAt | int | update timestamp | </data> |
Websocket coin market data
Introduction
Access URL
Quote Request Address
wss://api.bkex.com
Example
Socket.io Demo
<script
src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.4/socket.io.js"></script>
const socket = io('https://api.bkex.com/quotation');
socket.on('connect', function (data) {
socket.emit("subKlineByRange", {
"symbol": "BTC_USDT,ETH_USDT,LTC_USDT",
"period": "240",
"from": 1567136369,
"to": 1588735346,
"no": "157430756955441803"
});
});
Native WebScoket Demo
var pingPong = null;
ws = new WebSocket("wss://api.bkex.com/socket.io/?EIO=3&transport=websocket");
ws.onopen = function() {pingPong = setInterval(function () { ws.send('2');}, 20 * 1000)};
ws.onmessage = function(e) {
if(e.data === '40') {
ws.send('40/quotation')}
else if(e.data === '40/quotation'){
ws.send('42/quotation,["subOrderDepth",{"symbol": "BTC_USDT","number":
50}]')}
else {}
};
K-line data
Topic subscription
subKlineByRange
Subscription Requests
[
"subKlineByRange",
{
"symbol": "BTC_USDT,ETH_USDT",
"period": "240",
"from": 1567136369,
"to": 1574307629,
"no": "157430756955441833"
}
]
Subscription Parameters
Parameters | Data Types | Is it necessary | Description | Range of values |
---|---|---|---|---|
symbol | string | true | Trading pairs (multiple pairs separated by ',') | BTC_USDT,ETH_USDT... |
period | string | true | K Cycle | '1', '5', '15', '30', '60', '240', '360', '720', '1D', '1W', numbers for minutes, 1D for: 1 day, 1W for: 1 week |
from | long | true | Beginning time stamp in seconds | |
to | long | true | Cut-off time stamp in seconds | |
no | string | true | Marker |
Full Amount Response
[
"symbolKlineByRange",
{
"no": "157430756955441833",
"noMore": false,
"list":[
{
"volume": 194.2213,
"close": 8765.4543,
"quoteVolume": 31295.7543,
"high": 8942.4962,
"low": 8312.3154,
"open": 8532.8129,
"ts": 1574307629
}]
}
]
Incremental Response
[
"qSymbolKLine",
{
"volume": 194.2213,
"close": 8765.4543,
"vol": 31295.7543,
"high": 8942.4962,
"quoteVolume": 8312.3154,
"open": 8532.8129,
"ts": 1574307629
}
]
Response data
Field | Data Types | Description |
---|---|---|
no | string | Tag number, return and parameter match |
noMore | boolean | Is there more data, false is yes |
list | object | Full data set |
List of data fields
Field | Data Types | Description |
---|---|---|
volume | decimal | Turnover |
open | decimal | Opening price |
close | decimal | Closing price |
low | decimal | Lowest Price |
high | decimal | Highest Price |
quoteVolume | decimal | Turnover |
Order Depth Market Data
Subscription by topic
subOrderDepth
Subscription parameters
[
"subOrderDepth",
{
"symbol": "BTC_USDT,ETH_USDT",
"number": 50
}
]
Parameters
Parameters | Data Types | Is it necessary | Default value | Description | Range of values |
---|---|---|---|---|---|
symbol | string | true | NA | Trading pairs (multiple pairs separated by ',') | BTC_USDT,ETH_USDT... |
number | integer | true | 50 | Number of depth | [1-50] |
Response
[
"quotationOrderDepth",
{
"symbol": BTC_USDT,
"ts": 1577254059571,
"asks": [
["7148.0994","0.0021"],// [价格, 数量]
["7148.0994","0.0021"],
...
],
"bids":[
["7148.0994","0.0021"],
["7148.0994","0.0021"],
...
]
}
]
List of data fields
Field | Data Types | Description |
---|---|---|
symbol | string | Trading pair |
ts | long | Time stamp in milliseconds |
asks | object | All current sell orders [price, quantity] |
bids | object | Current So Buy Order [price, quantity] |
Transaction details
Topic Subscriptions
quotationDealConnect
This thread provides a line-by-line breakdown of the latest transactions.
Subscription parameters
[
"quotationDealConnect",
{
"symbol": "BTC_USDT,ETH_USDT",
"number": 50
}
]
Parameters
Parameters | Data Types | Is it necessary | Default value | Description | Range of values |
---|---|---|---|---|---|
symbol | string | true | NA | Trading pairs (multiple pairs separated by ',') | BTC_USDT,ETH_USDT... |
number | integer | true | 50 | Quantity | [1-50] |
Full Response
[
"quotationAllDeal",
[{
"symbol": BTC_USDT,
"price": 7145.0806,
"volume": 0.1662,
"direction": "B",
"ts": 1577254059571
}]
]
List of data fields
Field | Data Types | Description |
---|---|---|
symbol | string | Trading pair |
price | decimal | Trading price |
volume | decimal | Number of transactions |
direction | string | Direction of transaction, B for buy, S for sell |
ts | long | Closing Time Stamp |
.Incremental Response
[
"quotationListDeal",
[{
"symbol": BTC_USDT,
"price": 7145.0806,
"volume": 0.1662,
"direction": "B",
"ts": 1577254059571
}]
]
24-hour market
Topic Subscription
subQuotationSymbol
Subscription parameters
[
"subQuotationSymbol",
{
"symbol": "BTC_USDT,ETH_USDT"
}
]
Parameters
Parameters | Data Types | Is it necessary | Default value | Description | Range of values |
---|---|---|---|---|---|
symbol | string | false | NA | Trading pairs (multiple pairs separated by ',') | BTC_USDT,ETH_USDT... |
Response
[
"qPairsUpdateStats",
[{
"symbol": BTC_USDT,
"close": 7145.0806,
"open": 7123.0407,
"high": 7167.1034,
"low": 7105.5237,
"volume": 4214.5321,
"quoteVolume": 94285313.4451,
"change": 0.12
}]
]
List of data update fields
Field | Data Types | Description |
---|---|---|
symbol | string | Trading pair |
close | decimal | 24-hour closing price | volume | decimal | 24-hour trading volume |
open | decimal | 24-hour opening price |
low | decimal | Lowest price for 24 hours | .
high | decimal | 24-hour top price | .
quoteVolume | decimal | 24-hour turnover |
change | decimal | 24-hour ups and downs |
Websocket Coin User Data
Introduction
Access URL
Request address
wss://api.bkex.com
Example
Socket.io Demo
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.4/socket.io.js"></script>
const socketUser = io('https://api.bkex.com/account');
socketUser.on('connect', function (data) {
socketUser.emit('userLogin', {
"signature": "XXXXX",
"accessKey": "XXXXX",
"timestamp": 1589199182739
});
});
socketUser.on('userLogin', function (data) {
if(data.code==0){
socketUser.emit("subUserAccountInfo");
socketUser.emit("subUserOrderDeal");
}
});
Native WebScoket Demo
var pingPong = null;
ws = new WebSocket("wss://api.bkex.com/socket.io/?EIO=3&transport=websocket");
ws.onopen = function() {pingPong = setInterval(function () { ws.send('2');}, 20 * 1000)};
ws.onmessage = function(e) {
if(e.data === '40') {
ws.send('40/account')}
else if(e.data === '40/account'){
ws.send('42/account,["userLogin",{"signature":"93c4f85c396eeff4c0472a31439b98bec7168338f8fad44ef54b4f5b3f6b3e2f","accessKey":"64ff07234e19363cf15ca8dae1fa35e734a7842e1fef820ba7fbc94d5cffa45d","timestamp":1588663088781}]')}
else {}
};
websocket user login
event name
userLogin
parameters
[
"userLogin",
{
"signature": "93c4f85c396eeff4c0472a31439b98bec7168338f8fad44ef54b4f5b3f",
"accessKey": "xxxxxxxxxx19363cf15ca8dae1fa35e734a7842e1fef820ba7fbc94d5c",
"timestamp": 1588663088781
}
]
Request Parameters
Field | Data Types | Description |
---|---|---|
accessKey | string | api key |
timestamp | long | Timestamp |
signature | string | Signature String |
The signature parameter is timestamp
Example:
Signature parameter string: timestamp=1588663088781
Using secretKey for HMAC SHA256 encryption, the result is:93c4f85c396eeff4c0472a31439b98bec7168338f8fad44ef54b4f5b3f
Response
[
"userLogin",
{
"code": 0,
"msg": "success"
}
]
Response message
A success message is returned if the login information is verified (code=0, msg='success');
The corresponding error message is returned if the validation fails.
User Balance Change Subscription
Topic Subscription
subUserAccountInfo
Subscription parameters
[
"subUserAccountInfo"
]
Response
[
"subUserAccountInfo",
[
{
"avAfterChange": "201.100000",
"availableChange": "0.100000",
"currency": "BTC",
"frAfterChange": "0.000000",
"frozenChange": "0.000000",
"time": 1588667153068,
"type": "TRADE_DEAL_BUYER"
},
{
"avAfterChange": "1991120.234380",
"availableChange": "0.000000",
"currency": "USDT",
"frAfterChange": "0.000000",
"frozenChange": "-807.251420",
"time": 1588667153068,
"type": "TRADE_DEAL_BUYER"
}
]
]
List of data update fields
Field | Data Types | Description |
---|---|---|
avAfterChange | string | Changed available balance |
availableChange | string | Change in available balance |
currency | string | Currency |
frAfterChange | string | Frozen balance after changes |
frozenChange | string | Changes to frozen balances |
time | long | Timestamp |
type | string | Type of balance change |
Type of balance change:
TRADE_DEAL_BUYER: Buyer's balance changed during the transaction
TRADE_DEAL_SELLER: Change in seller balance during transaction
TRADE_DEAL_BUYER_FEE: Change in Buyer's Fee on Transactions
TRADE_DEAL_SELLER_FEE: Change in seller's fee on transactions
User Order Change Subscription
Topic Subscription
subUserOrderDeal
Subscription parameters
[
"subUserOrderDeal"
]
Response
[
"subUserOrderDeal",
{
"dealVolume": "0.1000",
"fee": "0.00000000",
"feeCurrency": "BKK",
"id": "2020050516255306842000020",
"orderId": "2020050516255281242000020",
"orderSide": "BID",
"price": "8072.5142",
"symbol": "BTC_USDT",
"tradeTime": 1588667153068
}
]
List of data update fields
Field | Data Types | Description |
---|---|---|
dealVolume | string | Turnover |
fee | string | Fee charges |
feeCurrency | string | Currency of fees |
id | string | Transaction ID |
orderId | string | Order id |
orderSide | string | Order Direction (BID: Buy, ASK: Sell) |
price | string | Unit price |
symbol | string | Trading pair |
tradeTime | long | Times of transaction |
Websocket contract quote data
Access URL
Contract Quote Request Address
wss://fapi.bkex.com/fapi/v2/ws
Heartbeat
When the user's Websocket client connects to the Websocket server, the server will periodically (currently set to 1 minute) send ping messages to it.
When the user's Websocket client receives this heartbeat message, it should return a pong message.
Subscribe to messages
Request
{"event":"sub","topic":"btc_usdt.5deep,btc_usdt.index"}
Response
{
"type":"sub",
"ts":1658133356074,
"data":{
"topic":"btc_usdt.5deep,btc_usdt.index",
"status":"ok"
}
}
After successfully establishing a connection with the Websocket server, the Websocket client sends a request to subscribe to a specific topic. The message format is unified, and multiple subscriptions can be subscribed at the same time, separated by ','.
{"event":"sub","topic":"topic1,topic2..."}
After a successful subscription, the Websocket client will receive an acknowledgment.
{"type":"sub","ts":1658133356074,"data":{"topic":"topic1,topic2...","status":"ok"}}
After that, once the subscribed topic is updated, the Websocket client will receive the update message pushed by the server.
Unsubscribe from messages
Request
{"event":"sub","topic":"btc_usdt.5deep,btc_usdt.index"}
Response
{
"type":"sub",
"ts":1658133356074,
"data":{
"topic":"btc_usdt.5deep,btc_usdt.index",
"status":"ok"
}
}
After the subscription is successful, you can cancel the subscription. The message format is unified, and multiple subscriptions can be unsubscribed at the same time, separated by ','.
{"event":"unsub","topic":"topic1,topic2..."}
After successfully unsubscribing, the Websocket client will receive a message that the cancellation was successful.
{"type":"unsub","ts":1658133356074,"data":{"topic":"topic1,topic2...","status":"ok"}}
After that, push messages for that topic will no longer be received.
limited depth
This thread sends the latest Depth of Market snapshot. The snapshot frequency is 1 every 500 milliseconds. Currently supports 5 files, 10 files, 20 files.
Topic subscription
$symbol.$depth
Request
{"event":"sub","topic":"btc_usdt.5deep"}
Subscription parameters
Parameters | Data Types | Is it necessary | Description | Range of values |
---|---|---|---|---|
symbol | string | true | Trading pair | ada_usdt,bch_usdt,btc_usdt... |
depth | string | true | depth type | 5deep,10deep,20deep |
Response
{
"type":"btc_usdt.5deep",
"ts":1658133356423,
"data":{
"symbol":"btc_usdt",
"asks":[
"22283.880000",
"1.91",
"22284.060000",
"0.08",
"22284.440000",
"0.11",
"22284.620000",
"0.06",
"22284.640000",
"1.24"
],
"bids":[
"22283.200000",
"1060",
"22283.000000",
"790",
"22282.280000",
"80",
"22282.240000",
"1150",
"22282.210000",
"940"
]
}
}
Response data
Field | Data Types | Description |
---|---|---|
type | string | subscribed topic |
ts | long | timestamp |
<data> | object | data block |
symbol | string | Trading pair |
asks | array | seller [price, size] |
bids | array | buyer [price, size] |
</data> |
Incremental depth
Push when the currency pair depth changes.
Topic subscription
$symbol.updateDepth
Request
{"event":"sub","topic":"btc_usdt.updateDepth"}
Subscription parameters
Parameters | Data Types | Is it necessary | Description | Range of values |
---|---|---|---|---|
symbol | string | true | Trading pair | ada_usdt,bch_usdt,btc_usdt... |
Response
{
"type":"btc_usdt.5deep",
"ts":1658133356423,
"data":{
"symbol":"btc_usdt",
"asks":[
"22283.880000",
"1.91"
],
"bids":[
"22283.200000",
"1060",
]
}
}
Response data
Field | Data Types | Description |
---|---|---|
type | string | subscribed topic |
ts | long | timestamp |
<data> | object | data block |
symbol | string | Trading pair |
asks | array | seller [price, size] |
bids | array | buyer [price, size] |
</data> |
Symbol's Ticker Information
symbol 24 hours full ticker information.
Topic subscription
$symbol.ticker
Request
{"event":"sub","topic":"btc_usdt.ticker"}
Subscription parameters
Parameters | Data Types | Is it necessary | Description | Range of values |
---|---|---|---|---|
symbol | string | true | Trading pair | ada_usdt,bch_usdt,btc_usdt... |
Response
{
"type":"btc_usdt.ticker",
"ts":1659319399003,
"data":{
"symbol":"btc_usdt",
"amount":"2553.28",
"volume":"60609744.48039",
"open":"23775.65",
"close":"23745.15",
"high":"23852.37",
"low":"23561.12",
"lastPrice":"23745.15",
"lastAmount":"0.06",
"lastTime":1659336982046,
"change":"-0.12"
}
}
Response data
Field | Data Types | Description |
---|---|---|
type | string | subscribed topic |
ts | long | timestamp |
<data> | object | data block |
symbol | string | Trading pair |
amount | string | Accumulated trading volume of last 24 hours (rotating 24h), in base currency |
volume | string | Accumulated trading value of last 24 hours (rotating 24h), in quote currency |
open | string | Opening price in the last 24 hours |
close | string | Last 24 hours closing price |
high | string | Highest price in the last 24 hours |
low | string | Lowest price in last 24 hours |
lastPrice | string | Last traded price |
lastAmount | string | Last traded size |
lastTime | long | Timestamp of the latest transaction |
change | string | Range of change (plus or minus percentage, such as -0.18 means a decrease of 0.18%) |
</data> |
latest index price
Topic subscription
$symbol.index
Request
{"event":"sub","topic":"btc_usdt.index"}
Subscription parameters
Parameters | Data Types | Is it necessary | Description | Range of values |
---|---|---|---|---|
symbol | string | true | Trading pair | ada_usdt,bch_usdt,btc_usdt... |
Response data
Request
{
"type":"btc_usdt.index",
"ts":1658139156030,
"data":{
"symbol":"btc_usdt",
"price":"22227.673",
"time":1658139156278
}
}
Field | Data Types | Description |
---|---|---|
type | string | subscribed topic |
ts | long | timestamp |
<data> | object | data block |
symbol | string | Trading pair |
price | string | Index price |
time | long | event time |
</data> | object | data block |
Market Candlestick
The K-line stream pushes the update of the requested K-line type (the latest K-line) second by second.
To subscribe to Kline, you need to provide interval parameters, the shortest is the minute line,
and the longest is the weekly line. The following intervals are supported:
M -> minute; H -> hour; D -> day; W -> week
Topic subscription
$symbol.candle.$period
Request
{"event":"sub","topic":"btc_usdt.candle.M1"}
Subscription parameters
Parameters | Data Types | Is it necessary | Description | Range of values |
---|---|---|---|---|
symbol | string | true | Trading pair | ada_usdt,bch_usdt,btc_usdt... |
period | string | true | period | M1,M5,M15,M30,H1,H2,H4,H6,D1,W1 |
Response
{
"type": "btc_usdt.candle.M1",
"ts": 1662360553440,
"data": [
"473.15",
"9355628.808",
"19771.14",
"19778.09",
"19769.17",
"19778.06",
"1662360540000"
]
}
Response data
Field | Data Types | Description |
---|---|---|
type | string | subscribed topic |
ts | long | timestamp |
<data> | array | data block |
string | total volume | |
string | total turnover | |
string | opening price | |
string | highest price | |
string | lowest price | |
string | Closing price | |
string | timestamp(milliseconds) | |
</data> | array |
Trade Detail
Topic subscription
$symbol.trade
Request
{"event":"sub","topic":"btc_usdt.trade"}
Subscription parameters
Parameters | Data Types | Is it necessary | Description | Range of values |
---|---|---|---|---|
symbol | string | true | Trading pair | ada_usdt,bch_usdt,btc_usdt... |
Response
{
"type": "btc_usdt.trade",
"ts": 1662361313562,
"data": [
"19788.12",
"1",
"15.06",
"1662361313094"
]
}
Response data
Field | Data Types | Description |
---|---|---|
type | string | subscribed topic |
ts | long | timestamp |
<data> | array | data block |
string | price | |
string | side 1.buy 2.sell | |
string | The number of transactions | |
string | timestamp | </data> | array |
Websocket Contract User Data
Access URL
Contract User Data Request Address
wss://fapi.bkex.com/fapi/v2/ws
Heartbeat
When the user's Websocket client connects to the Websocket server, the server will periodically (currently set to 1 minute) send ping messages to it.
When the user's Websocket client receives this heartbeat message, it should return a pong message.
User Authentication
Request
{"event":"auth","accessKey":"bdc8e5ed9813cc1d00fd5d564f27e7e2696d0a9cbd70644e297ed71bb8265ea2"}
Response
{
"type": "auth",
"ts": 1662364280888,
"data": "ok"
}
Before accepting user change push, you need to apply for an access key.
Use the access key for authentication. After success, subscribe to the corresponding topic,
and the user can receive the corresponding message push only after the user data changes.
Subscribe to messages
Request
{"event":"sub","topic":"btc_usdt.5deep,btc_usdt.index"}
Response
{
"type":"sub",
"ts":1658133356074,
"data":{
"topic":"btc_usdt.5deep,btc_usdt.index",
"status":"ok"
}
}
After successfully establishing a connection with the Websocket server, the Websocket client sends a request to subscribe to a specific topic. The message format is unified, and multiple subscriptions can be subscribed at the same time, separated by ','.
{"event":"sub","topic":"topic1,topic2..."}
After a successful subscription, the Websocket client will receive an acknowledgment.
{"type":"sub","ts":1658133356074,"data":{"topic":"topic1,topic2...","status":"ok"}}
After that, once the subscribed topic is updated, the Websocket client will receive the update message pushed by the server.
Unsubscribe from messages
Request
{"event":"unsub","topic":"btc_usdt.5deep,btc_usdt.index"}
Response
{
"type":"unsub",
"ts":1658133356074,
"data":{
"topic":"btc_usdt.5deep,btc_usdt.index",
"status":"ok"
}
}
After the subscription is successful, you can cancel the subscription. The message format is unified, and multiple subscriptions can be unsubscribed at the same time, separated by ','.
{"event":"unsub","topic":"topic1,topic2..."}
After successfully unsubscribing, the Websocket client will receive a message that the cancellation was successful.
{"type":"unsub","ts":1658133356074,"data":{"topic":"topic1,topic2...","status":"ok"}}
After that, push messages for that topic will no longer be received.
Account update
Topic subscription
user.balance
Request
{"event":"sub","topic":"user.balance"}
Subscription parameters
none
Response
{
"type":"user.balance",
"ts":1662365636378,
"data":{
"balance":"6120140.06",
"frozen":"0",
"margin":"1002.79",
"point":"0",
"loans":"",
"profit":"-327.08",
"unProfit":"0",
"unLosses":"-327.08",
"coin":"usdt"
}
}
Response data
Field | Data Types | Description |
---|---|---|
type | string | subscribed topic |
ts | long | timestamp |
<data> | object | data block |
balance | string | balance |
frozen | string | pending order freeze |
margin | string | position margin |
point | string | Points (bonus) | loans | string | loans | profit | string | unrealized profit and loss | unProfit | string | floating profit | unLosses | string | floating deficit | coin | string | coin type | </data> | object |
Position update
Topic subscription
user.position
Request
{"event":"sub","topic":"user.position"}
Subscription parameters
none
Response
{
"type":"user.position",
"ts":1662366937145,
"data":[
{
"positionID":"220902151914127013061",
"symbol":"btc_usdt",
"side":1,
"leverage":20,
"price":"20056.67",
"amount":"1",
"frozenAmount":"0",
"margin":"1002.7981",
"triggerType":2,
"spPrice":"",
"slPrice":"",
"openProfit":"",
"updatedAt":1662103154185
}
]
}
Response data
Field | Data Types | Description |
---|---|---|
type | string | subscribed topic |
ts | long | timestamp |
<data> | array | data block |
positionID | string | Position id |
symbol | string | Trading pair |
side | int | Direction:1-buy,2-Sell |
leverage | int | leverage |
price | string | Average transaction price |
amount | string | Open interest |
frozenAmount | string | Closed frozen amount |
margin | string | Position margin |
triggerType | int | Take profit and stop loss trigger type: 1-ticker price,2-index price |
spPrice | string | Take profit price |
slPrice | string | Stop price |
openProfit | string | Unrealized profit and loss |
updatedAt | int | Update timestamp |
spSlModel | int | Take Profit Stop Loss Mode. 1-All take profit and stop loss 2-Partial take profit stop loss |
spType | int | Take Profit Type. 0-no take profit set 1-limit price 2-market price |
slType | int | Stop loss type. 0-no take profit set 1-limit price 2-market price |
spTriggerPrice | string | Take Profit Order Price |
slTriggerPrice | string | Stop loss order price |
<spSlPartData> | array | Partial take profit and stop loss data |
id | int | Partial Stop Loss Stop Profit Stop Loss ID |
triggerType | int | Take profit and stop loss trigger type |
spPrice | string | Take Profit Price |
slPrice | string | Stop price |
amount | string | Partial Take Profit Stop Loss Quantity |
spType | int | Stop loss type |
slType | int | top loss type |
spTriggerPrice | string | Take Profit Order Price |
slTriggerPrice | string | Stop loss order price |
</spSlPartData> | </data> | array |
Order update
Topic subscription
user.order
Request
{"event":"sub","topic":"user.order"}
Subscription parameters
none
Response
{
"type":"user.order",
"ts":1662367922965,
"data":[
{
"id":"22090516520341901010000604204",
"customID":"",
"symbol":"btc_usdt",
"type":2,
"action":1,
"side":2,
"positionID":"220905163537440014195",
"price":"0",
"leverage":20,
"amount":"1.2",
"frozen":"0",
"filledAmount":"0",
"filledPrice":"0",
"filledValue":"",
"triggerType":2,
"spPrice":"0",
"slPrice":"0",
"state":0,
"profit":"",
"fee":"",
"pointFee":"",
"pointProfit":"",
"closePrice":"",
"triggerPrice":"",
"createdAt":1662367923419,
"updatedAt":0
}
]
}
Response data
Field | Data Types | Description |
---|---|---|
type | string | subscribed topic |
ts | long | timestamp |
<data> | array | data block | id | string | order id | customID | string | User-defined order number | symbol | string | trading symbol | type | int | order type. 1.limit price 2.market price | action | int | order event. 0.open 1.close 2.stop loss 3.take profit 4.forced close 5.FOK 6.ADL 7.add 8.reverse open 9.wear positions | side | int | order side. 1:buy 2:sell | positionID | string | position id | price | string | Order price, limit order is valuable | leverage | int | leverage | amount | string | order amount | frozen | string | Freeze Margin | filledAmount | string | filled amount | filledPrice | string | Average transaction price | filledValue | string | filled value | triggerType | int | Take Profit and Stop Loss Trigger Type. 1:ticker price 2:index price | spPrice | string | set take profit price | slPrice | string | set stop price | state | int | state. 1.normal 2.completed 4.partial deal 5.some deals have been cancelled 6.canceling | profit | string | Realized profit and loss (used for closing orders) | fee | string | handling fee | pointFee | string | Points (bonus) fee deduction | pointProfit | string | Points (bonus) profit and loss deduction | closePrice | string | bankruptcy price | triggerPrice | string | trigger price | createdAt | int | creation timestamp | updatedAt | int | update timestamp | </data> | array |
Trigger order update
Topic subscription
user.entrust
Request
{"event":"sub","topic":"user.entrust"}
Subscription parameters
none
Response
{
"type":"user.entrust",
"ts":1662369267825,
"data":[
{
"id":"22090517074500101010000600018",
"symbol":"btc_usdt",
"leverage":20,
"triggerType":2,
"triggerPrice":"19730.96",
"status":1,
"side":1,
"price":"19700.96",
"startPrice":"",
"amount":"1",
"spSlTriggerType":0,
"spPrice":"0",
"slPrice":"0",
"isSetSp":false,
"isSetSl":false,
"frozen":"",
"createdAt":1662368865001,
"updatedAt":1662368865001
}
]
}
Response data
Field | Data Types | Description |
---|---|---|
type | string | subscribed topic |
ts | long | timestamp |
<data> | array | data block | id | string | order id | symbol | string | trading symbol | side | int | order side. 1:buy 2:sell | triggerType | int | trigger type. 1:ticker price 2:index price | triggerPrice | string | trigger price | status | int | 1:pending 2:completed 3:user cancels 4:system cancels | amount | string | order amount | price | string | order price | startPrice | string | The price at which the order was triggered | leverage | int | leverage | spSlTriggerType | int | Take Profit and Stop Loss Trigger Type | slPrice | string | stop price | spPrice | string | take profit price | isSetSl | bool | whether to set stop loss | isSetSp | bool | whether to set take profit | frozen | string | freeze margin | createdAt | int | creation timestamp | updatedAt | int | update timestamp | </data> | array |