API_Historical_Data_fetching_Issue

from datetime import datetime
import pandas as pd
symbols = [
    'NSE:HDFCBANK-EQ', 'NSE:ANGELONE-EQ', 'NSE:ICICIBANK-EQ',
    'NSE:BSE-EQ', 'NSE:RELIANCE-EQ', 'NSE:ADANIPOWER-EQ'
]

start_date = "2026-04-17 09:15:00"
end_date   = "2026-04-17 15:30:00"

range_from = int(datetime.strptime(start_date, "%Y-%m-%d %H:%M:%S").timestamp())
range_to   = int(datetime.strptime(end_date, "%Y-%m-%d %H:%M:%S").timestamp())
all_rally_results = []

def main():

    dfs = {}

    for symbol in symbols:
        data = {
            "symbol": symbol,
            "resolution": "30",
            "date_format": "0",
            "range_from": str(range_from),
            "range_to": str(range_to),
            "cont_flag": "1"
        }

        response = fyers.history(data=data)

        if 'candles' not in response:
            print(f"Error for {symbol}: {response}")
            continue

        df = pd.DataFrame(response['candles'], columns=[
            'timestamp', 'open', 'high', 'low', 'close', 'volume'
        ])
        df['timestamp'] = pd.to_datetime(df['timestamp'], unit='s')

        dfs[symbol] = df

    # Example usage
    print(dfs['NSE:RELIANCE-EQ'].to_string())

if __name__ == "__main__":
    main()

            timestamp    open    high   low   close   volume
0 2026-04-17 09:15:00  1363.1  1366.8  1362  1365.5  1988287
1 2026-04-17 09:45:00  1365.5  1365.7  1363  1364.5   979926

I’m getting only two candles when I request data from 09:15 to 12:15.

What should I change to get all candles in this time range?

Hey @115759009830548714265,

Please provide the start and end dates in epoch format including time.

Hey @115759009830548714265, Since there’s been no update from your side, hoping your concern is resolved. Please reply if you still need help.