/marketfeed/ltp endpoint Times out

  • https://api.dhan.co/v2/marketfeed/ltp times out frequently if it’s getting polled every 2 seconds

@Sammy

1 Like
  • This is really not ideal for this API , sometimes it times out and sometimes it could take 60 seconds to get a response

  • Also I don’t see this API reflected in sandbox, is there any other HTTP API that needs to be used for fetching LTP for multiple instruments in realtime ?

Facing the similar issue :confused:

@Hardik @Dhan

Hello @fisek209281 @wekapi

Can you tell me if you are using Python to fetch the same? And also which library are you using to poll the API?

just pure nodeJs script


import axios from "axios";

async function getLTPofPositions(data, token, clientId) {
  const config = {
    method: "post",
    maxBodyLength: Infinity,
    url: "https://api.dhan.co/v2/marketfeed/ltp",
    headers: {
      Accept: "application/json",
      "Content-Type": "application/json",
      "access-token": token,
      "client-id": clientId,
    },
    data: data,
  };

  console.time("#### >>>> getLTPofPositions"); // Start the timer

  try {
    const response = await axios.request(config);
    console.timeEnd("#### >>>> getLTPofPositions"); // End the timer and log the duration
    return response.data;
  } catch (error) {
    console.timeEnd("#### >>>> getLTPofPositions"); // End the timer even in case of error
    console.error(error);
    throw error;
  }
}

export default { getLTPofPositions };