Below is the code and the output also note that I even copy pasted the example code for intraday API and it also does not work . Historical data is working correctly .
Maybe the reason is API rate limits ? But the historical data is working fine ?
/usr/bin/python "/run/media/yokai/Storage/Projects/Amish Python Bot/Testing/Backend/brokers_api/intraday_data.py"
yokai@fedora:/run/media/yokai/Storage/Projects/Amish Python Bot/Testing/Backend$ /usr/bin/python "/run/media/yokai/Storage/Projects/Amish Python Bot/Testing/Backend/brokers_api/intraday_data.py"
{'status': 'success', 'data': {'candles': []}}
yokai@fedora:/run/media/yokai/Storage/Projects/Amish Python Bot/Testing/Backend$
# File: brokers_api/upstox/candle_data/intraday_data_api.py
import requests
import time
def fetch_intraday_data(instrument):
"""Fetch intraday candle data from Upstox API."""
url = f"https://api.upstox.com/v2/historical-candle/intraday/{instrument}/1minute"
headers = {'Accept': 'application/json'}
try:
response = requests.get(url, headers=headers)
data = response.json()
if data.get("status") == "success":
print(data)
return data.get("data", {}).get("candles", [])
else:
print(f"API error for {instrument}: {data.get('message', 'Unknown error')}")
return []
except requests.RequestException as e:
print(f"Failed to fetch intraday data for {instrument}: {e}")
return []
# Example usage (for testing)
if __name__ == "__main__":
instrument = "NSE_INDEX|Nifty Bank"
candles = fetch_intraday_data(instrument)
print(candles)