Trading endpoints
New order (TRADE)
POST /api/v3/order
Send in a new order.
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
side | ENUM | YES | |
type | ENUM | YES | |
timeInForce | ENUM | NO | |
quantity | DECIMAL | NO | |
quoteOrderQty | DECIMAL | NO | |
price | DECIMAL | NO | |
newClientOrderId | STRING | NO | A unique id among open orders. Automatically generated if not sent. Orders with the same newClientOrderID can be accepted only when the previous one is filled, otherwise the order will be rejected. |
strategyId | LONG | NO | |
strategyType | INT | NO | The value cannot be less than 1000000 . |
stopPrice | DECIMAL | NO | Used with STOP_LOSS , STOP_LOSS_LIMIT , TAKE_PROFIT , and TAKE_PROFIT_LIMIT orders. |
trailingDelta | LONG | NO | Used with STOP_LOSS , STOP_LOSS_LIMIT , TAKE_PROFIT , and TAKE_PROFIT_LIMIT orders. |
icebergQty | DECIMAL | NO | Used with LIMIT , STOP_LOSS_LIMIT , and TAKE_PROFIT_LIMIT to create an iceberg order. |
newOrderRespType | ENUM | NO | Set the response JSON. ACK , RESULT , or FULL ; MARKET and LIMIT order types default to FULL , all other orders default to ACK . |
selfTradePreventionMode | ENUM | NO | The allowed enums is dependent on what is configured on the symbol. The possible supported values are EXPIRE_TAKER , EXPIRE_MAKER , EXPIRE_BOTH , NONE . |
recvWindow | LONG | NO | The value cannot be greater than 60000 |
timestamp | LONG | YES |
Some additional mandatory parameters based on order type
:
Type | Additional mandatory parameters | Additional Information |
---|---|---|
LIMIT | timeInForce , quantity , price | |
MARKET | quantity or quoteOrderQty | MARKET orders using the quantity field specifies the amount of the base asset the user wants to buy or sell at the market price. E.g. MARKET order on BTCUSDT will specify how much BTC the user is buying or selling. MARKET orders using quoteOrderQty specifies the amount the user wants to spend (when buying) or receive (when selling) the quote asset; the correct quantity will be determined based on the market liquidity and quoteOrderQty . E.g. Using the symbol BTCUSDT: BUY side, the order will buy as many BTC as quoteOrderQty USDT can. SELL side, the order will sell as much BTC needed to receive quoteOrderQty USDT. |
STOP_LOSS | quantity , stopPrice or trailingDelta | This will execute a MARKET order when the conditions are met. (e.g. stopPrice is met or trailingDelta is activated) |
STOP_LOSS_LIMIT | timeInForce , quantity , price , stopPrice or trailingDelta | |
TAKE_PROFIT | quantity , stopPrice or trailingDelta | This will execute a MARKET order when the conditions are met. (e.g. stopPrice is met or trailingDelta is activated) |
TAKE_PROFIT_LIMIT | timeInForce , quantity , price , stopPrice or trailingDelta | |
LIMIT_MAKER | quantity , price | This is a LIMIT order that will be rejected if the order immediately matches and trades as a taker. This is also known as a POST-ONLY order. |
Other info:
-
Any
LIMIT
orLIMIT_MAKER
type order can be made an iceberg order by sending anicebergQty
. -
Any order with an
icebergQty
MUST havetimeInForce
set toGTC
. -
For
STOP_LOSS
,STOP_LOSS_LIMIT
,TAKE_PROFIT_LIMIT
andTAKE_PROFIT
orders,trailingDelta
can be combined withstopPrice
. -
MARKET
orders usingquoteOrderQty
will not breakLOT_SIZE
filter rules; the order will execute aquantity
that will have the notional value as close as possible toquoteOrderQty
. Trigger order price rules against market price for both MARKET and LIMIT versions: -
Price above market price:
STOP_LOSS
BUY
,TAKE_PROFIT
SELL
-
Price below market price:
STOP_LOSS
SELL
,TAKE_PROFIT
BUY
Data Source: Matching Engine
Response - ACK:
{
"symbol": "BTCUSDT",
"orderId": 28,
"orderListId": -1, // Unless it's part of an order list, value will be -1
"clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
"transactTime": 1507725176595
}
Response - RESULT:
{
"symbol": "BTCUSDT",
"orderId": 28,
"orderListId": -1, // Unless it's part of an order list, value will be -1
"clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
"transactTime": 1507725176595,
"price": "0.00000000",
"origQty": "10.00000000",
"executedQty": "10.00000000",
"origQuoteOrderQty": "0.000000",
"cummulativeQuoteQty": "10.00000000",
"status": "FILLED",
"timeInForce": "GTC",
"type": "MARKET",
"side": "SELL",
"workingTime": 1507725176595,
"selfTradePreventionMode": "NONE"
}
Response - FULL:
{
"symbol": "BTCUSDT",
"orderId": 28,
"orderListId": -1, // Unless it's part of an order list, value will be -1
"clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
"transactTime": 1507725176595,
"price": "0.00000000",
"origQty": "10.00000000",
"executedQty": "10.00000000",
"origQuoteOrderQty": "0.000000",
"cummulativeQuoteQty": "10.00000000",
"status": "FILLED",
"timeInForce": "GTC",
"type": "MARKET",
"side": "SELL",
"workingTime": 1507725176595,
"selfTradePreventionMode": "NONE",
"fills": [
{
"price": "4000.00000000",
"qty": "1.00000000",
"commission": "4.00000000",
"commissionAsset": "USDT",
"tradeId": 56
},
{
"price": "3999.00000000",
"qty": "5.00000000",
"commission": "19.99500000",
"commissionAsset": "USDT",
"tradeId": 57
},
{
"price": "3998.00000000",
"qty": "2.00000000",
"commission": "7.99600000",
"commissionAsset": "USDT",
"tradeId": 58
},
{
"price": "3997.00000000",
"qty": "1.00000000",
"commission": "3.99700000",
"commissionAsset": "USDT",
"tradeId": 59
},
{
"price": "3995.00000000",
"qty": "1.00000000",
"commission": "3.99500000",
"commissionAsset": "USDT",
"tradeId": 60
}
]
}
Conditional fields in Order Responses
There are fields in the order responses (e.g. order placement, order query, order cancellation) that appear only if certain conditions are met.
These fields can apply to order lists.
The fields are listed below:
Field | Description | Visibility conditions | Examples |
---|---|---|---|
icebergQty | Quantity for the iceberg order | Appears only if the parameter icebergQty was sent in the request. | "icebergQty": "0.00000000" |
preventedMatchId | When used in combination with symbol , can be used to query a prevented match. | Appears only if the order expired due to STP. | "preventedMatchId": 0 |
preventedQuantity | Order quantity that expired due to STP | Appears only if the order expired due to STP. | "preventedQuantity": "1.200000" |
stopPrice | Price when the algorithmic order will be triggered | Appears for STOP_LOSS . TAKE_PROFIT , STOP_LOSS_LIMIT and TAKE_PROFIT_LIMIT orders. | "stopPrice": "23500.00000000" |
strategyId | Can be used to label an order that's part of an order strategy. | Appears if the parameter was populated in the request. | "strategyId": 37463720 |
strategyType | Can be used to label an order that is using an order strategy. | Appears if the parameter was populated in the request. | "strategyType": 1000000 |
trailingDelta | Delta price change required before order activation | Appears for Trailing Stop Orders. | "trailingDelta": 10 |
trailingTime | Time when the trailing order is now active and tracking price changes | Appears only for Trailing Stop Orders. | "trailingTime": -1 |
usedSor | Field that determines whether order used SOR | Appears when placing orders using SOR | "usedSor": true |
workingFloor | Field that determines whether the order is being filled by the SOR or by the order book the order was submitted to. | Appears when placing orders using SOR | "workingFloor": "SOR" |
Test new order (TRADE)
POST /api/v3/order/test
Test new order creation and signature/recvWindow long. Creates and validates a new order but does not send it into the matching engine.
Weight:
Condition | Request Weight |
---|---|
Without computeCommissionRates | 1 |
With computeCommissionRates | 20 |
Parameters:
In addition to all parameters accepted by POST /api/v3/order
,
the following optional parameters are also accepted:
Name | Type | Mandatory | Description |
---|---|---|---|
computeCommissionRates | BOOLEAN | NO | Default: false |
Data Source: Memory
Response:
Without computeCommissionRates
{}
With computeCommissionRates
{
"standardCommissionForOrder": { //Standard commission rates on trades from the order.
"maker": "0.00000112",
"taker": "0.00000114",
},
"taxCommissionForOrder": { //Tax commission rates for trades from the order.
"maker": "0.00000112",
"taker": "0.00000114",
},
"discount": { //Discount on standard commissions when paying in BNB.
"enabledForAccount": true,
"enabledForSymbol": true,
"discountAsset": "BNB",
"discount": "0.25000000" //Standard commission is reduced by this rate when paying commission in BNB.
}
}
Query order (USER_DATA)
GET /api/v3/order
Check an order's status.
Weight: 4
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
orderId | LONG | NO | |
origClientOrderId | STRING | NO | |
recvWindow | LONG | NO | The value cannot be greater than 60000 |
timestamp | LONG | YES |
Notes:
- Either
orderId
ororigClientOrderId
must be sent. - For some historical orders
cummulativeQuoteQty
will be < 0, meaning the data is not available at this time.
Data Source: Memory => Database
Response:
{
"symbol": "LTCBTC",
"orderId": 1,
"orderListId": -1 // This field will always have a value of -1 if not an order list.
"clientOrderId": "myOrder1",
"price": "0.1",
"origQty": "1.0",
"executedQty": "0.0",
"cummulativeQuoteQty": "0.0",
"status": "NEW",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "BUY",
"stopPrice": "0.0",
"icebergQty": "0.0",
"time": 1499827319559,
"updateTime": 1499827319559,
"isWorking": true,
"workingTime":1499827319559,
"origQuoteOrderQty": "0.000000",
"selfTradePreventionMode": "NONE"
}
Note: The payload above does not show all fields that can appear. Please refer to Conditional fields in Order Responses.
Cancel order (TRADE)
DELETE /api/v3/order
Cancel an active order.
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
orderId | LONG | NO | |
origClientOrderId | STRING | NO | |
newClientOrderId | STRING | NO | Used to uniquely identify this cancel. Automatically generated by default. |
cancelRestrictions | ENUM | NO | Supported values: ONLY_NEW - Cancel will succeed if the order status is NEW .ONLY_PARTIALLY_FILLED - Cancel will succeed if order status is PARTIALLY_FILLED . |
recvWindow | LONG | NO | The value cannot be greater than 60000 . |
timestamp | LONG | YES |
Either orderId
or origClientOrderId
must be sent.
If both parameters are sent, orderId
takes precedence.
Data Source: Matching Engine
Response:
{
"symbol": "LTCBTC",
"origClientOrderId": "myOrder1",
"orderId": 4,
"orderListId": -1, // Unless it's part of an order list, value will be -1
"clientOrderId": "cancelMyOrder1",
"transactTime": 1684804350068,
"price": "2.00000000",
"origQty": "1.00000000",
"executedQty": "0.00000000",
"origQuoteOrderQty": "0.000000",
"cummulativeQuoteQty": "0.00000000",
"status": "CANCELED",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "BUY",
"selfTradePreventionMode": "NONE"
}
Note: The payload above does not show all fields that can appear in the order response. Please refer to Conditional fields in Order Responses.
Regarding cancelRestrictions
- If the
cancelRestrictions
value is not any of the supported values, the error will be:
{
"code": -1145,
"msg": "Invalid cancelRestrictions"
}
- If the order did not pass the conditions for
cancelRestrictions
, the error will be:
{
"code": -2011,
"msg": "Order was not canceled due to cancel restrictions."
}
Cancel All Open Orders on a Symbol (TRADE)
DELETE /api/v3/openOrders
Cancels all active orders on a symbol. This includes orders that are part of an order list.
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
recvWindow | LONG | NO | The value cannot be greater than 60000 |
timestamp | LONG | YES |
Data Source: Matching Engine
Response:
[
{
"symbol": "BTCUSDT",
"origClientOrderId": "E6APeyTJvkMvLMYMqu1KQ4",
"orderId": 11,
"orderListId": -1,
"clientOrderId": "pXLV6Hz6mprAcVYpVMTGgx",
"transactTime": 1684804350068,
"price": "0.089853",
"origQty": "0.178622",
"executedQty": "0.000000",
"origQuoteOrderQty": "0.000000",
"cummulativeQuoteQty": "0.000000",
"status": "CANCELED",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "BUY",
"selfTradePreventionMode": "NONE"
},
{
"symbol": "BTCUSDT",
"origClientOrderId": "A3EF2HCwxgZPFMrfwbgrhv",
"orderId": 13,
"orderListId": -1,
"clientOrderId": "pXLV6Hz6mprAcVYpVMTGgx",
"transactTime": 1684804350069,
"price": "0.090430",
"origQty": "0.178622",
"executedQty": "0.000000",
"origQuoteOrderQty": "0.000000",
"cummulativeQuoteQty": "0.000000",
"status": "CANCELED",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "BUY",
"selfTradePreventionMode": "NONE"
},
{
"orderListId": 1929,
"contingencyType": "OCO",
"listStatusType": "ALL_DONE",
"listOrderStatus": "ALL_DONE",
"listClientOrderId": "2inzWQdDvZLHbbAmAozX2N",
"transactionTime": 1585230948299,
"symbol": "BTCUSDT",
"orders": [
{
"symbol": "BTCUSDT",
"orderId": 20,
"clientOrderId": "CwOOIPHSmYywx6jZX77TdL"
},
{
"symbol": "BTCUSDT",
"orderId": 21,
"clientOrderId": "461cPg51vQjV3zIMOXNz39"
}
],
"orderReports": [
{
"symbol": "BTCUSDT",
"origClientOrderId": "CwOOIPHSmYywx6jZX77TdL",
"orderId": 20,
"orderListId": 1929,
"clientOrderId": "pXLV6Hz6mprAcVYpVMTGgx",
"transactTime": 1688005070874,
"price": "0.668611",
"origQty": "0.690354",
"executedQty": "0.000000",
"origQuoteOrderQty": "0.000000",
"cummulativeQuoteQty": "0.000000",
"status": "CANCELED",
"timeInForce": "GTC",
"type": "STOP_LOSS_LIMIT",
"side": "BUY",
"stopPrice": "0.378131",
"icebergQty": "0.017083",
"selfTradePreventionMode": "NONE"
},
{
"symbol": "BTCUSDT",
"origClientOrderId": "461cPg51vQjV3zIMOXNz39",
"orderId": 21,
"orderListId": 1929,
"clientOrderId": "pXLV6Hz6mprAcVYpVMTGgx",
"transactTime": 1688005070874,
"price": "0.008791",
"origQty": "0.690354",
"executedQty": "0.000000",
"origQuoteOrderQty": "0.000000",
"cummulativeQuoteQty": "0.000000",
"status": "CANCELED",
"timeInForce": "GTC",
"type": "LIMIT_MAKER",
"side": "BUY",
"icebergQty": "0.639962",
"selfTradePreventionMode": "NONE"
}
]
}
]
Cancel an Existing Order and Send a New Order (TRADE)
POST /api/v3/order/cancelReplace
Cancels an existing order and places a new order on the same symbol.
Filters and Order Count are evaluated before the processing of the cancellation and order placement occurs.
A new order that was not attempted (i.e. when newOrderResult: NOT_ATTEMPTED
), will still increase the order count by 1.
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
symbol | STRING | YES | |
side | ENUM | YES | |
type | ENUM | YES | |
cancelReplaceMode | ENUM | YES | The allowed values are: STOP_ON_FAILURE - If the cancel request fails, the new order placement will not be attempted. ALLOW_FAILURE - new order placement will be attempted even if cancel request fails. |
timeInForce | ENUM | NO | |
quantity | DECIMAL | NO | |
quoteOrderQty | DECIMAL | NO | |
price | DECIMAL | NO | |
cancelNewClientOrderId | STRING | NO | Used to uniquely identify this cancel. Automatically generated by default. |
cancelOrigClientOrderId | STRING | NO | Either the cancelOrigClientOrderId or cancelOrderId must be provided. If both are provided, cancelOrderId takes precedence. |
cancelOrderId | LONG | NO | Either the cancelOrigClientOrderId or cancelOrderId must be provided. If both are provided, cancelOrderId takes precedence. |
newClientOrderId | STRING | NO | Used to identify the new order. |
strategyId | LONG | NO | |
strategyType | INT | NO | The value cannot be less than 1000000 . |
stopPrice | DECIMAL | NO | |
trailingDelta | LONG | NO | |
icebergQty | DECIMAL | NO | |
newOrderRespType | ENUM | NO | Allowed values: ACK , RESULT , FULL MARKET and LIMIT orders types default to FULL ; all other orders default to ACK |
selfTradePreventionMode | ENUM | NO | The allowed enums is dependent on what is configured on the symbol. The possible supported values are EXPIRE_TAKER , EXPIRE_MAKER , EXPIRE_BOTH , NONE . |
cancelRestrictions | ENUM | NO | Supported values: ONLY_NEW - Cancel will succeed if the order status is NEW .ONLY_PARTIALLY_FILLED - Cancel will succeed if order status is ONLY_PARTIALLY_FILLED . For more information please refer to Regarding cancelRestrictions |
orderRateLimitExceededMode | ENUM | No | Supported values: DO_NOTHING (default)- will only attempt to cancel the order if account has not exceeded the unfilled order rate limitCANCEL_ONLY - will always cancel the order |
recvWindow | LONG | NO | The value cannot be greater than 60000 |
timestamp | LONG | YES |
Similar to POST /api/v3/order
, additional mandatory parameters are determined by type
.
Response format varies depending on whether the processing of the message succeeded, partially succeeded, or failed.
Data Source: Matching Engine
Request | Response | ||||
---|---|---|---|---|---|
cancelReplaceMode |
orderRateLimitExceededMode |
Unfilled Order Count | cancelResult |
newOrderResult |
status |
STOP_ON_FAILURE |
DO_NOTHING |
Within Limits | ✅ SUCCESS |
✅ SUCCESS |
200 |
❌ FAILURE |
➖ NOT_ATTEMPTED |
400 |
|||
✅ SUCCESS |
❌ FAILURE |
409 |
|||
Exceeds Limits | ✅ SUCCESS |