Skip to main content

Get Order History

Query order history. As order creation/cancellation is asynchronous, the data returned from this endpoint may delay. If you want to get real-time order information, you could query this endpoint or rely on the websocket stream (recommended).

rule
  • The orders in the last 7 days:
    UTA2.0, UTA1.0(except inverse) support querying all closed status except "Cancelled", "Rejected", "Deactivated" status.
    UTA1.0(inverse) and classic account support querying all status (open and close status)
  • The orders in the last 24 hours:
    UTA2.0, UTA1.0(except inverse) for the orders with "Cancelled" (fully cancelled order), "Rejected", "Deactivated" can be query
  • The orders beyond 7 days:
    All account supports querying orders which have fills only, i.e., fully filled, partial filled but cancelled orders
  • UTA2.0, UTA1.0(except inverse) support querying the past 2 years data.
info
  • Classic Spot can get closed order status only, and Cancelled, Rejected, Deactivated orders save up to 7 days

HTTP Request

GET /v5/order/history

Request Parameters

ParameterRequiredTypeComments
categorytruestringProduct type
  • UTA2.0, UTA1.0: linear, inverse, spot, option
  • classic account: linear, inverse, spot
symbolfalsestringSymbol name, like BTCUSDT, uppercase only
baseCoinfalsestringBase coin, uppercase only
  • UTA1.0(inverse), classic account do not support this param
  • settleCoinfalsestringSettle coin, uppercase only
  • UTA1.0(inverse), classic account do not support this param
  • orderIdfalsestringOrder ID
    orderLinkIdfalsestringUser customised order ID
    orderFilterfalsestringOrder: active order
    StopOrder: conditional order for Futures and Spot
    tpslOrder: spot TP/SL order
    OcoOrder: spot OCO orders
    BidirectionalTpslOrder: Spot bidirectional TPSL order
    • classic account spot: return Order active order by default
    • Others: all kinds of orders by default
    orderStatusfalsestring
    • Classic spot: not supported
    • UTA2.0, UTA1.0(except inverse): return all closed status orders if not passed
    • UTA1.0(inverse), classic account(linear, inverse): return all status orders if not passed
    startTimefalseintegerThe start timestamp (ms)
    • startTime and endTime are not passed, return 7 days by default
    • Only startTime is passed, return range between startTime and startTime+7 days
    • Only endTime is passed, return range between endTime-7 days and endTime
    • If both are passed, the rule is endTime - startTime <= 7 days
    endTimefalseintegerThe end timestamp (ms)
    limitfalseintegerLimit for data size per page. [1, 50]. Default: 20
    cursorfalsestringCursor. Use the nextPageCursor token from the response to retrieve the next page of the result set

    Response Parameters

    ParameterTypeComments
    categorystringProduct type
    listarrayObject
    > orderIdstringOrder ID
    > orderLinkIdstringUser customised order ID
    > blockTradeIdstringBlock trade ID
    > symbolstringSymbol name
    > pricestringOrder price
    > qtystringOrder qty
    > sidestringSide. Buy,Sell
    > isLeveragestringWhether to borrow. Unified spot only. 0: false, 1: true. . Classic spot is not supported, always 0
    > positionIdxintegerPosition index. Used to identify positions in different position modes
    > orderStatusstringOrder status
    > createTypestringOrder create type
  • Only for category=linear or inverse
  • Spot, Option do not have this key
  • > cancelTypestringCancel type
    > rejectReasonstringReject reason. Classic spot is not supported
    > avgPricestringAverage filled price
  • UTA: returns "" for those orders without avg price
  • classic account: returns "0" for those orders without avg price, and also for those orders have partilly filled but cancelled at the end
  • > leavesQtystringThe remaining qty not executed. Classic spot is not supported
    > leavesValuestringThe estimated value not executed. Classic spot is not supported
    > cumExecQtystringCumulative executed order qty
    > cumExecValuestringCumulative executed order value. Classic spot is not supported
    > cumExecFeestringCumulative executed trading fee. Classic spot is not supported
    > timeInForcestringTime in force
    > orderTypestringOrder type. Market,Limit. For TP/SL order, it means the order type after triggered
  • Block trade Roll Back, Block trade-Limit: Unique enum values for Unified account block trades
  • > stopOrderTypestringStop order type
    > orderIvstringImplied volatility
    > marketUnitstringThe unit for qty when create Spot market orders for UTA account. baseCoin, quoteCoin
    > slippageToleranceTypestringSpot and Futures market order slippage tolerance type TickSize, Percent, UNKNOWN(default)
    > slippageTolerancestringSlippage tolerance value
    > triggerPricestringTrigger price. If stopOrderType=TrailingStop, it is activate price. Otherwise, it is trigger price
    > takeProfitstringTake profit price
    > stopLossstringStop loss price
    > tpslModestringTP/SL mode, Full: entire position for TP/SL. Partial: partial position tp/sl. Spot does not have this field, and Option returns always ""
    > ocoTriggerBystringThe trigger type of Spot OCO order.OcoTriggerByUnknown, OcoTriggerByTp, OcoTriggerBySl. Classic spot is not supported
    > tpLimitPricestringThe limit order price when take profit price is triggered
    > slLimitPricestringThe limit order price when stop loss price is triggered
    > tpTriggerBystringThe price type to trigger take profit
    > slTriggerBystringThe price type to trigger stop loss
    > triggerDirectionintegerTrigger direction. 1: rise, 2: fall
    > triggerBystringThe price type of trigger price
    > lastPriceOnCreatedstringLast price when place the order, Spot is not applicable
    > basePricestringLast price when place the order, Spot has this field only
    > reduceOnlybooleanReduce only. true means reduce position size
    > closeOnTriggerbooleanClose on trigger. What is a close on trigger order?
    > placeTypestringPlace type, option used. iv, price
    > smpTypestringSMP execution type
    > smpGroupintegerSmp group ID. If the UID has no group, it is 0 by default
    > smpOrderIdstringThe counterparty's orderID which triggers this SMP execution
    > createdTimestringOrder created timestamp (ms)
    > updatedTimestringOrder updated timestamp (ms)
    > extraFeesstringTrading fee rate information. Currently, this data is returned only for spot orders placed on the Indonesian site or spot fiat currency orders placed on the EU site. In other cases, an empty string is returned. Enum: feeType, subFeeType
    nextPageCursorstringRefer to the cursor request parameter

    Request Example

    GET /v5/order/history?category=linear&limit=1 HTTP/1.1
    Host: api-testnet.bybit.com
    X-BAPI-SIGN: XXXXX
    X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx
    X-BAPI-TIMESTAMP: 1672221263407
    X-BAPI-RECV-WINDOW: 5000

    Response Example

    {
    "retCode": 0,
    "retMsg": "OK",
    "result": {
    "list": [
    {
    "orderId": "14bad3a1-6454-43d8-bcf2-5345896cf74d",
    "orderLinkId": "YLxaWKMiHU",
    "blockTradeId": "",
    "symbol": "BTCUSDT",
    "price": "26864.40",
    "qty": "0.003",
    "side": "Buy",
    "isLeverage": "",
    "positionIdx": 1,
    "orderStatus": "Cancelled",
    "cancelType": "UNKNOWN",
    "rejectReason": "EC_PostOnlyWillTakeLiquidity",
    "avgPrice": "0",
    "leavesQty": "0.000",
    "leavesValue": "0",
    "cumExecQty": "0.000",
    "cumExecValue": "0",
    "cumExecFee": "0",
    "timeInForce": "PostOnly",
    "orderType": "Limit",
    "stopOrderType": "UNKNOWN",
    "orderIv": "",
    "triggerPrice": "0.00",
    "takeProfit": "0.00",
    "stopLoss": "0.00",
    "tpTriggerBy": "UNKNOWN",
    "slTriggerBy": "UNKNOWN",
    "triggerDirection": 0,
    "triggerBy": "UNKNOWN",
    "lastPriceOnCreated": "0.00",
    "reduceOnly": false,
    "closeOnTrigger": false,
    "smpType": "None",
    "smpGroup": 0,
    "smpOrderId": "",
    "tpslMode": "",
    "tpLimitPrice": "",
    "slLimitPrice": "",
    "placeType": "",
    "slippageToleranceType": "UNKNOWN",
    "slippageTolerance": "",
    "createdTime": "1684476068369",
    "updatedTime": "1684476068372",
    "extraFees": ""
    }
    ],
    "nextPageCursor": "page_token%3D39380%26",
    "category": "linear"
    },
    "retExtInfo": {},
    "time": 1684766282976
    }