Navbar
Chinese
shell

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:

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:

Be sure to remember the following information after successful creation:

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:

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

  1. Use the X_ACCESS_KEY header to store access key information.
  2. 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:

Order and transaction related ID description

Order Type

Direction of buying and selling:

Order type:

Query order sorting rules:

Order Status

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

For example:

Request Format

There are currently only two methods: GET and POST

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

github 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

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
    },
    {
      "symbol": "ETH_USDT",
      "supportTrade": false,
      "volumePrecision": 4,
      "pricePrecision": 4,
      "minimumTradeVolume": 0.01
    }
  ]
}

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

Get all currencies

This interface returns all currencies supported by BKEX Global.

curl "https://api.bkex.com/v2/common/currencys"
            

HTTP request

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

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

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 candle1m, 5m, 15m, 30m, 1h, 4h, 6h, 12h, 1d, 1w
from long true NA The start timestamp in milliseconds1529739295000
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

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",
      "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
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

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

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

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

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

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

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

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
createTimelong Initiation time
Status Description
-1 Failure
0 Acknowledged
3 Confirmation in progress

Withdraw records

.

API Key Permissions: Read

Check your cash withdrawal history

HTTP requests

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
createTimelong Initiation time
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

{
  "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

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

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
createdTimelong 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

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
createdTimelong 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
createdTimelong Pending order time
updateTimelong 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

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
createdTimelong Time stamp of order creation time in milliseconds
updateTimelong 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

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


[
    "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

Signature authentication is required to access this interface.

Frequency limit (according to IP limit): 20 times / S.

HTTP request

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

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]

Quotes interface

Get K-line data

API Key permissions: no signature required

Frequency limit (according to IP limit): 20 times / s.

HTTP Request

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

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

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

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

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

Signature authentication is required to access this interface.

Limit (according to IP limit):20 times /s.

HTTP request

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

Signature authentication is required to access this interface.

Limit (according to IP limit):20 times /s.

HTTP requests

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

Signature authentication is required to access this interface.

Limit (according to IP limit):20 times /s.

HTTP request

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

Signature authentication is required to access this interface.

Limit (according to IP limit):20 times /s.

HTTP request

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

Get risk limits

Signature authentication is required to access this interface.

Limit (according to IP limit):20 times /s.

HTTP request

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

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://api.bkex.com/contract/q/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

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

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
typestringsubscribed 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
typestringsubscribed 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
typestringsubscribed topic
ts long timestamp
<data> object data block
symbol string Trading pair
amount stringAccumulated trading volume of last 24 hours (rotating 24h), in base currency
volume stringAccumulated 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
typestringsubscribed topic
ts long timestamp
<data> object data block
symbolstringTrading pair
pricestringIndex price
timelongevent time
</data> object data block

Websocket Contract User Data (not in service)

Basic Information

Access URL

wss://api.bkex.com/contract/u/ws/{listenKey}

Create listenKey

API Key Permissions: Contract Queries

Create a new stream of user information. If no keepalive is sent, the push will be disconnected after 60 minutes

HTTP Request

{
  "recvWindow": 500
}

Request parameters

Parameters Data Types Is it necessary Default values Description
recvWindow long false 500 recvWindow

Response:

{
  "code": 0,
  "data": {
    "listenKey": "1A9LWJjuMwKWYP4QQPw34GRm8gz3x5AephXSuqcDef1RnzoBVhEeGE963CoS1Sgj"
  }
}

Response data

Parameter Name Data Types Examples Description
listenKey String listen Key

Extend ListenKey validity

API Key Permissions: Contract Queries

Extend to 60 minutes after this call, it is recommended to do an extension every 30 minutes

HTTP Request

{
  "listenKey":" 1A9LWJjuMwKWYP4QQPw34GRm8gz3x5AephXSuqcDef1RnzoBVhEeGE963CoS1Sgj ",
  "recvWindow": 500
}

Request parameters

Parameters Data Types Is it necessary Default values Description
listenKey string true 500 listen Key
recvWindow long false 500 recvWindow

Response:

{
  "code": 0,
  "data": {}
}

Response data

{}

Close listenKey

.

API Key Permissions: Contract Queries

Closing user data streams

HTTP Request

{
  "listenKey":"1A9LWJjuMwKWYP4QQPw34GRm8gz3x5AephXSuqcDef1RnzoBVhEeGE963CoS1Sgj",
  "recvWindow": 500
}

Request parameters

Parameters Data Types Is it necessary Default values Description
listenKey string true 500 listen Key
recvWindow long false 500 recvWindow

Response:

{
  "code": 0,
  "data": {}
}

Response data

{}

WebSocket Payload

Account update

Use outbound AccountInfo event for account updates

Payload

{ "e": "outboundAccountInfo", // event type "E": 1499405658849, // Time of event "T": true, // Allow trading? "W": true, // Allow reflections? "D": true, // Allow top-ups? "B": [ // Balance change { "a": "LTC", // Asset name "f": "17366.18538083", // Quantity available "l": "0.00000000" // Quantity frozen } ] }

Account update response

{
  "e": "outboundAccountInfo", // event type
  "E": 1499405658849, // Time of event
  "T": true, // Allow trading?
  "W": true, // Allow reflections?
  "D": true, // Allow top-ups?
  "B": [ // Balance change
    {
      "a": "LTC", // Asset name
      "f": "17366.18538083", // Quantity available
      "l": "0.00000000" // Quantity frozen
    }
  ]
}

Order Update

The order is updated via the contractExecutionReport event. Detailed description information can be found here. Average price can be found by dividing Z by z

Payload

{ "e": "contractExecutionReport", // event type "E": 1499405658658, // Time of event "s": "BTC-SWAP-USDT", // trading pairs "c": 1000087761, // Client order ID "S": "BUY", // order direction "o": "LIMIT", // Order Type "f": "GTC", // Time in force "q": "1.00000000", // Number of Orders "p": "0.10264410", // Order Price "X": "NEW", // Current Order Status "i": 4293153, // Order ID "l": "0.00000000", // last traded quantity "z": "0.00000000", // Cumulative number of transactions "L": "0.00000000", // last traded price "n": "0", // Handling fees "N": null, // Fee currency "u": true, // Please ignore. "w": true, // Please ignore. "m": false, // Please ignore. "O": 1499405658657, // Order Creation Time "Z": "0.00000000" // Cumulative transaction amount

Order Status:

Order update response

{
  "e": "executionReport", // event type
  "E": 1499405658658, // Time of event
  "s": "BTC-SWAP-USDT", // trading pairs
  "c": 1000087761, // Client order ID
  "S": "BUY", // order direction
  "o": "LIMIT", // Order Type
  "f": "GTC", // Time in force
  "q": "1.00000000", // Number of Orders
  "p": "0.10264410", // Order Price
  "X": "NEW", // Current Order Status
  "i": 4293153, // Order ID
  "l": "0.00000000", // last traded quantity
  "z": "0.00000000", // Cumulative number of transactions
  "L": "0.00000000", // last traded price
  "n": "0", // Handling fees
  "N": null, // Fee currency
  "u": true, // Please ignore.
  "w": true, // Please ignore.
  "m": false, // Please ignore.
  "O": 1499405658657, // Order Creation Time
  "Z": "0.00000000" // Cumulative transaction amount
}

Position update

Using outboundContractPositionInfo event for position updates

Payload

{ "e": "outboundContractPositionInfo", // event genre "A": "", // Account ID "s": "BTC-SWAP-USDT", // symbol "S": "LONG", // Position Direction "p": "9851.5", // average price "P": "269", // Number of Positions "a": "269", // available "f": "7705.9", // STRONG CLOSING PRICE "m": "59.7884", // Margin "r": "-0.0139" // P&L realized }

Holdings update response

{
  "e": "outboundContractPositionInfo", // event genre
  "A": "", // Account ID
  "s": "BTC-SWAP-USDT", // symbol
  "S": "LONG", // Position Direction
  "p": "9851.5", // average price
  "P": "269", // Number of Positions
  "a": "269", // available
  "f": "7705.9", // STRONG CLOSING PRICE
  "m": "59.7884", // Margin
  "r": "-0.0139" // P&L realized Translated with www.DeepL.com/Translator (free version)
}