Intraday history API giving next candle data after 6-10 seconds

https://api-v2.upstox.com/historical-candle/intraday

what is the timedelta for getting next candle data through this API ?

We suggest utilizing real-time WebSocket to access the most recent two candles in the intraday timeframe. Specifically, for 1-minute- and 30-minute intervals, we provide two candles, including the current and previous ones.

Regarding the delay in the cache response, we have implemented caching for the intraday REST API to improve performance. We are examining the possibility of optimizing the current Time To Live (TTL) for the cache.

Can you give me refrence how to get 1 minute candle through webscoket

Older version API was returning historical data with in 2 seconds

You can locate the reference code for the full mode, which analyzes the current LTP (Last Traded Price) with the previous two candles for both 1-minute and 30-minute timeframes, in the following GitHub repository:

GitHub Repository: upstox/upstox-python

For further information and documentation, please refer to the following link:

Documentation: Upstox API Documentation - WebSocket Implementation / Market Data Stream

Websocket also not seems reliable it’s throwing error

Error during DataFrame creation: received 1001 (going away) CloudFlare WebSocket proxy restarting; then sent 1001 (going away) CloudFlare WebSocket proxy restarting