Download the jar file of the project from the following link breezeconnect jar file and include it in the build path of your project.
breezeapi@icicisecurities.com
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:
// 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!
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"
breezeConnect.getCustomerDetails("your_api_session");
breezeConnect.getDematHoldings();
breezeConnect.getFunds();
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".
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"
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 : 1) Get Historical Data (version 2) for specific stock-code by mentioning interval either as "1second","1minute", "5minute", "30minute" or as "1day". 2) Maximum candle intervals in one single request is 1000
breezeConnect.addMargin(
"margin", "ICIBAN", "BSE", "2021220", "100", "3817.10", "10", "0", "", "",
"", "", "", ""
);
breezeConnect.getMargin("NSE");
Note: Please change exchange_code=“NFO” to get F&O margin details
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"
);
breezeConnect.placeOrder(
"ITC","NSE","cash","buy","limit","","1","305","day"
);
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"
);
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"
breezeConnect.getOrderDetail("NSE","20220819N100000001");
Note: Please change exchange_code=“NFO” to get details about F&O
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
breezeConnect.cancelOrder("NSE","20220819N100000001");
breezeConnect.modifyOrder(
"202208191100000001","NFO","limit","0","250","290100","day",
"0","2022-08-22T06:00:00.000Z"
);
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
breezeConnect.getPortfolioPositions()
breezeConnect.getQuotes(
"ICIBAN","NFO","2022-08-25T06:00:00.000Z","futures",
"others","0"
);
breezeConnect.getOptionChainQuotes(
"ICIBAN","NFO","futures","2022-08-25T06:00:00.000Z"
);
breezeConnect.getOptionChainQuotes(
"ICIBAN","NFO","options","2022-08-25T06:00:00.000Z","call","16850"
);
breezeConnect.squareOff(
"NSE","margin","NIFTY","10","0","sell","market","day","0","0",
"","","","",""
);
Note: Please refer get_portfolio_positions() for settlement id and margin_amount
breezeConnect.squareOff(
"NFO","futures","ICIBAN","2022-08-25T06:00:00.000Z","sell","market",
"day","0","50","0","2022-08-12T06:00:00.000Z","","0"
);
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"
);
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
breezeConnect.getTradeDetail("NSE","20220819N100000005");
Note: Please change exchange_code=“NFO” to get details about F&O
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");