How can I retrieve order status?

DM2290
I'm placing an order through my NodeJS code which returns the following even though the actual order gets rejected as seen in Kite interface -

{"status":"success","data":{"order_id":"230821301171641"}} I

so I'm trying to retrieve the order id's details by calling 'https://api.kite.trade/orders/230821301235027/trades' but the request call automatically adds '?status-COMPLETED' ('https://api.kite.trade/orders/230821301235027/trades?status=COMPLETE',)

and the response is

data: { status: 'success', data: [] }

How can I get the order's status whether it is rejected or accepted? Please help.
Tagged:
  • rakeshr
    which returns the following even though the actual order gets rejected as seen in Kite interface
    This thread explains more. You need to read status_message field from the order history, to know the rejection reason.
    request call automatically adds '?status-COMPLETED' ('https://api.kite.trade/orders/230821301235027/trades?status=COMPLETE',)
    I just tried, getOrderTrades, and it's working fine, with no status url encoded param addition. Can you paste here the exact code for this?
  • DM2290
    DM2290 edited August 2023
    @rakeshr: Please see my code below and advice!

    async function retrieveParticularExecutedOrder(order_id){

    console.log(order_id); //checking to ensure correct order_id is passed

    try {
    const response = await axios.get('https://api.kite.trade/orders/' + order_id + '/trades', {
    headers: {
    'X-Kite-Version': '3',
    'Authorization': `token :` + accessToken,
    },
    });

    console.log(response.data); // returns { status: 'success', data: [] } //why is data empty here? how can I get the status REJECTED here???

    } catch (error) {
    console.error('Catch Error:', error.response.data.message); //returns Insufficient stock holding or there are pending sell orders for this stock. Check the orderbook....
    }
    }
  • rakeshr
    You can use the Nodejs client.
  • DM2290
    @rakeshr : could you please give me an example to use the function. I tried the following but getting undefined -

    async function retrieveParticularExecutedOrder(order_id){

    console.log(order_id); //checking to ensure correct order_id is passed

    var kc = new KiteConnect({api_key: apiKey});

    kc.getOrderTrades(order_id);

    console.log(kc.response);

    }
  • sujith
    There are only two APIs supported by Kite Connect, one is fetching the whole orderbook or fetch order history.
    I would suggest fetch the orderbook and check the status of the particular order using order id.
Sign In or Register to comment.