How to get MARKET order’s executed price in FUTURES?

Question:
What are the methods to get the executed price after placing a MARKET order by using /fapi/v1/order endpoint ?

The executed price can be consulted in different scenarios:

A - After New Order via REST API (POST /fapi/v1/order)
This request will create a response with orderId / clientOrderId in it, copy that value and use it for the Query Order endpoint (GET /fapi/v1/order), which will return the following example:

{
    "orderId": 2816201874,
    "symbol": "BTCUSDT",
    "status": "FILLED",
    "clientOrderId": "nJbJ2Y508uq6obmrcohprS",
    "price": "0",
    "avgPrice": "46874.40000",  // Average executed price
    "origQty": "0.010",
    "executedQty": "0.010",
    "cumQuote": "468.74400",
    "timeInForce": "GTC",
    "type": "MARKET",
    "reduceOnly": false,
    "closePosition": false,
    "side": "BUY",
    "positionSide": "LONG",
    "stopPrice": "0",
    "workingType": "CONTRACT_PRICE",
    "priceProtect": false,
    "origType": "MARKET",
    "time": 1631358143129,
    "updateTime": 1631358143129
}

—> One MARKET price can have several trades and the average executed price can be checked in the avgPrice field.

B - After New Order via Websocket (User Data Stream)
You can receive several ORDER_TRADE_UPDATE events, look for the one with `“X”: “FILLED”. Example:

{
    "e": "ORDER_TRADE_UPDATE",
    "T": 1590969041003,
    "E": 1590969041006,
    "o": {
        "s": "BTCUSDT",
        "c": "Lp12Nq0OoBYTF7zyqZGl3n",
        "S": "BUY",
        "o": "MARKET",
        "f": "GTC",
        "q": "1",
        "p": "0",
        "ap": "9452.71000",  // Average executed price
        "sp": "0",
        "x": "TRADE",
        "X": "FILLED",
        "i": 2413175154,
        "l": "1",
        "z": "1",
        "L": "9452.71", // Last filled price
        "n": "3.78108399",
        "N": "USDT",
        "T": 1590969041003,
        "t": 133350643,
        "b": "0",
        "a": "0",
        "m": false,
        "R": false,
        "wt": "CONTRACT_PRICE",
        "ot": "MARKET",
        "ps": "BOTH",
        "cp": false
    }
}

—> ap is the field you’re looking for.