Download
iLearn application
Elevate Your Financial Knowledge with the
ICICI Direct iLearn App
To start exploring the multiple features of Breeze API, one would need to enter certain parameters for a successful output. For example, in trying to download minute by minute historical data for Ashok Leyland’s stock price on NSE exchange for the 1st week of May, the code should like something like below:
|
# importing required libraries from breeze_connect import BreezeConnect import pandas as pd
# generating session through isec = BreezeConnect(api_key="K%834G9%)2M9z75111V2dP") isec.generate_session(api_secret="a69+y9097T9r279342xC513O82#ucU1a0",session_token="1117193")
# get historical data for Ashok Leyland data = isec.get_historical_data(interval="1minute", from_date= "2022-05-03T07:00:00.000Z", to_date= "2022-05-06T18:00:00.000Z", stock_code="ASHLEY", exchange_code="NSE", product_type="cash")
|
Please note that the api_key and api_secret are shown for demo purpose only. Users would need to enter their own api key and secret key, as can be seen in the view app section of Breeze Hompage. Refer to our articles on “How to register an App” and “How to generate the session key” to know about the starting process. The links for those are mentioned below:
What inputs are allowed to go in parameters?
The key thing to note in the above code is that the parameters (like interval, to_date, from_date, stock_code, exchange_code and product_type) can take input in a specific format only. For instance, parameter ‘interval’ will accept “1minute” but not if you enter “1min” or “01m”. Even if you miss a double quote “at the end or start of the parameter, the code would throw an error. This is standard protocol of any programming language (python in this case) and we have to abide by this.
Now the next thing that one would like to know is how to get all the list of available inputs that go in these parameters. For example, at the time of writing this article the parameter “interval” can accept the following inputs:
“1minute” , “5minute” , “30minute” , “1day”
While we are building new capabilities for the Breeze API on a regular basis, make sure you check out our community for regular updates.
Link to Breeze Community:
https://community.icicidirect.com/api
Where to get the list of stock codes?
To get the parameter “stock_code” you will have to go to à
https://api.icicidirect.com/breezeapi/documents/index.html?python#instruments
You can download the Security Master file from the above link. It is generated/updated daily at 8:00 AM.

Above is a snapshot of how the .txt file looks from inside. If you want to search the stock code for a particular instrument, simply use “ctrl + f” to find the related instrument.
#Note: You can open the file in excel too, just that, you would need to use a delimiter “,” to separate the field values and create a dataset.
Notice the second column “Short Name” in the dataset. This corresponds to the stock code required in the input parameter of API endpoints.
So let’s say you want to download daily closing price for Reliance Industries Limited from NSE for the entire 2021 year. You should first look for Reliance Industries in the stock master file and on doing so should come across “RELIND” as the short name for Reliance Industries as listed on NSE.
The final code should look something like below:
|
# importing required libraries from breeze_connect import BreezeConnect import pandas as pd
# generating session through isec = BreezeConnect(api_key="K%834G9%)2M9z75111V2dP") isec.generate_session(api_secret="a69+y9097T9r279342xC513O82#ucU1a0",session_token="1117193")
# get historical data for Reliance Industries data = isec.get_historical_data(interval="day", from_date= "2021-01-01T07:00:00.000Z", to_date= "2021-12-31T07:00:00.000Z", stock_code="RELIND", exchange_code="NSE", product_type="cash") |
Similarly, you can look for stock codes for all the asset classes – equity, futures, options etc. using the respective master security file (example : NSE script master or FnO scrip master file) available on the same link as mentioned above on our documentation page à instruments section.
For more information on Breeze API, please check out our homepage, which contains access to articles, videos and webinars for the same. The link for the same is mentioned below:
Explore the meaning of a mainboard IPO, SEBI's eligibility routes, NSE and BSE listing rules, key benefits, and the checks investors should make before applying.
Commodity prices don't move in isolation. Along with demand-supply dynamics and geopolitical events, one global indicator that often influences commodity prices is the US Dollar Index (DXY).
Gold can react to inflation data, while crude oil may jump after an inventory report or geopolitical disruption.