Get Open Orders
Query unfilled or partially filled orders in real-time. To query older order records, please use the order history interface.
Unified account covers: Spot / USDT perpetual / USDC contract / Inverse contract / Options
Classic account covers: Spot / USDT perpetual / Inverse contract
tip
- This endpoint also allows for querying filled, canceled, and rejected orders to the most recent 500 orders for spot, linear, and option categories. The inverse category is not subject to this limitation.
- You can query by symbol, baseCoin, orderId and orderLinkId, and if you pass multiple params, the system will process them according to this priority: orderId > orderLinkId > symbol > baseCoin.
- The records are sorted by the
createdTime
from newest to oldest.
info
- Classic account spot can return open orders only
- After a server release or restart, filled, canceled, and rejected orders of Unified account should only be queried through order history.
HTTP Request
GET /v5/order/realtime
Request Parameters
Parameter | Required | Type | Comments |
---|---|---|---|
category | true | string | Product type
|
symbol | false | string | Symbol name. For linear, either symbol , baseCoin , settleCoin is required |
baseCoin | false | string | Base coin linear , inverse & option option : it returns all option open orders by default |
settleCoin | false | string | Settle coin
|
orderId | false | string | Order ID |
orderLinkId | false | string | User customised order ID |
openOnly | false | integer |
|
orderFilter | false | string | Order : active order, StopOrder : conditional order for Futures and Spot, tpslOrder : spot TP/SL order, OcoOrder : Spot oco order, BidirectionalTpslOrder : Spot bidirectional TPSL order
|
limit | false | integer | Limit for data size per page. [1 , 50 ]. Default: 20 |
cursor | false | string | Cursor. Use the nextPageCursor token from the response to retrieve the next page of the result set |
Response Parameters
Parameter | Type | Comments |
---|---|---|
category | string | Product type |
nextPageCursor | string | Refer to the cursor request parameter |
list | array | Object |
> orderId | string | Order ID |
> orderLinkId | string | User customised order ID |
> blockTradeId | string | Paradigm block trade ID |
> symbol | string | Symbol name |
> price | string | Order price |
> qty | string | Order qty |
> side | string | Side. Buy ,Sell |
> isLeverage | string | Whether to borrow. Unified spot only. 0 : false, 1 : true. Classic spot is not supported, always 0 |
> positionIdx | integer | Position index. Used to identify positions in different position modes. |
> orderStatus | string | Order status |
> createType | string | Order create type |
> cancelType | string | Cancel type |
> rejectReason | string | Reject reason. Classic spot is not supported |
> avgPrice | string | Average filled price "" for those orders without avg price"0" for those orders without avg price, and also for those orders have partilly filled but cancelled at the end |
> leavesQty | string | The remaining qty not executed. Classic spot is not supported |
> leavesValue | string | The estimated value not executed. Classic spot is not supported |
> cumExecQty | string | Cumulative executed order qty |
> cumExecValue | string | Cumulative executed order value. Classic spot is not supported |
> cumExecFee | string | Cumulative executed trading fee. Classic spot is not supported |
> timeInForce | string | Time in force |
> orderType | string | Order type. Market ,Limit . For TP/SL order, it means the order type after triggered |
> stopOrderType | string | Stop order type |
> orderIv | string | Implied volatility |
> marketUnit | string | The unit for qty when create Spot market orders for UTA account. baseCoin , quoteCoin |
> triggerPrice | string | Trigger price. If stopOrderType =TrailingStop, it is activate price. Otherwise, it is trigger price |
> takeProfit | string | Take profit price |
> stopLoss | string | Stop loss price |
> tpslMode | string | TP/SL mode, Full : entire position for TP/SL. Partial : partial position tp/sl. Spot does not have this field, and Option returns always "" |
> ocoTriggerBy | string | The trigger type of Spot OCO order.OcoTriggerByUnknown , OcoTriggerByTp , OcoTriggerByBySl . Classic spot is not supported |
> tpLimitPrice | string | The limit order price when take profit price is triggered |
> slLimitPrice | string | The limit order price when stop loss price is triggered |
> tpTriggerBy | string | The price type to trigger take profit |
> slTriggerBy | string | The price type to trigger stop loss |
> triggerDirection | integer | Trigger direction. 1 : rise, 2 : fall |
> triggerBy | string | The price type of trigger price |
> lastPriceOnCreated | string | Last price when place the order |
> reduceOnly | boolean | Reduce only. true means reduce position size |
> closeOnTrigger | boolean | Close on trigger. What is a close on trigger order? |
> placeType | string | Place type, option used. iv , price |
> smpType | string | SMP execution type |
> smpGroup | integer | Smp group ID. If the UID has no group, it is 0 by default |
> smpOrderId | string | The counterparty's orderID which triggers this SMP execution |
> createdTime | string | Order created timestamp (ms) |
> updatedTime | string | Order updated timestamp (ms) |
Request Example
- HTTP
- Python
- Java
- Node.js
GET /v5/order/realtime?symbol=ETHUSDT&category=linear&openOnly=0&limit=1 HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: XXXXX
X-BAPI-TIMESTAMP: 1672219525810
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="XXXXX",
api_secret="XXXXX",
)
print(session.get_open_orders(
category="linear",
symbol="ETHUSDT",
openOnly=0,
limit=1,
))
import com.bybit.api.client.config.BybitApiConfig;
import com.bybit.api.client.domain.trade.request.TradeOrderRequest;
import com.bybit.api.client.domain.*;
import com.bybit.api.client.domain.trade.*;
import com.bybit.api.client.service.BybitApiClientFactory;
var client = BybitApiClientFactory.newInstance("YOUR_API_KEY", "YOUR_API_SECRET", BybitApiConfig.TESTNET_DOMAIN).newTradeRestClient();
var openLinearOrdersResult = client.getOpenOrders(openOrderRequest.category(CategoryType.LINEAR).openOnly(1).build());
System.out.println(openLinearOrdersResult);
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.getActiveOrders({
category: 'linear',
symbol: 'ETHUSDT',
openOnly: 0,
limit: 1,
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
Response Example
{
"retCode": 0,
"retMsg": "OK",
"result": {
"list": [
{
"orderId": "fd4300ae-7847-404e-b947-b46980a4d140",
"orderLinkId": "test-000005",
"blockTradeId": "",
"symbol": "ETHUSDT",
"price": "1600.00",
"qty": "0.10",
"side": "Buy",
"isLeverage": "",
"positionIdx": 1,
"orderStatus": "New",
"cancelType": "UNKNOWN",
"rejectReason": "EC_NoError",
"avgPrice": "0",
"leavesQty": "0.10",
"leavesValue": "160",
"cumExecQty": "0.00",
"cumExecValue": "0",
"cumExecFee": "0",
"timeInForce": "GTC",
"orderType": "Limit",
"stopOrderType": "UNKNOWN",
"orderIv": "",
"triggerPrice": "0.00",
"takeProfit": "2500.00",
"stopLoss": "1500.00",
"tpTriggerBy": "LastPrice",
"slTriggerBy": "LastPrice",
"triggerDirection": 0,
"triggerBy": "UNKNOWN",
"lastPriceOnCreated": "",
"reduceOnly": false,
"closeOnTrigger": false,
"smpType": "None",
"smpGroup": 0,
"smpOrderId": "",
"tpslMode": "Full",
"tpLimitPrice": "",
"slLimitPrice": "",
"placeType": "",
"createdTime": "1684738540559",
"updatedTime": "1684738540561"
}
],
"nextPageCursor": "page_args%3Dfd4300ae-7847-404e-b947-b46980a4d140%26symbol%3D6%26",
"category": "linear"
},
"retExtInfo": {},
"time": 1684765770483
}