Yamanrb12
(Yaman Bisen)
July 17, 2023, 10:23am
1
Hello Alice Blue Support,
I would like to know if historical data for Nifty 50 and Bank Nifty is available through your REST APIs. Specifically, I am interested in accessing historical price data including open, high, low, and closing prices.
Could you please confirm if Alice Blue provides historical data for Nifty 50 and Bank Nifty via REST APIs? If so, I would appreciate any documentation or guidelines explaining how to access this data programmatically.
Thank you for your assistance.
Sincerely,
Yaman Bisen
kindly follow the below link historical data API.
https://v2api.aliceblueonline.com/historical
Yamanrb12
(Yaman Bisen)
July 18, 2023, 7:14am
3
Thank you for your reply.
I am using python to acheive this.
url : ‘/chart/history’
data = {
“token”: 26000, # NIFTY 50
“resolution”: “1”,
“from”: 1688960700000, # 10/07/2023 9:15
“to”: 1689222600000, # 10/07/2023 10:00
“exchange”: “NSE”
}
Response : {‘emsg’: ‘No data available’, ‘stat’: ‘Not_Ok’}
can you please tell me what’s wrong happening.
from pya3 import *
from datetime import datetime
import datetime
alice = Aliceblue(user_id=‘’,api_key=‘’)
alice.get_session_id()
instrument = alice.get_instrument_by_token(‘INDICES’,26000)
print(instrument)
from_datetime = datetime.datetime(2023, 6, 2, 9,45,00) # From last & days
to_datetime = datetime.datetime(2023, 6, 5, 10,40,00) # To now
interval = “D” # [“1”, “D”]
indices = True # For Getting index data
print(alice.get_historical(instrument, from_datetime, to_datetime, interval, indices))
print(type(interval))
print(type(to_datetime))
Kindly try this sample code.
Yamanrb12
(Yaman Bisen)
July 21, 2023, 6:50am
5
Thank you very much, I got the data now.
kzatakia
(Kiran Zatakia)
September 1, 2023, 4:28pm
6
Thanks, Alavala7997 for sharing.
I found that whenever fetching data by using ‘1’ it gives a full day one min data, any Idea what’s wrong with it?
kzatakia
(Kiran Zatakia)
September 2, 2023, 1:11pm
7
Thanks for updating the prompt, 1 of min data started to be seen but only the current expiry.
I am testing with historical dates, unable to find the instrument of any previous expiry.
should I have to download the old contract file? how?