import requests
import json
import config as l
ip = input(“Enter the stock instrument key :”)
url = f"https://api-v2.upstox.com/historical-candle/NSE_EQ|{ip}/1minute/2023-08-18"
headers = {
‘accept’: ‘application/json’,
‘Api-Version’: ‘2.0’
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
data = response.json()
# Save JSON response to a file
f2 = input(“What to name the .json file :”)
with open(f2, ‘w’) as json_file:
json.dump(data, json_file, indent=4)
print(f’JSON response saved to {f2}')
else:
print(f"Request failed with status code: {response.status_code}")
The above code os to fetch the candlestick data for 1min timeframe
I’m trying to run this on the evening of 2023-08-18 but the output doesn’t contain any data for 18th its giving the data from 17th
Is this some issue with the Upstox API or am I going wrong with the code ?