Rest API changed.
Updated Endpoint — New Order (SIGNED)
POST /open/v1/orders
selfTradePreventionMode (INT, optional) — 0 EXPIRE_MAKER, 1 EXPIRE_TAKER, 2 EXPIRE_BOTH, 3 NONE, 4 DECREMENT, 5 TRANSFERUpdated Endpoint — Get all Supported Trading Symbol
GET /open/v1/common/symbols
defaultSelfTradePreventionMode to symbol responseallowedSelfTradePreventionModes to symbol responseUpdated Documentation — FAQs
FAQs.mdRest API changed.
New Endpoint — Query Execution Rules
GET /api/v3/executionRules
New Documentation — FAQs
FAQs.md with Price Range Execution Rule documentationRest API changed.
Updated Endpoint — Account Information (SIGNED)
GET /open/v1/account/spot
fiatMakerCommission — Maker commission rate for TRY (fiat) pairsfiatTakerCommission — Taker commission rate for TRY (fiat) pairsAdd deprecation notice to POST /open/v1/user-data-stream, PUT /open/v1/user-data-stream, DELETE /open/v1/user-data-stream
POST /open/v1/user-listen-tokenAdd new endpoint POST /open/v1/user-listen-token
Add WebSocket API documentation for user data stream
Rest API changed.
New Endpoint — Batch Cancel Orders (SIGNED)
POST /open/v1/orders/batch-cancel
Updated Endpoint — New Order (SIGNED)
POST /open/v1/orders
timeInForce parameterWallet Endpoints Changed
Add Withdraw History (SIGNED)
GET /open/v1/fiat/deposits (Deposit History)
GET /open/v1/fiat/withdraws (Withdraw History)
Public API Definitions adds limit maker type
Rest API changed.
Public API Definitions Add order types 3,4,5,6,7
Withdraw (SIGNED) Add new parameters
User Data Streams changed.
Create a listenKey:
POST /open/v1/user-data-stream (when symbolType is 1, MBX symbol)
POST /open/v1/private-n/user-data-stream (when symbolType is 3, Nextme Symbol(New Symbol) )
Ping/Keep-alive a listenKey:
PUT /open/v1/user-data-stream (when symbolType is 1, MBX symbol)
PUT /open/v1/private-n/user-data-stream (when symbolType is 3, Nextme Symbol(New Symbol) )
Close a listenKey:
DELETE /open/v1/user-data-stream (when symbolType is 1, MBX symbol)
DELETE /open/v1/private-n/user-data-stream (when symbolType is 3, Nextme Symbol(New Symbol) )
General WSS information changed.
Changes ws link:
HTTP 4XX return codes are used for malformed requests; the issue is on the sender's side.
HTTP 403 return code is used when the WAF Limit (Web Application Firewall) has been violated.
HTTP 429 return code is used when breaking a request rate limit.
HTTP 418 return code is used when an IP has been auto-banned for continuing to send requests after receiving 429 codes.
HTTP 5XX return codes are used for internal errors; the issue is on
Server's side.
It is important to NOT treat this as a failure operation; the execution status is
UNKNOWN and could have been a success.
| Name | Type | Mandatory | Description |
|---|---|---|---|
| code | Number | Yes | Error Code,0 is success,else is fail |
| msg | String | Yes | error message |
| timestamp | Number | Yes | server timestamp |
| data | Object | No | response data |
GET endpoints, parameters must be sent as a query string.POST endpoints, the parameters may be sent as a query string or in the request body with content type application/x-www-form-urlencoded. You may mix parameters between both the query string and request body if you wish to do so.query string and request body, the body string parameter will be used.The following intervalLetter values for headers:
intervalNum describes the amount of the interval. For example, intervalNum 5 with intervalLetter M means "Every 5 minutes".X-MBX-USED-WEIGHT-(intervalNum)(intervalLetter) in the response headers which has the current used weight for the IP for all request rate limiters defined.weight which determines for the number of requests each endpoint counts for. Heavier endpoints and endpoints that do operations on multiple symbols will have a heavier weight.Retry-After header is sent with a 418 or 429 responses and will give the number of seconds required to wait, in the case of a 418, to prevent a ban, or, in the case of a 429, until the ban is over.We recommend using the websocket for getting data as much as possible, as this will not count to the request rate limit.
X-MBX-ORDER-COUNT-(intervalNum)(intervalLetter) header which has the current order count for the account for all order rate limiters defined.X-MBX-ORDER-COUNT-** headers in the response.Each endpoint has a security type that determines the how you will interact with it. This is stated next to the NAME of the endpoint.
X-MBX-APIKEY header.| Security Type | Description |
|---|---|
| NONE | Endpoint can be accessed freely. |
| SIGNED | Endpoint requires sending a valid API-Key and signature. |
| API_KEY | Endpoint requires sending a valid API-Key. |
SIGNED endpoints require an additional parameter, signature, to be
sent in the query string or request body.
Endpoints use HMAC SHA256 signatures. The HMAC SHA256 signature is a keyed HMAC SHA256 operation.
Use your secretKey as the key and totalParams as the value for the HMAC operation.
The signature is not case sensitive.
totalParams is defined as the query string concatenated with the
request body.
A SIGNED endpoint also requires a parameter, timestamp, to be sent which
should be the millisecond timestamp of when the request was created and sent.
An additional parameter, recvWindow, may be sent to specify the number of
milliseconds after timestamp the request is valid for. If recvWindow
is not sent, it defaults to 5000.
The logic is as follows:
if (timestamp < (serverTime + 1000) && (serverTime - timestamp) <= recvWindow)
{
// process request
}
else
{
// reject request
}
Serious trading is about timing. Networks can be unstable and unreliable,
which can lead to requests taking varying amounts of time to reach the
servers. With recvWindow, you can specify that the request must be
processed within a certain number of milliseconds or be rejected by the
server.
It is recommended to use a small recvWindow of 5000 or less! The max cannot go beyond 60,000!
Here is a step-by-step example of how to send a vaild signed payload from the Linux command line using echo, openssl, and curl.
| Key | Value |
|---|---|
| apiKey | cfDC92B191b9B3Ca3D842Ae0e01108CBKI6BqEW6xr4NrPus3hoZ9Ze9YrmWwPFV |
| secretKey | f9AbA6a8AD6bC2a97294a212244dda04ETfl0kc4BSUGOtL7m7rNELpt3Jh25SiP |
| Parameter | Value |
|---|---|
| symbol | BTC_USDT |
| side | 0 |
| type | 1 |
| quantity | '0.16' |
| price | '7500' |
| recvWindow | 5000 |
| timestamp | 1581720670624 |
requestBody: symbol=BTC_USDT&side=0&type=1&quantity=0.16&price=7500×tamp=1581720670624&recvWindow=5000
HMAC SHA256 signature:
[linux]$ echo -n "symbol=BTC_USDT&side=0&type=1&quantity=0.16&price=7500×tamp=1581720670624&recvWindow=5000" | openssl dgst -sha256 -hmac "cfDC92B191b9B3Ca3D842Ae0e01108CBKI6BqEW6xr4NrPus3hoZ9Ze9YrmWwPFV"
(stdin)= 33824b5160daefc34257ab9cd3c3db7a0158a446674f896c9fc3b122ae656bfa
curl command:
(HMAC SHA256)
[linux]$ curl -H "X-MBX-APIKEY: cfDC92B191b9B3Ca3D842Ae0e01108CBKI6BqEW6xr4NrPus3hoZ9Ze9YrmWwPFV" -X POST 'https://www.binance.tr/open/v1/orders' -d 'symbol=BTC_USDT&side=0&type=1&quantity=0.16&price=7500×tamp=1581720670624&recvWindow=5000&signature=33824b5160daefc34257ab9cd3c3db7a0158a446674f896c9fc3b122ae656bfa'
queryString: symbol=BTC_USDT&side=0&type=1&quantity=0.16&price=7500×tamp=1581720670624&recvWindow=5000
HMAC SHA256 signature:
[linux]$ echo -n "symbol=BTC_USDT&side=0&type=1&quantity=0.16&price=7500×tamp=1581720670624&recvWindow=5000" | openssl dgst -sha256 -hmac "cfDC92B191b9B3Ca3D842Ae0e01108CBKI6BqEW6xr4NrPus3hoZ9Ze9YrmWwPFV"
(stdin)= 33824b5160daefc34257ab9cd3c3db7a0158a446674f896c9fc3b122ae656bfa
curl command:
(HMAC SHA256)
[linux]$ curl -H "X-MBX-APIKEY: cfDC92B191b9B3Ca3D842Ae0e01108CBKI6BqEW6xr4NrPus3hoZ9Ze9YrmWwPFV" -X POST 'https://www.binance.tr/open/v1/orders?symbol=BTC_USDT&side=0&type=1&quantity=0.16&price=7500×tamp=1581720670624&recvWindow=5000&signature=33824b5160daefc34257ab9cd3c3db7a0158a446674f896c9fc3b122ae656bfa'
queryString: symbol=BTC_USDT&side=0&type=1
requestBody: quantity=1&price=0.1&recvWindow=5000×tamp=1499827319559
requestBody: symbol=BTC_USDT&side=0&type=1quantity=0.16&price=7500×tamp=1581720670624&recvWindow=5000
HMAC SHA256 signature:
[linux]$ echo -n "symbol=BTC_USDT&side=0&type=1quantity=0.16&price=7500×tamp=1581720670624&recvWindow=5000" | openssl dgst -sha256 -hmac "cfDC92B191b9B3Ca3D842Ae0e01108CBKI6BqEW6xr4NrPus3hoZ9Ze9YrmWwPFV"
(stdin)= 27dbb813ab6ee7ef61902f88f1a0a6cd4daca0503a5195dbdd3174f49a61ad79
curl command:
(HMAC SHA256)
[linux]$ curl -H "X-MBX-APIKEY: cfDC92B191b9B3Ca3D842Ae0e01108CBKI6BqEW6xr4NrPus3hoZ9Ze9YrmWwPFV" -X POST 'https://www.binance.tr/open/v1/orders?symbol=BTC_USDT&side=0&type=1' -d 'quantity=0.16&price=7500×tamp=1581720670624&recvWindow=5000&signature=27dbb813ab6ee7ef61902f88f1a0a6cd4daca0503a5195dbdd3174f49a61ad79'
Note that the signature is different in example 3. There is no & between "1" and "quantity=1".
base asset refers to the asset that is the quantity of a symbol.quote asset refers to the asset that is the price of a symbol.Symbol type:
Order status (status):
Order types (orderTypes, type):
Order side (side):
Kline/Candlestick chart intervals:
m -> minutes; h -> hours; d -> days; w -> weeks; M -> months
Filters define trading rules on a symbol or an exchange.
Filters come in two forms: symbol filters and exchange filters.
The PRICE_FILTER defines the price rules for a symbol. There are 3 parts:
minPrice defines the minimum price/stopPrice allowed; disabled on minPrice == 0.maxPrice defines the maximum price/stopPrice allowed; disabled on maxPrice == 0.tickSize defines the intervals that a price/stopPrice can be increased/decreased by; disabled on tickSize == 0.Any of the above variables can be set to 0, which disables that rule in the price filter. In order to pass the price filter, the following must be true for price/stopPrice of the enabled rules:
price >= minPriceprice <= maxPriceprice-minPrice) % tickSize == 0/exchangeInfo format:
{
"filterType": "PRICE_FILTER",
"minPrice": "0.00000100",
"maxPrice": "100000.00000000",
"tickSize": "0.00000100"
}
The PERCENT_PRICE filter defines valid range for a price based on the average of the previous trades.
avgPriceMins is the number of minutes the average price is calculated over. 0 means the last price is used.
In order to pass the percent price, the following must be true for price:
price <= weightedAveragePrice * multiplierUpprice >= weightedAveragePrice * multiplierDown/exchangeInfo format:
{
"filterType": "PERCENT_PRICE",
"multiplierUp": "1.3000",
"multiplierDown": "0.7000",
"avgPriceMins": 5
}
The LOT_SIZE filter defines the quantity (aka "lots" in auction terms) rules for a symbol. There are 3 parts:
minQty defines the minimum quantity/icebergQty allowed.maxQty defines the maximum quantity/icebergQty allowed.stepSize defines the intervals that a quantity/icebergQty can be increased/decreased by.In order to pass the lot size, the following must be true for quantity/icebergQty:
quantity >= minQtyquantity <= maxQtyquantity-minQty) % stepSize == 0/exchangeInfo format:
{
"filterType": "LOT_SIZE",
"minQty": "0.00100000",
"maxQty": "100000.00000000",
"stepSize": "0.00100000"
}
The NOTIONAL filter defines the minimum notional value allowed for an order on a symbol.
An order's notional value is the price * quantity.
applyToMarket determines whether or not the NOTIONAL filter will also be applied to MARKET orders.
Since MARKET orders have no price, the average price is used over the last avgPriceMins minutes.
avgPriceMins is the number of minutes the average price is calculated over. 0 means the last price is used.
/exchangeInfo format:
{
"filterType": "NOTIONAL",
"minNotional": "0.00100000",
"applyToMarket": true,
"avgPriceMins": 5
}
The ICEBERG_PARTS filter defines the maximum parts an iceberg order can have. The number of ICEBERG_PARTS is defined as CEIL(qty / icebergQty).
/exchangeInfo format:
{
"filterType": "ICEBERG_PARTS",
"limit": 10
}
The MARKET_LOT_SIZE filter defines the quantity (aka "lots" in auction terms) rules for MARKET orders on a symbol. There are 3 parts:
minQty defines the minimum quantity allowed.maxQty defines the maximum quantity allowed.stepSize defines the intervals that a quantity can be increased/decreased by.In order to pass the market lot size, the following must be true for quantity:
quantity >= minQtyquantity <= maxQtyquantity-minQty) % stepSize == 0/exchangeInfo format:
{
"filterType": "MARKET_LOT_SIZE",
"minQty": "0.00100000",
"maxQty": "100000.00000000",
"stepSize": "0.00100000"
}
The MAX_NUM_ORDERS filter defines the maximum number of orders an account is allowed to have open on a symbol.
Note that both "algo" orders and normal orders are counted for this filter.
/exchangeInfo format:
{
"filterType": "MAX_NUM_ORDERS",
"limit": 25
}
The MAX_NUM_ALGO_ORDERS filter defines the maximum number of "algo" orders an account is allowed to have open on a symbol.
"Algo" orders are STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
/exchangeInfo format:
{
"filterType": "MAX_NUM_ALGO_ORDERS",
"maxNumAlgoOrders": 5
}
The MAX_NUM_ICEBERG_ORDERS filter defines the maximum number of ICEBERG orders an account is allowed to have open on a symbol.
An ICEBERG order is any order where the icebergQty is > 0.
/exchangeInfo format:
{
"filterType": "MAX_NUM_ICEBERG_ORDERS",
"maxNumIcebergOrders": 5
}
The MAX_NUM_ORDERS filter defines the maximum number of orders an account is allowed to have open on the exchange.
Note that both "algo" orders and normal orders are counted for this filter.
/exchangeInfo format:
{
"filterType": "EXCHANGE_MAX_NUM_ORDERS",
"maxNumOrders": 1000
}
The MAX_ALGO_ORDERS filter defines the maximum number of "algo" orders an account is allowed to have open on the exchange.
"Algo" orders are STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders.
/exchangeInfo format:
{
"filterType": "EXCHANGE_MAX_ALGO_ORDERS",
"maxNumAlgoOrders": 200
}
GET /open/v1/common/time
Test connectivity to the Rest API and get the current server time.
Parameters: NONE
Response:
{
"code": 0,
"msg": "success",
"timestamp": 1572265137927
}
GET /open/v1/common/symbols
This endpoint returns all Exchange's supported trading symbol.
Parameters: NONE
Response:
{
"code": 0,
"msg": "success",
"data": {
"list": [
{
"type": 1, // 1 - Main, 2 - Next.
"symbol": "ADA_BNB",
"baseAsset": "ADA",
"basePrecision": 8,
"quoteAsset": "BNB",
"quotePrecision": 8,
"filters": [
{
"applyToMarket": false,
"filterType": "PRICE_FILTER",
"maxPrice": "1000.00000000",
"minPrice": "0.00000100",
"tickSize": "0.00000100"
},
{
"applyToMarket": false,
"avgPriceMins": "5",
"filterType": "PERCENT_PRICE",
"multiplierDown": 0.2,
"multiplierUp": 5
},
{
"applyToMarket": false,
"filterType": "LOT_SIZE",
"maxQty": "9000000.00000000",
"minQty": "1.00000000",
"stepSize": "1.00000000"
},
{
"applyToMarket": true,
"avgPriceMins": "5",
"filterType": "NOTIONAL",
"minNotional": "0.10000000"
},
{
"applyToMarket": false,
"filterType": "ICEBERG_PARTS",
"limit": "10"
},
{
"applyToMarket": false,
"filterType": "MARKET_LOT_SIZE",
"maxQty": "4526300.00000000",
"minQty": "0.00000000",
"stepSize": "0.00000000"
},
{
"applyToMarket": false,
"filterType": "MAX_NUM_ALGO_ORDERS",
"maxNumAlgoOrders": "5"
}
],
"orderTypes": [
"LIMIT",
"LIMIT_MAKER",
"MARKET",
"STOP_LOSS_LIMIT",
"TAKE_PROFIT_LIMIT"
],
"defaultSelfTradePreventionMode": "EXPIRE_MAKER",
"allowedSelfTradePreventionModes": [
"EXPIRE_TAKER",
"EXPIRE_MAKER",
"EXPIRE_BOTH",
"DECREMENT",
"TRANSFER"
],
"icebergEnable": 1,
"ocoEnable": 1,
"spotTradingEnable": 1,
"marginTradingEnable": 0
}
]
},
"timestamp": 1571921637091
}
GET /api/v3/executionRules
Weight:
| Parameter | Weight |
|---|---|
symbol |
2 |
symbols |
2 for each symbol, capped at a max of 40 |
symbolStatus |
40 |
| None | 40 |
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
symbol |
STRING | No | Query for specified symbol |
symbols |
STRING | No | Query for multiple symbols |
symbolStatus |
ENUM | No | Query for all symbols with the specified status. Supported values: TRADING, HALT, BREAK |
Notes:
Data Source: Memory
Response:
{
"symbolRules": [
{
"symbol": "BAZUSD",
"rules": [
{
"ruleType": "PRICE_RANGE",
"bidLimitMultUp": "1.0001",
"bidLimitMultDown": "0.9999",
"askLimitMultUp": "1.0001",
"askLimitMultDown": "0.9999"
}
]
}
]
}
GET https://api.binance.me/api/v3/depth (when symbol type is 1)
GET https://cloudme-tr.2meta.app/api/v1/depth (when symbol type is 3)
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | when symbol type is 1, replace _ of symbol with null string |
| limit | INT | NO | Default 100; max 5000. Valid limits:[5, 10, 20, 50, 100, 500] |
Response:
{
"code": 0,
"msg": "success",
"data": {
"lastUpdateId": 1027024,
"bids": [
[
"4.00000000", // 价位
"431.00000000", // 挂单量
]
],
"asks": [
[
"4.00000200",
"12.00000000",
]
]
},
"timestamp": 1571921637091
}
GET https://api.binance.me/api/v3/trades (when symbol type is 1)
GET /open/v1/market/trades (when symbol type is not 1)
Get recent trades (up to last 500).
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | when symbol type is 1, replace _ of symbol with null string |
| fromId | LONG | NO | ID to get trades from INCLUSIVE. |
| limit | INT | NO | Default 500; max 1000. |
Response:
{
"code": 0,
"msg": "success",
"data": [
{
"id": 28457,
"price": "4.00000100",
"qty": "12.00000000",
"time": 1499865549590,
"isBuyerMaker": true,
"isBestMatch": true
}
],
"timestamp": 1571921637091
}
GET https://api.binance.me/api/v3/aggTrades (when symbol type is 1)
GET https://cloudme-tr.2meta.app/api/v1/aggTrades (when symbol type is 3)
Get compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price will have the quantity aggregated.
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | when symbol type is 1, replace _ of symbol with null string |
| fromId | LONG | NO | ID to get aggregate trades from INCLUSIVE. |
| startTime | LONG | NO | Timestamp in ms to get aggregate trades from INCLUSIVE. |
| endTime | LONG | NO | Timestamp in ms to get aggregate trades until INCLUSIVE. |
| limit | INT | NO | Default 500; max 1000. |
Response:
{
"code": 0,
"msg": "success",
"data": [
{
"a": 26129, // Aggregate tradeId
"p": "0.01633102", // Price
"q": "4.70443515", // Quantity
"f": 27781, // First tradeId
"l": 27781, // Last tradeId
"T": 1498793709153, // Timestamp
"m": true, // Was the buyer the maker?
"M": true // Was the trade the best price match?
}
],
"timestamp": 1571921637091
}
GET https://api.binance.me/api/v1/klines (when symbol type is 1)
GET https://cloudme-tr.2meta.app/api/v1/klines (when symbol type is 3)
Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | when symbol type is 1, replace _ of symbol with null string |
| interval | ENUM | YES | |
| startTime | LONG | NO | |
| endTime | LONG | NO | |
| limit | INT | NO | Default 500; max 1000. |
Response:
{
"code": 0,
"msg": "success",
"data": [
[
1499040000000, // Open time
"0.01634790", // Open
"0.80000000", // High
"0.01575800", // Low
"0.01577100", // Close
"148976.11427815", // Volume
1499644799999, // Close time
"2434.19055334", // Quote asset volume
308, // Number of trades
"1756.87402397", // Taker buy base asset volume
"28.46694368", // Taker buy quote asset volume
"17928899.62484339" // Ignore.
]
],
"timestamp": 1571921637091
}
POST /open/v1/orders (HMAC SHA256)
Send in a new order.
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | |
| side | ENUM | YES | 0,1 |
| type | ENUM | YES | 1,2,3,4,5,6,7 |
| quantity | STRING | NO | |
| quoteOrderQty | STRING | NO | |
| price | STRING | NO | |
| clientId | STRING | NO | Client's custom ID for the order, Server does not check it's uniqueness. Automatically generated if not sent. |
| stopPrice | STRING | NO | Used with STOP_LOSS, STOP_LOSS_LIMIT, TAKE_PROFIT, and TAKE_PROFIT_LIMIT orders. |
| icebergQty | STRING | NO | Used with LIMIT, STOP_LOSS_LIMIT, and TAKE_PROFIT_LIMIT to create an iceberg order. |
| timeInForce | INT | NO | Default 1. 1 - GTC (Good Till Cancel), 2 - IOC (Immediate Or Cancel), 3 - FOK (Fill Or Kill), 4 - GTX (Post Only, cancel if would immediately match). |
| selfTradePreventionMode | INT | NO | 0 - EXPIRE_MAKER, 1 - EXPIRE_TAKER, 2 - EXPIRE_BOTH, 3 - NONE, 4 - DECREMENT, 5 - TRANSFER. |
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
Additional mandatory parameters based on type:
| Type | Additional mandatory parameters |
|---|---|
1 |
quantity, price |
2 |
quantity (sell) or quoteOrderQty (buy) |
3 |
quantity, stopPrice |
4 |
quantity, price, stopPrice |
5 |
quantity, stopPrice |
6 |
quantity, price, stopPrice |
7 |
quantity, price |
Other info:
LIMIT_MAKER are LIMIT orders that will be rejected if they would immediately match and trade as a taker.STOP_LOSS and TAKE_PROFIT will execute a MARKET order when the stopPrice is reached.LIMIT or LIMIT_MAKER type order can be made an iceberg order by sending an icebergQty.icebergQty MUST have timeInForce set to GTC.MARKET orders using quantity specifies how much a user wants to buy or sell based on the market price.MARKET orders using quoteOrderQty specifies the amount the user wants to spend (when buying) of the quote asset; the correct quantity will be determined based on the market liquidity and quoteOrderQty.MARKET orders using quoteOrderQty will not break LOT_SIZE filter rules; the order will execute a quantity that will have the notional value as close as possible to quoteOrderQty.Trigger order price rules against market price for both MARKET and LIMIT versions:
STOP_LOSS BUY, TAKE_PROFIT SELLSTOP_LOSS SELL, TAKE_PROFIT BUYResponse:
{
"code": 0,
"message": "success",
"data": {
"orderId": "4",
"createTime": 1550130502385
},
"timestamp": 1550130502489
}
GET /open/v1/orders/detail (HMAC SHA256)
Check an order's status.
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| orderId | LONG | NO | One of orderId and clientId must be filled in |
| clientId | STRING | NO | One of orderId and clientId must be filled in |
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
Response:
{
"code": 0,
"message": "success",
"data": {
"orderId": 4,
"orderListId": -1 //Unless part of an OCO, the value will always be -1.
"clientId": "myOrder1",
"symbol": "BTC_USDT",
"side": 1,
"type": 1,
"price": 1,
"status": 0,
"origQty": 10.88,
"origQuoteQty": 0,
"executedQty": 0,
"executedPrice": 0,
"executedQuoteQty": 0,
"createTime": 1550130502000
},
"timestamp": 1550130554182
}
POST /open/v1/orders/cancel (HMAC SHA256)
Cancel an active order.
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| orderId | LONG | NO | One of orderId and clientId must be filled in |
| clientId | STRING | NO | One of orderId and clientId must be filled in |
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
Response:
{
"code": 0,
"message": "success",
"data": {
"orderId": 4,
"orderListId": -1 // Unless part of an OCO, the value will always be -1.
"clientId": "myOrder1",
"symbol": "BTC_USDT",
"side": 1,
"type": 1,
"price": 1,
"status": 0,
"origQty": 10.88,
"origQuoteQty": 0,
"executedQty": 0,
"executedPrice": 0,
"executedQuoteQty": 0,
"createTime": 1550130502000
},
"timestamp": 1550130554182
}
POST /open/v1/orders/batch-cancel (HMAC SHA256)
Cancel multiple active orders. Either symbol or orderIds must be sent.
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | NO | Cancel all open orders for this symbol. |
| orderIds | LIST\<LONG> | NO | List of order IDs to cancel, e.g. [1,2,3]. |
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
Notes:
symbol or orderIds must be sent.Response:
{
"code": 0,
"msg": "success",
"data": {
"succeedIds": [
1,
2,
3
],
"failedIds": [
{
"orderId": 4,
"code": 500,
"message": "The order has been cancelled or does not exist"
}
]
},
"timestamp": 1571921637091
}
GET /open/v1/orders (HMAC SHA256)
Get all account orders; active, canceled, or filled.
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | |
| type | ENUM | NO | 1-open, 2-history, -1-all |
| side | ENUM | NO | |
| startTime | LONG | NO | |
| endTime | LONG | NO | |
| fromId | String | NO | start order ID the searching to begin with. |
| direct | ENUM | NO | searching direction: prev - in ascending order from the start order ID; next - in descending order from the start order ID |
| limit | INT | NO | Default 500; max 1000. |
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
Notes:
Response:
{
"code": 0,
"msg": "success",
"data": {
"list": [
{
"orderId": "21",
"clientId": "uuid",
"symbol": "ADA_USDT",
"symbolType": 1,
"side": 1,
"type": 1,
"price": "0.1",
"origQty": "10",
"origQuoteQty": "1",
"executedQty": "0",
"executedPrice": "0",
"executedQuoteQty": "0",
"timeInForce": 1,
"stopPrice": "0.0000000000000000",
"icebergQty": "0.0000000000000000",
"status": 0,
"isWorking": 0,
"createTime": 1572692016811
}
]
},
"timestamp": 1572860756458
}
POST /open/v1/orders/oco (HMAC SHA256)
Send in a new OCO
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | |
| listClientId | STRING | NO | Client's custom ID for the entire orderList, Server does not check it's uniqueness. Automatically generated if not sent. |
| side | ENUM | YES | |
| quantity | STRING | YES | |
| limitClientId | STRING | NO | Client's custom ID for the limit order, Server does not check it's uniqueness. Automatically generated if not sent. |
| price | STRING | YES | |
| stopClientId | STRING | NO | Client's custom ID for the stop loss/stop loss limit order, Server does not check it's uniqueness. Automatically generated if not sent. |
| stopPrice | STRING | YES | Stop price |
| stopLimitPrice | STRING | YES | Stop limit price. |
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
Additional Info:
Price Restrictions:
SELL: Limit Price > Last Price > Stop PriceBUY: Limit Price < Last Price < Stop PriceResponse:
{
"code": 0,
"message": "success",
"data": {
"orderId": "4",
"createTime": 1550130502385
},
"timestamp": 1550130502489
}
GET /open/v1/account/spot (HMAC SHA256)
Get current account information.
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
Response:
Response fields:
| Name | Type | Description |
|---|---|---|
| makerCommission | string | Maker commission rate |
| takerCommission | string | Taker commission rate |
| buyerCommission | string | Buyer commission rate |
| sellerCommission | string | Seller commission rate |
| fiatMakerCommission | string | Maker commission rate for TRY (fiat) pairs |
| fiatTakerCommission | string | Taker commission rate for TRY (fiat) pairs |
| canTrade | int | Whether trading is allowed |
| canWithdraw | int | Whether withdrawal is allowed |
| canDeposit | int | Whether deposit is allowed |
| accountAssets | array | List of account assets |
{
"code": 0,
"msg": "success",
"data": {
"makerCommission": "10.00000000",
"takerCommission": "10.00000000",
"buyerCommission": "0.00000000",
"sellerCommission": "0.00000000",
"fiatMakerCommission": "0.001500",
"fiatTakerCommission": "0.001500",
"canTrade": 1,
"canWithdraw": 1,
"canDeposit": 1,
"accountAssets": [
{
"asset": "ADA",
"free": "272.5550000000000000",
"locked": "3.0000000000000000"
}
]
},
"timestamp": 1572514387348
}
GET /open/v1/account/spot/asset (HMAC SHA256)
Get current account information for a specific asset.
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| asset | STRING | YES | |
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
Response:
{
"code": 0,
"msg": "success",
"data": {
"asset": "ADA",
"free": "272.5550000000000000",
"locked": "3.0000000000000000",
},
"timestamp": 1572514387348
}
GET /open/v1/orders/trades (HMAC SHA256)
Get trades for a specific account and symbol.
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| symbol | STRING | YES | |
| orderId | String | NO | |
| startTime | LONG | NO | |
| endTime | LONG | NO | |
| fromId | LONG | NO | TradeId to fetch from. Default gets most recent trades. |
| direct | ENUM | NO | searching direction: prev - in ascending order from the start order ID; next - in descending order from the start order ID |
| limit | INT | NO | Default 500; max 1000. |
| recvWindow | LONG | NO | The value cannot be greater than 60000 |
| timestamp | LONG | YES |
Notes:
Response:
{
"code": 0,
"msg": "success",
"data": {
"list": [
{
"tradeId": "3",
"orderId": "2",
"symbol": "ADA_USDT",
"price": "0.04398",
"qty": "250",
"quoteQty": "10.995",
"commission": "0.25",
"commissionAsset": "ADA",
"isBuyer": 1,
"isMaker": 0,
"isBestMatch": 1,
"time": "1572920872276"
}
]
},
"timestamp": 1573723498893
}
POST /open/v1/withdraws (HMAC SHA256)
Submit a withdraw request.
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| asset | STRING | YES | |
| clientId | STRING | NO | Client's custom ID for withdraw order, Server does not check it's uniqueness. Automatically generated if not sent. |
| network | STRING | NO | |
| address | STRING | YES | |
| addressTag | STRING | NO | Secondary address identifier for coins like XRP,XMR etc. |
| amount | STRING | YES | |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES | |
| channel | Number | YES | 1-wallet, 2-vasp |
| targetType | Number | YES | 1-myself, 2-others |
| entityType | Number | YES | 1-personal ,2-corporate |
| vasp | String | NO | If channel=2, it is required |
| name | String | NO | If entityType=2, it is required |
| birthdate | String | NO | If entityType=2, it is required |
| idNo | String | NO | ID/TIN/Passport |
| homeAddr | String | NO | home address |
| countryName | String | NO | |
| countryCode3 | String | NO | Country code (3 digits) |
| countryCode2 | String | NO | Country code (2 digits) |
| cityName | String | NO | |
| cityCode | String | NO | |
| corporateName | String | NO | If entityType=2, it is required |
| corporateTin | String | NO | corporate tax ID |
| description | String | YES |
Response:
{
"code": 0,
"msg": "成功",
"data": {
"withdrawId":"12"
},
"timestamp": 1571745049095
}
GET /open/v1/withdraws (HMAC SHA256)
Fetch withdraw history.
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| asset | STRING | NO | |
| status | INT | NO | 0(0:Email Sent,1:Cancelled 2:Awaiting Approval 3:Rejected 4:Processing 5:Failure 10:Completed) |
| fromId | LONG | NO | ID to fetch from. Default gets most recent records. |
| startTime | LONG | NO | |
| endTime | LONG | NO | |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES |
Response:
{
"code": 0,
"msg": "成功",
"data": {
"list": [
{
"id": 1,
"clientId": "1",
"asset": "BTC",
"network": "BTC",
"address": "1G58aoKLVd1vHkv7wi6R2rKUrjuk4ZRtY3",
"amount": "0.001",
"fee": "0.0005",
"txId": "",
"status": 4,
"createTime": 1572359825000,
}
]
},
"timestamp": 1572402980747
}
GET /open/v1/fiat/withdraws (HMAC SHA256)
Fetch fiat withdraw history.
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| asset | STRING | NO | |
| status | INT | NO | (1:CANCELED 2:CONFIRMED 3:AUDIT-REJECTED 4:AUDIT-PASSED 5:FAILED 10:SUCCEED) |
| fromId | LONG | NO | ID to fetch from. Default gets most recent records. |
| direct | STRING | NO | 'prev', 'next' |
| startTime | LONG | NO | |
| endTime | LONG | NO | |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES |
Response:
{
"code": 0,
"msg": "",
"data": {
"list": [
{
"id": 1,
"asset": "",
"amount": "10",
"fee": "1",
"txId": "",
"status": 1,
"createTime": 1583493783852
}
]
},
"timestamp": 1572402980747
}
GET /open/v1/deposits (HMAC SHA256)
Fetch deposit history. Parameters: Name | Type | Mandatory | Description ------------ | ------------ | ------------ | ------------ asset | STRING | NO status | INT | NO | 0(0:pending, 1:success) fromId | LONG | NO | ID to fetch from. Default gets most recent records. startTime | LONG | NO endTime | LONG | NO recvWindow | LONG | NO timestamp | LONG | YES Response:
{
"code": 0,
"msg": "成功",
"data": {
"list": [
{
"id": 1,
"asset": "BTC",
"network": "BTC",
"address": "2",
"addressTag": "2",
"txId": "1",
"amount": "1.000000000000000000000000000000",
"status": 1,
"insertTime": "0"
}
]
},
"timestamp": 1572317515063
}
GET /open/v1/fiat/deposits (HMAC SHA256)
Fetch fiat deposit history.
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| asset | STRING | NO | |
| fromId | LONG | NO | ID to fetch from. Default gets most recent records. |
| direct | STRING | NO | 'prev', 'next' |
| startTime | LONG | NO | |
| endTime | LONG | NO | |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES |
Response:
{
"code": 0,
"msg": "",
"data": {
"list": [
{
"id": 8,
"asset": "TRY",
"txId": "",
"amount": "500",
"fillAmount": "500",
"status": 1, // 1:pending 2:timeout 3:failed 10:success
"insertTime": 1584347139000
}
]
},
"timestamp": 1572317515063
}
GET /open/v1/deposits/address (HMAC SHA256)
Fetch deposit address.
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| asset | STRING | YES | |
| network | STRING | YES | |
| recvWindow | LONG | NO | |
| timestamp | LONG | YES |
Response:
{
"code": 0,
"msg": "成功",
"data": {
"address": "0x6915f16f8791d0a1cc2bf47c13a6b2a92000504b",
"addressTag": "1231212",
"asset": "BNB"
},
"timestamp": 1571745049095
}
ping frame every 3 minutes. If the websocket server does not receive a pong frame back from the connection within a 10 minute period, the connection will be disconnected. Unsolicited pong frames are allowed.id used in the JSON payloads is an unsigned INT used as an identifier to uniquely identify the messages going back and forth.result received is null this means the request sent was a success for non-query requests (e.g. Subscribing/Unsubscribing).Request
{
"method": "SUBSCRIBE",
"params": [
"btcusdt@aggTrade",
"btcusdt@depth"
],
"id": 1
}
Response
{
"result": null,
"id": 1
}
Request
{
"method": "UNSUBSCRIBE",
"params": [
"btcusdt@depth"
],
"id": 312
}
Response
{
"result": null,
"id": 312
}
Request
{
"method": "LIST_SUBSCRIPTIONS",
"id": 3
}
Response
{
"result": [
"btcusdt@aggTrade"
],
"id": 3
}
Currently, the only property can be set is to set whether combined stream payloads are enabled are not.
The combined property is set to false when connecting using /ws/ ("raw streams") and true when connecting using /stream/.
Request
{
"method": "SET_PROPERTY",
"params": [
"combined",
true
],
"id": 5
}
Response
{
"result": null,
"id": 5
}
Request
{
"method": "GET_PROPERTY",
"params": [
"combined"
],
"id": 2
}
Response
{
"result": true, // Indicates that combined is set to true.
"id": 2
}
| Error Message | Description |
|---|---|
| {"code": 0, "msg": "Unknown property"} | Parameter used in the SET_PROPERTY or GET_PROPERTY was invalid |
| {"code": 1, "msg": "Invalid value type: expected Boolean"} | Value should only be true or false |
| {"code": 2, "msg": "Invalid request: property name must be a string"} | Property name provided was invalid |
| {"code": 2, "msg": "Invalid request: request ID must be an unsigned integer"} | Parameter id had to be provided or the value provided in the id parameter is an unsupported type |
{"code": 2, "msg": "Invalid request: unknown variant %s, expected one of SUBSCRIBE, UNSUBSCRIBE, LIST_SUBSCRIPTIONS, SET_PROPERTY, GET_PROPERTY at line 1 column 28"} |
Possible typo in the provided method or provided method was neither of the expected values |
| {"code": 2, "msg": "Invalid request: too many parameters"} | Unnecessary parameters provided in the data |
| {"code": 2, "msg": "Invalid request: property name must be a string"} | Property name was not provided |
{"code": 2, "msg": "Invalid request: missing field method at line 1 column 73"} |
method was not provided in the data |
| {"code":3,"msg":"Invalid JSON: expected value at line %s column %s"} | JSON data sent has incorrect syntax. |
The Aggregate Trade Streams push trade information that is aggregated for a single taker order.
Stream Name: \<symbol>@aggTrade
Update Speed: Real-time
Payload:
{
"e": "aggTrade", // Event type
"E": 123456789, // Event time
"s": "BNBBTC", // Symbol
"a": 12345, // Aggregate trade ID
"p": "0.001", // Price
"q": "100", // Quantity
"f": 100, // First trade ID
"l": 105, // Last trade ID
"T": 123456785, // Trade time
"m": true, // Is the buyer the market maker?
"M": true // Ignore
}
The Trade Streams push raw trade information; each trade has a unique buyer and seller.
Stream Name: \<symbol>@trade
Update Speed: Real-time
Payload:
{
"e": "trade", // Event type
"E": 123456789, // Event time
"s": "BNBBTC", // Symbol
"t": 12345, // Trade ID
"p": "0.001", // Price
"q": "100", // Quantity
"b": 88, // Buyer order ID
"a": 50, // Seller order ID
"T": 123456785, // Trade time
"m": true, // Is the buyer the market maker?
"M": true // Ignore
}
The Kline/Candlestick Stream push updates to the current klines/candlestick every second.
Kline/Candlestick chart intervals:
m -> minutes; h -> hours; d -> days; w -> weeks; M -> months
Stream Name: \<symbol>@kline_\<interval>
Update Speed: 2000ms
Payload:
{
"e": "kline", // Event type
"E": 123456789, // Event time
"s": "BNBBTC", // Symbol
"k": {
"t": 123400000, // Kline start time
"T": 123460000, // Kline close time
"s": "BNBBTC", // Symbol
"i": "1m", // Interval
"f": 100, // First trade ID
"L": 200, // Last trade ID
"o": "0.0010", // Open price
"c": "0.0020", // Close price
"h": "0.0025", // High price
"l": "0.0015", // Low price
"v": "1000", // Base asset volume
"n": 100, // Number of trades
"x": false, // Is this kline closed?
"q": "1.0000", // Quote asset volume
"V": "500", // Taker buy base asset volume
"Q": "0.500", // Taker buy quote asset volume
"B": "123456" // Ignore
}
}
24hr rolling window mini-ticker statistics. These are NOT the statistics of the UTC day, but a 24hr rolling window for the previous 24hrs.
Stream Name: \<symbol>@miniTicker
Update Speed: 1000ms
Payload:
{
"e": "24hrMiniTicker", // Event type
"E": 123456789, // Event time
"s": "BNBBTC", // Symbol
"c": "0.0025", // Close price
"o": "0.0010", // Open price
"h": "0.0025", // High price
"l": "0.0010", // Low price
"v": "10000", // Total traded base asset volume
"q": "18" // Total traded quote asset volume
}
24hr rolling window mini-ticker statistics for all symbols that changed in an array. These are NOT the statistics of the UTC day, but a 24hr rolling window for the previous 24hrs. Note that only tickers that have changed will be present in the array.
Stream Name: !miniTicker@arr
Update Speed: 1000ms
Payload:
[
{
// Same as <symbol>@miniTicker payload
}
]
Top \<levels> bids and asks, pushed every second. Valid \<levels> are 5, 10, or 20.
Stream Names: \<symbol>@depth\<levels> OR \<symbol>@depth\<levels>@100ms
Update Speed: 1000ms or 100ms
Payload:
{
"lastUpdateId": 160, // Last update ID
"bids": [ // Bids to be updated
[
"0.0024", // Price level to be updated
"10" // Quantity
]
],
"asks": [ // Asks to be updated
[
"0.0026", // Price level to be updated
"100" // Quantity
]
]
}
Order book price and quantity depth updates used to locally manage an order book.
Stream Name: \<symbol>@depth OR \<symbol>@depth@100ms
Update Speed: 1000ms or 100ms
Payload:
{
"e": "depthUpdate", // Event type
"E": 123456789, // Event time
"s": "BNBBTC", // Symbol
"U": 157, // First update ID in event
"u": 160, // Final update ID in event
"b": [ // Bids to be updated
[
"0.0024", // Price level to be updated
"10" // Quantity
]
],
"a": [ // Asks to be updated
[
"0.0026", // Price level to be updated
"100" // Quantity
]
]
}
u is <= lastUpdateId in the snapshot.U <= lastUpdateId+1 AND u >= lastUpdateId+1.U should be equal to the previous event's u+1.listenKey is valid for 60 minutes after creation.PUT on a listenKey will extend its validity for 60 minutes.DELETE on a listenKey will close the stream.POST /open/v1/user-data-stream (when symbolType is 1, MBX symbol)
POST /open/v1/private-n/user-data-stream (when symbolType is 3, Nextme Symbol(New Symbol) )
Notice: For symbolType 1 (MBX symbol), this interface will be deprecated soon. Please switch to POST /open/v1/user-listen-token. For symbolType 3, no change is required.
Start a new user data stream. The stream will close after 60 minutes unless a keepalive is sent.
Weight: 1
Parameters: NONE
Response:
{
"code": 0,
"data": "pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1"
}
PUT /open/v1/user-data-stream (when symbolType is 1, MBX symbol)
PUT /open/v1/private-n/user-data-stream (when symbolType is 3, Nextme Symbol(New Symbol) )
Notice: For symbolType 1 (MBX symbol), this interface will be deprecated soon. Please switch to POST /open/v1/user-listen-token. For symbolType 3, no change is required.
Keepalive a user data stream to prevent a time out. User data streams will close after 60 minutes. It's recommended to send a ping about every 30 minutes.
Weight: 1
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| listenKey | STRING | YES |
Response:
{}
DELETE /open/v1/user-data-stream (when symbolType is 1, MBX symbol)
DELETE /open/v1/private-n/user-data-stream (when symbolType is 3, Nextme Symbol(New Symbol) )
Notice: For symbolType 1 (MBX symbol), this interface will be deprecated soon. Please switch to POST /open/v1/user-listen-token. For symbolType 3, no change is required.
Close out a user data stream.
Weight: 1
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| listenKey | STRING | YES |
Response:
{}
POST /open/v1/user-listen-token
Create a new listen token for user data stream subscription via WebSocket API.
Weight: 1
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| validity | Integer | NO | The number of milliseconds the token should be valid. Defaults to 1 day. If the validity provided is greater than the max, an error will be thrown. |
| recvWindow | Long | NO | The value cannot be greater than 60000 |
| timestamp | Long | YES |
Response:
Notes:
{
"code": 0,
"data": {
"token": "6xXxePXwZRjVSHKhzUCCGnmN3fkvMTXru+pYJS8RwijXk9Vcyr3rkwfVOTcP2OkONqciYA",
"expirationTime": 1758792204196 // Token expiration timestamp in milliseconds
}
}
/v1/common/system-config (field: binanceWssApiBaseUrl or binanceWssApiBaseUrlList)listenToken obtained from POST /open/v1/user-listen-token to subscribe to user data streamslistenToken subscription does not require an authenticated sessionPOST /open/v1/user-listen-token for new token → subscribe.listenToken with new tokenSubscribe to user data stream using a listenToken.
Method: userDataStream.subscribe.listenToken
Weight: 2
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| listenToken | STRING | YES | The listen token obtained from POST /open/v1/user-listen-token |
Request:
Response:
Notes:
POST /open/v1/user-listen-token before the expiration of your current subscription, obtain a new listenToken with an updated expirationTime, and call userDataStream.subscribe.listenToken again passing the new listenToken. This will seamlessly extend your subscription to the new expirationDate.eventStreamTerminated event (see example below).{
"id": "f3a8f7a29f2e54df796db582f3d",
"method": "userDataStream.subscribe.listenToken",
"params": {
"listenToken": "6xXxePXwZRjVSHKhzUCCGnmN3fkvMTXru+pYJS8RwijXk9Vcyr3rkwfVOTcP2OkONqciYA"
}
}
{
"subscriptionId": 1,
"expirationTime": 1749094553955907 // Subscription expiration timestamp
}
Unsubscribe from user data stream.
Method: userDataStream.unsubscribe
Weight: 2
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| subscriptionId | INT | NO | If omitted, all subscriptions will be closed |
Request:
Response:
{
"id": "d3df8a21-98ea-4fe0-8f4e-0fcea5d418b7",
"method": "userDataStream.unsubscribe"
}
{
"result": null,
"id": "d3df8a21-98ea-4fe0-8f4e-0fcea5d418b7"
}
When a subscription expires without renewal, the server will push an eventStreamTerminated event.
Payload:
{
"subscriptionId": 0,
"event": {
"e": "eventStreamTerminated", // Event type
"E": 1759089357377 // Event time (milliseconds)
}
}
Account state is updated with the outboundAccountPosition event.
Payload:
{
"e": "outboundAccountPosition", // Event type
"E": 1499405658849, // Event time
"m": 0, // Maker commission rate (bips)
"t": 0, // Taker commission rate (bips)
"b": 0, // Buyer commission rate (bips)
"s": 0, // Seller commission rate (bips)
"T": true, // Can trade?
"W": true, // Can withdraw?
"D": true, // Can deposit?
"u": 1499405658848, // Time of last account update
"B": [ // Balances array
{
"a": "LTC", // Asset
"f": "17366.18538083", // Free amount
"l": "0.00000000" // Locked amount
},
{
"a": "BTC",
"f": "10537.85314051",
"l": "2.19464093"
},
{
"a": "ETH",
"f": "17902.35190619",
"l": "0.00000000"
},
{
"a": "BNC",
"f": "1114503.29769312",
"l": "0.00000000"
},
{
"a": "NEO",
"f": "0.00000000",
"l": "0.00000000"
}
]
}
Orders are updated with the executionReport event. Check the API documentation and below for relevant enum definitions.
Average price can be found by doing Z divided by z.
Payload:
Execution types:
{
"e": "executionReport", // Event type
"E": 1499405658658, // Event time
"s": "ETHBTC", // Symbol
"c": "mUvoqJxFIILMdfAW5iGSOW", // order ID
"S": "BUY", // Side
"o": "LIMIT", // Order type
"f": "GTC", // Time in force
"q": "1.00000000", // Order quantity
"p": "0.10264410", // Order price
"P": "0.00000000", // Stop price
"F": "0.00000000", // Iceberg quantity
"g": -1, // Ignore
"C": "null", // Original client order ID; This is the ID of the order being canceled
"x": "NEW", // Current execution type
"X": "NEW", // Current order status
"r": "NONE", // Order reject reason; will be an error code.
"i": 4293153, // Binance Order ID
"l": "0.00000000", // Last executed quantity
"z": "0.00000000", // Cumulative filled quantity
"L": "0.00000000", // Last executed price
"n": "0", // Commission amount
"N": null, // Commission asset
"T": 1499405658657, // Transaction time
"t": -1, // Trade ID
"I": 8641984, // Ignore
"w": true, // Is the order working? Stops will have
"m": false, // Is this trade the maker side?
"M": false, // Ignore
"O": 1499405658657, // Order creation time
"Z": "0.00000000", // Cumulative quote asset transacted quantity
"Y": "0.00000000" // Last quote asset transacted quantity (i.e. lastPrice * lastQty)
}
Disclaimer: The symbols and values used here are fictional and do not imply anything about the actual configuration of the live exchange.
Execution rules are trading rules enforced at order execution time. The only execution rule currently available is the Price Range rule.
This rule ensures trades may only execute at prices within and equal to a price range around a reference price.
| API | Request |
|---|---|
| REST API | GET /api/v3/executionRules |
| WebSocket API | executionRules |
| API | Request |
|---|---|
| REST API | GET /api/v3/referencePrice |
| WebSocket API | referencePrice |
| WebSocket Streams | <symbol>@referencePrice |
Note: The reference price is continually changing, so monitoring via WebSocket Streams is recommended.
Example execution rule for a hypothetical symbol:
Example reference price:
At time 1770736694138:
BUY order may not execute at a price more than twice or less than half the reference price.SELL order may not execute at a price more than twice or less than half the reference price.{
"symbolRules": [
{
"symbol": "BAZUSD",
"rules": [
{
"ruleType": "PRICE_RANGE",
"bidMultiplierUp": "2.0000",
"bidMultiplierDown": "0.5000",
"askMultiplierUp": "2.0000",
"askMultiplierDown": "0.5000"
}
]
}
]
}
{
"symbol": "BAZUSD",
"referencePrice": "10.00",
"timestamp": 1770736694138
}
PRICE_RANGE and no reference price?The Price Range Execution Rule is not enforced on the symbol.
PRICE_RANGE but does have a reference price?The Price Range Execution Rule is not enforced on the symbol.
PRICE_RANGE but does not have a reference price?The Price Range Execution Rule is not enforced on the symbol.
PRICE_RANGE that does not have all four multipliers?When a multiplier is absent, the rule is not enforced for that order side and price direction. For example, if bidMultiplierDown were missing, a BUY order could execute at any price at or below twice the reference price.
null?The Price Range Execution Rule is not enforced on the symbol.
When an order enters its taker phase, the reference price is recalculated to set the execution price limits for the order's entire taker phase. A single taker order may match with many maker orders during this phase.
The taker order will be expired (status: EXPIRED) with expiry reason EXECUTION_RULE_PRICE_RANGE_EXCEEDED.
| Service | Reference |
|---|---|
| Non-FIX APIs | expiryReason |
| FIX APIs | ExpiryReason <25056> |
| User Data Stream | "eR" |
"calculationType": "ARITHMETIC_MEAN""calculationType": "EXTERNAL" (see below)The matching engine computes a simple moving average of trade prices over a time window configured with bucketWidthMs (bucket width in milliseconds) and bucketCount. The product of these defines the window size.
When a trade occurs, the engine captures the price and adds it to the current bucket. Each bucket has:
The engine calculates a bucket's average by dividing sum by trade count. Buckets accumulate as trades occur; a bucket is dropped when its close time exits the window. Thus:
bucketCount.The oldest time in the window is called the "cutoff time."
When the oldest bucket straddles the cutoff time, its contents are prorated:
The reference price is the total of the sum in each bucket divided by the total of the trade count in each bucket. Division is truncating integer division.
If external, a query returns "externalCalculationId" followed by an integer. Each integer indicates a different calculation method.
The reference price was set manually by a human operator. This calculation method will only be used in situations when algorithmic calculation of the reference price has been deemed unsuitable.
Disclaimer: The commissions and prices used here are fictional and do not imply anything about the actual setup on the live exchange.
Self Trade Prevention (or STP) prevents orders of users to match against their own.
A self-trade can occur in either scenario:
There are five possible modes for what the system does when an order would create a self-trade.
NONE - This mode exempts the order from self-trade prevention. Accounts or Trade group IDs will not be compared, no orders will be expired, and the trade will occur.
EXPIRE_TAKER - This mode prevents a trade by immediately expiring the taker order's remaining quantity.
EXPIRE_MAKER - This mode prevents a trade by immediately expiring the potential maker order's remaining quantity.
EXPIRE_BOTH - This mode prevents a trade by immediately expiring both the taker and the potential maker orders' remaining quantities.
DECREMENT - This mode increases the prevented quantity of both orders by the amount of the prevented match. The smaller of the two orders will expire, or both if they have the same quantity.
TRANSFER - If orders are from the same account, then the behavior is the same as DECREMENT. If orders are from different accounts with the same tradeGroupId, then in addition to the behavior of DECREMENT, the last prevented quantity and its notional are transferred between the two accounts.
STP behavior is typically determined by the STP mode of the taker order only. The exception is that for STP TRANSFER to occur, both the maker and taker orders must specify STP mode TRANSFER. If the taker order specifies STP mode TRANSFER, but the maker order specifies a different STP mode, then the STP behavior is DECREMENT.
In summary:
| Taker Order STP Mode | Maker Order STP Mode | Effective STP Mode |
|---|---|---|
TRANSFER |
TRANSFER |
TRANSFER |
TRANSFER |
EXPIRE_MAKER, EXPIRE_TAKER, EXPIRE_BOTH, NONE, DECREMENT |
DECREMENT |
EXPIRE_MAKER, EXPIRE_TAKER, EXPIRE_BOTH, NONE, DECREMENT |
ANY STP MODE | STP mode of the Taker Order |