Batch New Orders
Description
Batch create and submit new orders. Maximum 5 orders per request.
Per-order failures do not abort the batch — each element in the response array is either a successful order object or an error {code, msg}, in the same position as its request.
HTTP Request
POST /fapi/v1/batchOrders (HMAC SHA256)
Weight
5
Request Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| batchOrders | JSON LIST | YES | Order list, containing up to 5 order objects |
| timestamp | LONG | YES | Timestamp |
Each order object contains the following parameters:
| Name | Type | Required | Description |
|---|---|---|---|
| symbol | STRING | YES | Trading pair |
| side | ENUM | YES | Order side: BUY, SELL |
| type | ENUM | YES | Order type |
| quantity | DECIMAL | YES | Order quantity |
| price | DECIMAL | NO | Order price |
| stopPrice | DECIMAL | NO | Stop price |
| timeInForce | ENUM | NO | Time in force |
| reduceOnly | STRING | NO | true or false |
| positionSide | ENUM | NO | Position side |
| workingType | ENUM | NO | Working type |
Response Example
[
{
"clientOrderId": "testOrderBatch1",
"cumQty": "0",
"cumQuote": "0",
"executedQty": "0",
"orderId": 2254222045,
"avgPrice": "0.00000",
"origQty": "10",
"price": "0",
"reduceOnly": false,
"side": "SELL",
"positionSide": "BOTH",
"status": "NEW",
"stopPrice": "0",
"closePosition": false,
"symbol": "BTCUSDT",
"timeInForce": "GTC",
"type": "TRAILING_STOP_MARKET",
"origType": "TRAILING_STOP_MARKET",
"activatePrice": "9020",
"priceRate": "0.3",
"updateTime": 1566818724722,
"workingType": "CONTRACT_PRICE",
"priceProtect": false
},
{
"code": -2010,
"msg": "Account has insufficient balance for requested action."
}
]
The response is a list where each element corresponds to an order in the request. If an order fails to create, the corresponding element will contain an error code and error message.
Code Examples
cURL
API_KEY="your_api_key"
API_SECRET="your_api_secret"
TIMESTAMP=$(date +%s%3N)
BATCH='[{"symbol":"BTCUSDT","side":"BUY","type":"LIMIT","timeInForce":"GTC","quantity":"0.01","price":"60000"},{"symbol":"BTCUSDT","side":"SELL","type":"LIMIT","timeInForce":"GTC","quantity":"0.01","price":"80000"}]'
QUERY_STRING="batchOrders=${BATCH}×tamp=${TIMESTAMP}"
SIGNATURE=$(echo -n "${QUERY_STRING}" | openssl dgst -sha256 -hmac "${API_SECRET}" | awk '{print $2}')
curl -s -X POST \
-H "X-MBX-APIKEY: ${API_KEY}" \
"https://api.primit.xyz/fapi/v1/batchOrders?${QUERY_STRING}&signature=${SIGNATURE}"
Python
import time, hmac, hashlib, requests, json
from urllib.parse import quote
API_KEY = "your_api_key"
API_SECRET = "your_api_secret"
BASE_URL = "https://api.primit.io"
def sign(msg: str) -> str:
return hmac.new(API_SECRET.encode(), msg.encode(), hashlib.sha256).hexdigest()
# Place two LIMIT orders in a batch
batch_orders = [
{"symbol": "BTCUSDT", "side": "BUY", "type": "LIMIT", "timeInForce": "GTC", "quantity": "0.01", "price": "60000"},
{"symbol": "BTCUSDT", "side": "SELL", "type": "LIMIT", "timeInForce": "GTC", "quantity": "0.01", "price": "80000"},
]
ts = int(time.time() * 1000)
batch_str = json.dumps(batch_orders, separators=(',', ':'))
encoded = quote(batch_str)
qs = f"batchOrders={encoded}×tamp={ts}"
sig = sign(qs)
resp = requests.post(
f"{BASE_URL}/fapi/v1/batchOrders?{qs}&signature={sig}",
headers={"X-MBX-APIKEY": API_KEY},
)
print(resp.json())