
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
breezeconnect
Advanced tools
The official JS client for communicating with BreezeConnect API and Websocket.
The official Javascript 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:
npm install breezeconnect
var BreezeConnect = require('breezeconnect').BreezeConnect;
var appKey ="your_api_key";
var appSecret = "your_secret_key";
var breeze = new BreezeConnect({"appKey":appKey});
//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.
console.log("https://api.icicidirect.com/apiuser/login?api_key="+encodeURI("your_api_key"))
//Generate Session
breeze.generateSession(appSecret,"your_api_session").then(function(resp){
apiCalls();
}).catch(function(err){
console.log(err)
});
function apiCalls(){
breeze.getFunds().then(function(resp){
console.log("Final Response");
console.log(resp);
});
}
//Connect to websocket(it will connect to rate refresh server)
breeze.wsConnect();
//Callback to receive ticks.
function onTicks(ticks){
console.log(ticks);
}
//Assign the callbacks
breeze.onTicks = onTicks;
//subscribe stocks feeds by stock-token
breeze.subscribeFeeds({stockToken:"4.1!1594"})
.then(
function(resp){
console.log(resp);
}
)
// subscribe to oneclick strategy stream
breeze.subscribeFeeds({stockToken:"one_click_fno"})
.then(
function(resp){
console.log(resp);
}
)
// unsubscribe to oneclick strategy stream
breeze.unsubscribeFeeds({stockToken:"one_click_fno"})
.then(
function(resp){
console.log(resp);
}
)
// subscribe to i_click_2_gain strategy stream
breeze.subscribeFeeds({stockToken:"i_click_2_gain"})
.then(
function(resp){
console.log(resp);
}
)
// unsubscribe to i_click_2_gain strategy stream
breeze.unsubscribeFeeds({stockToken:"i_click_2_gain"})
.then(
function(resp){
console.log(resp);
}
)
//subscribe stocks feeds
breeze.subscribeFeeds(
{
exchangeCode:"NFO",
stockCode:"ZEEENT",
productType:"options",
expiryDate:"31-Mar-2022",
strikePrice:"350",
right:"Call",
getExchangeQuotes:true,
getMarketDepth:false
}
).then(function(resp){console.log(resp)});
//subscribe stocks feeds
breeze.unsubscribeFeeds(
{
exchangeCode:"NFO",
stockCode:"ZEEENT",
productType:"options",
expiryDate:"31-Mar-2022",
strikePrice:"350",
right:"Call",
getExchangeQuotes:true,
getMarketDepth:false
}
).then(function(resp){console.log(resp)});
//unsubscribe feeds using stock token
breeze.unsubscribeFeeds({stockToken:"4.1!1594"}).then(
function(resp){
console.log(resp);
}
)
//subscribe to Real Time Streaming OHLCV Data of stocks by stock-token
breeze.subscribeFeeds({stockToken:"1.1!500780", interval:"1second"})
.then(
function(resp){
console.log(resp);
}
)
//subscribe to Real Time Streaming OHLCV Data of stocks
breeze.subscribeFeeds(
{
exchangeCode:"NFO",
stockCode:"ZEEENT",
productType:"options",
expiryDate:"31-Mar-2022",
strikePrice:"350",
right:"Call",
getExchangeQuotes:true,
getMarketDepth:false,
interval:"1minute"
}
).then(function(resp){console.log(resp)});
// unsubscribe from Real Time Streaming OHLCV Data of stocks by stock-token
breeze.unsubscribeFeeds({stockToken:"1.1!500780", interval:"1second"})
.then(
function(resp){
console.log(resp);
}
)
//unsubscribe from Real Time Streaming OHLCV Data of stocks
breeze.unsubscribeFeeds(
{
exchangeCode:"NFO",
stockCode:"ZEEENT",
productType:"options",
expiryDate:"31-Mar-2022",
strikePrice:"350",
right:"Call",
getExchangeQuotes:true,
getMarketDepth:false,
interval:"1minute"
}
).then(function(resp){console.log(resp)});
//subscribe order notification feeds(it will connect to order streaming server)
breeze.subscribeFeeds({getOrderNotification:true}).then(
function(resp){
console.log(resp);
}
)
//unsubscribe order notification feeds(it will disconnect from order streaming server)
breeze.subscribeFeeds({getOrderNotification:true}).then(
function(resp){
console.log(resp);
}
)
//disconnects rate refresh server
breeze.wsDisconnect();
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
exchangeCode 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 exchangeCode '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 exchangeCode '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"
breeze.getCustomerDetails("api session").then((data) => {
console.log(data);
}).catch((err)=>{
console.log(err);
});
breeze.getDematHoldings().then(function(resp){
console.log(resp);
});
breeze.getFunds().then(function(resp){
console.log(resp);
});
breeze.setFunds(
{
transactionType:"debit", //"debit", "credit"
amount:"100",
segment:"Equity"
}
)
.then(function(resp){
console.log(resp);
});
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".
breeze.getHistoricalData(
{
interval:"1minute", //'1minute', '5minute', '30minute','1day'
fromDate: "2022-08-15T07:00:00.000Z",
toDate: "2022-08-17T07:00:00.000Z",
stockCode:"ITC",
exchangeCode:"NSE", // 'NSE','BSE','NFO'
productType:"cash"
}
)
.then(function(resp){
console.log(resp);
});
breeze.getHistoricalData(
{
interval:"1minute", //'1minute', '5minute', '30minute','1day'
fromDate: "2022-08-15T07:00:00.000Z",
toDate: "2022-08-17T07:00:00.000Z",
stockCode:"CNXBAN",
exchangeCode:"NFO", // 'NSE','BSE','NFO'
productType:"options", // "futures","options","cash"
expiryDate:"2022-09-29T07:00:00.000Z",
right:"call", // "call","put", "others"
strikePrice:"38000"
}
)
.then((resp)=>{
console.log(resp);
});
breeze.getHistoricalData(
{
interval:"1minute", //'1minute', '5minute', '30minute','1day'
fromDate: "2022-08-15T07:00:00.000Z",
toDate: "2022-08-17T07:00:00.000Z",
stockCode:"ICIBAN",
exchangeCode:"NFO", // 'NSE','BSE','NFO'
productType:"futures", // "futures","options","cash"
expiryDate:"2022-08-25T07:00:00.000Z",
right:"others", // "call","put", "others"
strikePrice:"0"
}
)
.then((resp)=>{
console.log(resp);
});
Note : Get Historical Data for specific stock-code by mentioned interval either as "1minute", "5minute", "30minute" or as "1day"
breeze.getHistoricalDatav2(
{
interval:"1minute", //'1second', '1minute', '5minute', '30minute','1day'
fromDate: "2022-08-15T07:00:00.000Z",
toDate: "2022-08-17T07:00:00.000Z",
stockCode:"ITC",
exchangeCode:"NSE", // 'NSE','BSE','NFO','NDX,'MCX'
productType:"cash"
}
)
.then(function(resp){
console.log(resp);
});
breeze.getHistoricalDatav2(
{
interval:"1minute", //'1second', '1minute', '5minute', '30minute','1day'
fromDate: "2022-08-15T07:00:00.000Z",
toDate: "2022-08-17T07:00:00.000Z",
stockCode:"CNXBAN",
exchangeCode:"NFO", // 'NSE','BSE','NFO','NDX,'MCX'
productType:"options", // "futures","options",'cash'
expiryDate:"2022-09-29T07:00:00.000Z",
right:"call", // "call","put", "others"
strikePrice:"38000"
}
)
.then((resp)=>{
console.log(resp);
});
breeze.getHistoricalDatav2(
{
interval:"1minute", //'1second', '1minute', '5minute', '30minute','1day'
fromDate: "2022-08-15T07:00:00.000Z",
toDate: "2022-08-17T07:00:00.000Z",
stockCode:"ICIBAN",
exchangeCode:"NFO", // 'NSE','BSE','NFO'
productType:"futures", // "futures","options","cash"
expiryDate:"2022-08-25T07:00:00.000Z",
right:"others", // "call","put", "others"
strikePrice:"0"
}
)
.then((resp)=>{
console.log(resp);
});
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
breeze.addMargin(
{
productType:"cash", //"futures","options","cash"
stockCode:"ITC",
exchangeCode:"NSE", // 'NSE','BSE','NFO'
settlementId:"2022106",
addAmount:"100",
marginAmount:"265",
openQuantity:"1",
coverQuantity:"0",
categoryIndexPerStock:"",
expiryDate:"",
right:"", //"call", "put", "others"
contractTag:"",
strikePrice:"",
segmentCode:"N"
}
)
.then(function(resp){
console.log(resp);
})
breeze.getMargin(exchangeCode='NSE').then(function(resp){
console.log(resp);
})
Note: Please change exchangeCode=“NFO” to get F&O margin details
breeze.placeOrder(
{
stockCode:"ICIBAN",
exchangeCode:"NFO",
product:"futures",
action:"buy",
orderType:"limit",
stoploss:"0",
quantity:"3200",
price:"200",
validity:"day",
validityDate:"2022-08-22T06:00:00.000Z",
disclosedQuantity:"0",
expiryDate:"2022-08-25T06:00:00.000Z",
right:"others",
strike_price:"0",
userRemark:"Test"
}
)
.then(function(resp){
console.log(resp);
})
breeze.placeOrder(
{
stockCode:"NIFTY",
exchangeCode:"NFO",
product:"options",
action:"buy",
orderType:"market",
stoploss:"",
quantity:"50",
price:"",
validity:"day",
validityDate:"2022-08-30T06:00:00.000Z",
disclosedQuantity:"0",
expiryDate:"2022-09-29T06:00:00.000Z",
right:"call",
strikePrice:"16600"
}
)
.then(function(resp){
console.log(resp);
})
breeze.placeOrder(
{
stockCode:"ITC",
exchangeCode:"NSE",
product:"cash",
action:"buy",
orderType:"limit",
stoploss:"",
quantity:"1",
price:"305",
validity:"day"
}
)
.then(function(resp){
console.log(resp);
})
breeze.getOrderDetail(
{
exchangeCode:"NSE",
orderId:"20220819N100000001"
}
)
.then(function(resp){
console.log(resp);
})
Note: Please change exchangeCode=“NFO” to get details about F&O
breeze.getOrderList(
{
exchangeCode:"NSE",
fromDate:"2022-08-01T10:00:00.000Z",
toDate:"2022-08-19T10:00:00.000Z"
}
)
.then(function(resp){
console.log(resp);
})
Note: Please change exchangeCode=“NFO” to get details about F&O
breeze.cancelOrder(
{
exchangeCode:"NSE",
orderId:"20220819N100000001"
}
)
.then(function(resp){
console.log(resp);
})
breeze.modifyOrder(
{
orderId:"202208191100000001",
exchangeCode:"NFO",
orderType:"limit",
stoploss:"0",
quantity:"250",
price:"290100",
validity:"day",
disclosedQuantity:"0",
validityDate:"2022-08-22T06:00:00.000Z"
}
)
.then(function(resp){
console.log(resp);
})
breeze.getPortfolioHoldings(
{
exchangeCode:"NFO",
fromDate:"2022-08-01T06:00:00.000Z",
toDate:"2022-08-19T06:00:00.000Z",
stockCode:"",
portfolioType:""
}
)
.then(function(resp){
console.log(resp);
})
Note: Please change exchangeCode=“NSE” to get Equity Portfolio Holdings
breeze.getPortfolioPositions()
breeze.getQuotes(
{
stockCode:"ICIBAN",
exchangeCode:"NFO",
expiryDate:"2022-08-25T06:00:00.000Z",
productType:"futures",
right:"others",
strikePrice:"0"
}
)
.then(function(resp){
console.log(resp);
})
breeze.getOptionChainQuotes(
{
stockCode:"ICIBAN",
exchangeCode:"NFO",
productType:"futures",
expiryDate:"2022-08-25T06:00:00.000Z"
}
)
.then(function(resp){
console.log(resp);
})
breeze.getOptionChainQuotes(
{
stockCode:"ICIBAN",
exchangeCode:"NFO",
productType:"options",
expiryDate:"2022-08-25T06:00:00.000Z",
right:"call",
strikePrice:"16850"
}
)
.then(function(resp){
console.log(resp);
})
breeze.squareOff(
{
exchangeCode:"NSE",
product:"cash",
stockCode:"NIFTY",
quantity:"10",
price:"0",
action:"sell",
orderType:"limit",
validity:"day",
stoploss:"0",
disclosedQuantity:"0",
protectionPercentage:"",
settlementId:"",
coverQuantity:"",
openQuantity:"",
marginAmount:""
}
)
.then(function(resp){
console.log(resp);
})
breeze.squareOff(
{
exchangeCode:"NFO",
product:"futures",
stockCode:"ICIBAN",
expiryDate:"2022-08-25T06:00:00.000Z",
action:"sell",
orderType:"market",
validity:"day",
stoploss:"0",
quantity:"50",
price:"0",
validityDate:"2022-08-12T06:00:00.000Z",
tradePassword:"",
disclosedQuantity:"0"
}
)
.then(function(resp){
console.log(resp);
})
breeze.squareOff(
{
exchangeCode:"NFO",
product:"options",
stockCode:"ICIBAN",
expiryDate:"2022-08-25T06:00:00.000Z",
right:"Call",
strikePrice:"16850",
action:"sell",
orderType:"market",
validity:"day",
stoploss:"0",
quantity:"50",
price:"0",
validityDate:"2022-08-12T06:00:00.000Z",
tradePassword:"",
disclosedQuantity:"0"
}
)
.then(function(resp){
console.log(resp);
})
breeze.getTradeList(
{
fromDate:"2022-08-01T06:00:00.000Z",
toDate:"2022-08-19T06:00:00.000Z",
exchangeCode:"NSE",
productType:"",
action:"",
stockCode:""
}
)
.then(function(resp){
console.log(resp);
})
Note: Please change exchangeCode=“NFO” to get details about F&O
breeze.getTradeDetail(
{
exchangeCode:"NSE",
orderId:"20220819N100000005"
}
)
.then(function(resp){
console.log(resp);
})
Note: Please change exchangeCode=“NFO” to get details about F&O
breeze.getNames({exchangeCode :'NSE',stockCode : 'TATASTEEL'})
.then(function(resp){
console.log(resp);
})
breeze.getNames({exchangeCode : 'NSE',stockCode : 'RELIANCE'})
.then(function(resp){
console.log(resp);
})
Note: Use this method to find ICICI specific stock codes / token
breeze.previewOrder(
{
stockCode : "ICIBAN",
exchangeCode : "NSE",
productType : "cash",
orderType : "limit",
price : "907.05",
action :"buy",
quantity : "1",
specialFlag : "N"
}
).then(function(resp){
console.log(resp);
}).catch((err)=>{
console.log(err);
})
breeze.limitCalculator(strikePrice = "19200",
productType = "options",
expiryDate = "06-JUL-2023",
underlying = "NIFTY",
exchangeCode = "NFO",
orderFlow = "Buy",
stopLossTrigger = "200.00",
optionType = "Call",
sourceFlag = "P",
limitRate = "",
orderReference = "",
availableQuantity = "",
marketType = "limit",
freshOrderLimit = "177.70")
breeze.marginCalculator([{
"strike_price": "0",
"quantity": "15",
"right": "others",
"product": "futures",
"action": "buy",
"price": "46230.85",
"expiry_date": "31-Aug-2023",
"stock_code": "CNXBAN",
"cover_order_flow": "N",
"fresh_order_type": "N",
"cover_limit_rate": "0",
"cover_sltp_price": "0",
"fresh_limit_rate": "0",
"open_quantity": "0"
},
{
"strike_price": "37000",
"quantity": "15",
"right": "Call",
"product": "options",
"action": "buy",
"price": "9100",
"expiry_date": "27-Jul-2023",
"stock_code": "CNXBAN",
"cover_order_flow": "N",
"fresh_order_type": "N",
"cover_limit_rate": "0",
"cover_sltp_price": "0",
"fresh_limit_rate": "0",
"open_quantity": "0"
},
{
"strike_price": "0",
"quantity": "50",
"right": "others",
"product": "futures",
"action": "buy",
"price": "19800",
"expiry_date": "27-Jul-2023",
"stock_code": "NIFTY",
"cover_order_flow": "N",
"fresh_order_type": "N",
"cover_limit_rate": "0",
"cover_sltp_price": "0",
"fresh_limit_rate": "0",
"open_quantity": "0"
},
{
"strike_price": "19600",
"quantity": "50",
"right": "call",
"product": "options",
"action": "buy",
"price": "245.05",
"expiry_date": "27-Jul-2023",
"stock_code": "NIFTY",
"cover_order_flow": "sell",
"fresh_order_type": "limit",
"cover_limit_rate": "180.00",
"cover_sltp_price": "200.00",
"fresh_limit_rate": "245.05",
"open_quantity": "50"
}],exchangeCode = "NFO")
FAQs
The official JS client for communicating with BreezeConnect API and Websocket.
We found that breezeconnect demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.