Historical data fetching is missing data

historical_data_lookback = (no_of_candles // 360) + 1
today2 = datetime.now().strftime(“%Y-%m-%d”)
yesterday2 = (datetime.now() - timedelta(days=4 + historical_data_lookback)).strftime(“%Y-%m-%d”)
print(f"yesterday={yesterday2},today={today2}")

            url2 = f'https://api.upstox.com/v2/historical-candle/{symbol}/1minute/{today2}/{yesterday2}'
            headers2 = {'Accept': 'application/json'}
            response2 = requests.get(url2, headers=headers2)
            response2.raise_for_status()

i am using this to fetch historical data ,but i only got first day and last days data ,i am missing few days data in between ,can somw one help me to fetch 1 min ohlc data for last 7 days for a specific intstrument_token in python

Hi @Vibhuvan_Krishna, Could you please share the instrument key for which the historical data is missing? I’m able to retrieve the correct candle data for the last 7 days using the cURL request below.

curl --location 'https://api.upstox.com/v2/historical-candle/NSE_EQ%7CINE848E01016/1minute/2025-04-07/2025-04-01' \
--header 'Accept: application/json'

Please make sure to account for holidays and weekends in your data. Also, note that intraday data is not available through the Historical API.

Thanks

sure ,try fetching historical data for NSE_FO|43826 from 02-04-25 to 07-04-25 , im getting data for 2-4-25 and 7-4-25 but not inbetween

Hi @Vibhuvan_Krishna, please try using the following URL: https://api.upstox.com/v2/historical-candle/NSE_FO|43826/1minute/2025-04-07/2025-04-02. It should return the data you need for the period from 2nd to 7th April.

Thanks!

@Vibhuvan_Krishna It appears that no trades occurred on the 3rd and 4th of April for the given instrument thats why no data.

1 Like

oh ok ,thankyou sir,so what ever data is visible through upstox app will exactly be fetched through api right?

@Vibhuvan_Krishna Yes, the data is consistent across all platforms.