- Breeze API Java Client
- API Documentation
- Set Up Virtual Environment
- Installing Client
- API Usage
- Websocket Usage
- List Of Other SDK methods
Download the jar file of the project from the following link breezeconnect jar file and include it in the build path of your project.
The official Java client library for the ICICI Securities trading APIs. BreezeConnect is a set of REST-like APIs that allows one to build a complete investment and trading platform. Following are some notable features of Breeze APIs:
- Execute orders in real time
- Manage Portfolio
- Access to 10 years of historical market data including 1 sec OHLCV
- Streaming live OHLC (websockets)
- Option Chain API
// Initialize SDK
BreezeConnect breezeConnect = new BreezeConnect("your_api_key");
// Obtain your session key from https://api.icicidirect.com/apiuser/login?api_key=YOUR_API_KEY
// Incase your api-key has special characters(like +,=,!) then encode the api key before using in the url as shown below.
System.out.println("https://api.icicidirect.com/apiuser/login?api_key="+URLEncoder.encode("your_api_key", StandardCharsets.UTF_8));
// Generate Session
breezeConnect.generateSession("your_secret_key","your_api_session");
// Initialize SDK
BreezeConnect breezeConnect = new BreezeConnect("your_api_key");
// Obtain your session key from https://api.icicidirect.com/apiuser/login?api_key=YOUR_API_KEY
// Incase your api-key has special characters(like +,=,!) then encode the api key before using in the url as shown below.
System.out.println("https://api.icicidirect.com/apiuser/login?api_key="+URLEncoder.encode("your_api_key", StandardCharsets.UTF_8));
// Generate Session
breezeConnect.generateSession("your_secret_key","your_api_session");
// Connect to websocket(it will connect to rate refresh server)
breezeConnect.connectTicker();
// Callback to receive ticks.
breezeConnect.registerOnTickEventListener(new OnTickEventListener() {
@Override
public void onTickEvent(Object tick) {
System.out.println(tick.toString());
}
});
// subscribe stocks feeds
breezeConnect.subscribeFeeds("NFO","ZEEENT","options","31-Mar-2022","350","Call", true, false);
// subscribe stocks feeds by stock-token
breezeConnect.subscribeFeeds("1.1!500780");
// unsubscribe stocks feeds
breezeConnect.unsubscribeFeeds("NFO","ZEEENT","options","31-Mar-2022","350","Call", true, false);
// unsubscribe stocks feeds by stock-token
breezeConnect.unsubscribeFeeds("1.1!500780");
// subscribe to Real Time Streaming OHLCV Data of stocks
breezeConnect.subscribeFeeds("NFO", "ZEEENT", "options", "31-Mar-2022","350", "Call", "1minute");
// subscribe to Real Time Streaming OHLCV Data of stocks by stock-token
breezeConnect.subscribeFeeds("1.1!500780","1second");
// unsubscribe to Real Time Streaming OHLCV Data of stocks
breezeConnect.unsubscribeFeeds("NFO", "ZEEENT", "options", "31-Mar-2022", "350", right="Call", interval="1minute");
// unsubscribe to Real Time Streaming OHLCV Data of stocks by stock-token
breezeConnect.unsubscribeFeeds("1.1!500780","1second");
// subscribe order notification feeds(it will connect to order streaming server)
breezeConnect.subscribeFeeds(true)
// unsubscribe order notification feeds(also it will disconnect the order streaming server)
breezeConnect.unsubscribeFeeds(get_order_notification=true)
NOTE
Examples for stock_token are "4.1!38071" or "1.1!500780".
Template for stock_token : X.Y! X : exchange code Y : Market Level data Token : ISEC stock code
Value of X can be : 1 for BSE, 4 for NSE, 13 for NDX, 6 for MCX, 4 for NFO,
Value of Y can be : 1 for Level 1 data, 4 for Level 2 data
Token number can be obtained via get_names() function or downloading master security file via https://api.icicidirect.com/breezeapi/documents/index.html#instruments
exchange_code must be 'BSE', 'NSE', 'NDX', 'MCX' or 'NFO'.
stock_code should not be an empty string. Examples for stock_code are "WIPRO" or "ZEEENT".
product_type can be either 'Futures', 'Options' or an empty string. Product_type can not be an empty string for exchange_code 'NDX', 'MCX' and 'NFO'.
strike_date can be in DD-MMM-YYYY(Ex.: 01-Jan-2022) or an empty string. strike_date can not be an empty string for exchange_code 'NDX', 'MCX' and 'NFO'.
strike_price can be float-value in string or an empty string. strike_price can not be an empty string for product_type 'Options'.
right can be either 'Put', 'Call' or an empty string. right can not be an empty string for product_type 'Options'.
Either get_exchange_quotes must be True or get_market_depth must be True.
Both get_exchange_quotes and get_market_depth can be True, But both must not be False.
For Streaming OHLCV, interval must not be empty and must be equal to either of the following "1second","1minute", "5minute", "30minute"
- getCustomerDetails
- getDematHoldings
- getFunds
- setFunds
- getHistoricalData
- getHistoricalDatav2
- addMargin
- getMargin
- placeOrder
- orderDetail
- orderList
- cancelOrder
- modifyOrder
- getPortfolioHolding
- getPortfolioPosition
- getQuotes
- getOptionChainQuotes
- squareOff
- modifyOrder
- getTradeList
- getTradeDetail
- getNames
- previewOrder
breezeConnect.getCustomerDetails("your_api_session");
Back to Index
breezeConnect.getDematHoldings();
Back to Index
breezeConnect.getFunds();
Back to Index
breezeConnect.setFunds("debit","200","Equity");
Note: Set Funds of your account by transaction-type as "Credit" or "Debit" with amount in numeric string as rupees and segment-type as "Equity" or "FNO".
Back to Index
breezeConnect.getHistoricalData(
"1minute","2022-08-15T07:00:00.000Z","2022-08-17T07:00:00.000Z",
"ICIBAN","NFO","futures","2022-08-25T07:00:00.000Z","others","0"
);
breezeConnect.getHistoricalData(
"1minute","2022-08-15T07:00:00.000Z","2022-08-17T07:00:00.000Z",
"ITC","NSE","cash"
);
breezeConnect.getHistoricalData(
"1minute","2022-08-15T07:00:00.000Z","2022-08-17T07:00:00.000Z",
"CNXBAN","NFO","options","2022-09-29T07:00:00.000Z","call","38000"
);
Note : Get Historical Data for specific stock-code by mentioned interval either as "1minute", "5minute", "30minute" or as "1day"
Back to Index
breezeConnect.getHistoricalDatav2(
"1minute","2022-08-15T07:00:00.000Z","2022-08-17T07:00:00.000Z",
"ICIBAN","NFO","futures","2022-08-25T07:00:00.000Z","others","0"
);
breezeConnect.getHistoricalDatav2(
"1minute","2022-08-15T07:00:00.000Z","2022-08-17T07:00:00.000Z",
"ITC","NSE","cash"
);
breezeConnect.getHistoricalDatav2(
"1minute","2022-08-15T07:00:00.000Z","2022-08-17T07:00:00.000Z",
"CNXBAN","NFO","options","2022-09-29T07:00:00.000Z","call","38000"
);
Note :
-
Get Historical Data (version 2) for specific stock-code by mentioning interval either as "1second","1minute", "5minute", "30minute" or as "1day".
-
Maximum candle intervals in one single request is 1000
Back to Index
breezeConnect.addMargin(
"margin", "ICIBAN", "BSE", "2021220", "100", "3817.10", "10", "0", "", "",
"", "", "", ""
);
Back to Index
breezeConnect.getMargin("NSE");
Note: Please change exchange_code=“NFO” to get F&O margin details
Back to Index
breezeConnect.placeOrder(
"ICIBAN","NFO","futures","buy","limit","0","3200","200","day",
"2022-08-22T06:00:00.000Z","0","2022-08-25T06:00:00.000Z","others",
"0","Test"
);
breezeConnect.placeOrder(
"NIFTY","NFO","options","buy","market","","50","","day","2022-08-30T06:00:00.000Z",
"0","2022-09-29T06:00:00.000Z","call","16600"
);
Back to Index
breezeConnect.placeOrder(
"ITC","NSE","cash","buy","limit","","1","305","day"
);
Back to Index
breezeConnect.placeOrder(
"NIFTY","NFO","optionplus","buy","limit","15","50","11.25","day",
"2022-12-02T06:00:00.000Z","0","2022-12-08T06:00:00.000Z","call",
"19000","Limit","20","Test"
);
Back to Index
breezeConnect.placeOrder(
"NIFTY","NFO","futureplus","Buy","limit","18720",
"50","18725","Day","0","29-DEC-2022"
);
Future plus - "Stop loss trigger price cannot be less than last traded price for Buy order"
Back to IndexbreezeConnect.getOrderDetail("NSE","20220819N100000001");
Note: Please change exchange_code=“NFO” to get details about F&O
Back to Index
breezeConnect.getOrderList("NSE","2022-08-01T10:00:00.000Z","2022-08-19T10:00:00.000Z");
Note: Please change exchange_code=“NFO” to get details about F&O
Back to Index
breezeConnect.cancelOrder("NSE","20220819N100000001");
Back to Index
breezeConnect.modifyOrder(
"202208191100000001","NFO","limit","0","250","290100","day",
"0","2022-08-22T06:00:00.000Z"
);
Back to Index
breezeConnect.getPortfolioHoldings(
"NFO","2022-08-01T06:00:00.000Z","2022-08-19T06:00:00.000Z","",""
);
Note: Please change exchange_code=“NSE” to get Equity Portfolio Holdings
Back to Index
breezeConnect.getPortfolioPositions()
Back to Index
breezeConnect.getQuotes(
"ICIBAN","NFO","2022-08-25T06:00:00.000Z","futures",
"others","0"
);
Back to Index
Get option-chain of mentioned stock-code for product-type Futures where input of expiry-date is not compulsory
breezeConnect.getOptionChainQuotes(
"ICIBAN","NFO","futures","2022-08-25T06:00:00.000Z"
);
Back to Index
Get option-chain of mentioned stock-code for product-type Options where atleast 2 input is required out of expiry-date, right and strike-price
breezeConnect.getOptionChainQuotes(
"ICIBAN","NFO","options","2022-08-25T06:00:00.000Z","call","16850"
);
Back to Index
breezeConnect.squareOff(
"NSE","margin","NIFTY","10","0","sell","market","day","0","0",
"","","","",""
);
Note: Please refer get_portfolio_positions() for settlement id and margin_amount
Back to Index
breezeConnect.squareOff(
"NFO","futures","ICIBAN","2022-08-25T06:00:00.000Z","sell","market",
"day","0","50","0","2022-08-12T06:00:00.000Z","","0"
);
Back to Index
breezeConnect.squareOff(
"NFO","options","ICIBAN","2022-08-25T06:00:00.000Z","Call","16850",
"sell","market","day","0","50","0","2022-08-12T06:00:00.000Z","","0"
);
Back to Index
breezeConnect.getTradeList(
"2022-08-01T06:00:00.000Z","2022-08-19T06:00:00.000Z","NSE",
"","","");
Note: Please change exchange_code=“NFO” to get details about F&O
Back to Index
breezeConnect.getTradeDetail("NSE","20220819N100000005");
Note: Please change exchange_code=“NFO” to get details about F&O
Back to Index
breezeConnect.getNames('NSE','TATASTEEL');
breezeConnect.getNames('NSE','RELIANCE');
Note: Use this method to find ICICI specific stock codes / token
breezeConnect.previewOrder("ICIBAN","NSE", "margin","limit","907.05","buy","1","N");