loader2
Partner With Us NRI

Open Free Demat Account Online with ICICIDIRECT

How to Generate Session Key and Install SDK for Breeze API?

ICICI Securities 02 Feb 2022 0 COMMENT

What is Breeze API?

Breeze API is the next-gen Trading API from ICICIdirect which has been built with a Customer-first mentality. We are the offering the widest range of data, unmatched in India alongside a robust and stable framework of processes to ensure data security and privacy

You need to login to on https://api.icicidirect.com/apiuser/home to save your App.

What is a Session Key?

A session key is a temporary key that is only used once, during one stretch of time, for encrypting and decrypting data. This is similar to a password that someone has to resets every time they login and helps in encrypting a communication session for each app separately. This key or token expires in 24 hours after generation or at midnight.

How can you generate your Session Key?

  • Login with your ICICIdirect Account on https://api.icicidirect.com/apiuser/home and then navigate to ‘View Apps’
  • Select the app for which you want to generate the Session Token and copy its API Key
  • Open a new tab, and switch to Developer Tools (on Chrome, Firefox, and Edge use the keyboard shortcut: Ctrl+Shift+I)
  • Open the URL: https://api.icicidirect.com/apiuser/login?api_key=your_public_key
  • Give ICICIdirect account credentials as usual and submit
  • In the Network Log table, find the resource with the same name as the redirect URL you gave when creating the app. For example, if you gave the redirect URL as https://127.0.0.1:9080/api, look for a row named “127.0.0.1”.Click the row and in the new split, click tab named “Payload”>”Form Data”>”API_Session”.

Against “API_Session” will be an alpha-numeric (could be only numbers or only alphabets) token. This is your Sesssion Key for that app.

What is an SDK?

SDK stands for software development kit or devkit for short. SDK tools will include a variety of things, including libraries, documentation, code samples, processes, and guides. These can be used by developers to integrate into the apps they want to create.

How can you install an SDK?

  • Install virtual environment package.
    (If you have already installed it then skip this step.)
    pip install virtualenv
  • Create and activate the environment.
    virtualenv -p python3 .
    source bin/activate
  • Install breeze-connect SDK  
    pip install breeze-connect

A few samples:

from breeze_connect import BreezeConnect

# Generate Session

isec = BreezeConnect(api_key="your_api_key")

isec.generate_session(api_secret="your_secret",

session_token="YOUR_SESSION_TOKEN_OBTAINED_FROM_LOGIN_PAGE_RESPONSE")

# Websocket

isec.ws_connect()

# subscribe stocks feeds

isec.subscribe_stock(exchange_code="", stock_code="", product_type="", strike_date="", strike_price="", right="", get_exchange_quotes=True, get_market_depth=True)

def on_ticks(ticks):

print("Ticks: {}".format(ticks))

isec.on_ticks = on_ticks

# unsubscribe stocks feeds

isec.unsubscribe_stock(exchange_code="", stock_code="",product_type="", strike_date="", strike_price="", right="", get_exchange_quotes=True, get_market_depth=True)

Please note that the stock symbols for websockets/live data are different from all other end points. The stock codes for this can be referenced from the Security Master file available at https://api.icicidirect.com/breezeapi/documents/index.html#instruments

What are the salient features of Breeze API are:

  1. Historical 1 Second Data: While everyone gives limited amount of Equity OHLC data, only Breeze gives 3 years of second level LTP data. This allows you to model your strategies more accurately and in the process backtest strategies far more accurately.
  2. Historical Derivatives Data: With 3 years of data, no other broker provides Futures or Options historical data for in-depth analysis
  3. Live Streaming OHLC: While everyone gives streaming LTP data, Breeze is the only one that gives streaming OHLC data so that strategies that are written around Historical OHLC data can be simply taken live without the need to change the data handling functions.
  4. Triple secure data: Breeze has SSL + (App Key, Secret Key) encryption + Checksum encryption of the whole data package so no amount of sniffing or hacking can reveal your data to the wannabe hacker. Breeze is the only retail API in India has this feature.

 

Disclaimer – ICICI Securities Ltd. (I-Sec). Registered office of I-Sec is at ICICI Securities Ltd. - ICICI Venture House, Appasaheb Marathe Marg, Prabhadevi, Mumbai - 400 025, India, Tel No : 022 - 6807 7100. I-Sec is a Member of National Stock Exchange of India Ltd (Member Code :07730), BSE Ltd (Member Code :103) and Member of Multi Commodity Exchange of India Ltd. (Member Code: 56250) and having SEBI registration no. INZ000183631. I-Sec is a SEBI registered with SEBI as a Research Analyst vide registration no. INH000000990. AMFI Regn. No.: ARN-0845. PFRDA registration numbers:  POP no -05092018. I-Sec acts as a Composite Corporate agent having registration number –CA0113. Name of the Compliance officer (broking): Mr. Anoop Goyal, Contact number: 022-40701000, E-mail address: complianceofficer@icicisecurities.com. Investment in securities market are subject to market risks, read all the related documents carefully before investing. The non-broking products / services like Mutual Funds, Insurance, FD/ Bonds, loans, PMS, Tax, Elocker, NPS, IPO, Research, Financial Learning, Investment Advisory etc. are not exchange traded products / services and ICICI Securities Ltd. is just acting as a distributor/ referral Agent of such products / services and all disputes with respect to the distribution activity would not have access to Exchange investor redressal or Arbitration mechanism.The contents herein above shall not be considered as an invitation or persuasion to trade or invest.  I-Sec and affiliates accept no liabilities for any loss or damage of any kind arising out of any actions taken in reliance thereon. The contents herein above are solely for informational purpose and may not be used or considered as an offer document or solicitation of offer to buy or sell or subscribe for securities or other financial instruments or any other product. Investors should consult their financial advisers whether the product is suitable for them before taking any decision. The contents herein mentioned are solely for informational and educational purpose.