0

I have recently started looking at python-binance. I have read through the entire API and spent a frustratingly long time on Google, trying to find out how to get an orderId.

The API frequently states that you need the orderId for certain functions, but never how to actually get the orderId of an order.

Can anyone help me please?

William Baker Morrison
  • 1,642
  • 4
  • 21
  • 33
Hoodiedoodie
  • 1
  • 1
  • 1
  • Correct me if I'm wrong but don't you get an orderID returned when you create an order through the API? You're supposed to save that in order to track the order and pass it around different functions. However, this is from my experience working with the Bittrex API not Binance so it might be different. – Ilhan Jan 30 '21 at 12:12

1 Answers1

0

You need to create an order first and you will get the orderId in the response:

{
    "symbol": "BTCUSDT",
    "orderId": 28,
    "clientOrderId": "6gCrw2kRUAF9CvJDGP16IP",
    "transactTime": 1507725176595,
    "price": "0.00000000",
    "origQty": "10.00000000",
    "executedQty": "10.00000000",
    "status": "FILLED",
    "timeInForce": "GTC",
    "type": "MARKET",
    "side": "SELL"
}

See here https://python-binance.readthedocs.io/en/latest/binance.html?highlight=create_order#binance.client.Client.create_order

  • Do you know which id should be referenced when using the client.get_order() method? Should it be the "orderId"? Or the "clientOrderId"? – DavidSilverberg Aug 14 '22 at 21:42
  • both options are possible, either you enter orderId or clientOrderId. https://binance-docs.github.io/apidocs/spot/en/#query-order-user_data – Ali Zakaria Aug 15 '22 at 23:14