npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

breezeconnect

v1.0.29

Published

The official JS client for communicating with BreezeConnect API and Websocket.

Readme

Table Of Content

[email protected]

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:

  1. Execute orders in real time
  2. Manage Portfolio
  3. Access to 10 years of historical market data including 1 sec OHLCV
  4. Streaming live OHLC (websockets)
  5. Option Chain API
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);
});
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);
});

Back to Index

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","futureplus","optionplus", 'cash'
        expiryDate:"2022-09-29T07:00:00.000Z",
        right:"call",           // "call","put", "others" 
        strikePrice:"38000"
    }
)
.then((resp)=>{
    console.log(resp);
});

Back to Index

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","futureplus","optionplus", 'cash'
        expiryDate:"2022-08-25T07:00:00.000Z",
        right:"others",           // "call","put", "others" 
        strikePrice:"0"
    }
)
.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:"ITC",
        exchangeCode:"NSE",   // 'NSE','BSE','NFO','NDX,'MCX'
        productType:"cash"
    }
)
.then(function(resp){
    console.log(resp);
});

Back to Index

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);
});

Back to Index

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","futureplus","optionplus", 'cash'
        expiryDate:"2022-08-25T07:00:00.000Z",
        right:"others",           // "call","put", "others" 
        strikePrice:"0"
    }
)
.then((resp)=>{
    console.log(resp);
});
  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


breeze.addMargin(
    {
        productType:"cash",   //"futures","options","futureplus","optionplus","cash","eatm","margin"
        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);
})
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:"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",
        settlementId: "2023008",
        orderSegmentCode = "N"
    }                
)
.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.placeOrder(
    {
        stockCode:"NIFTY",
        exchangeCode:"NFO",
        product:"optionplus",
        action:"buy",
        orderType:"limit",
        stoploss:"15",
        quantity:"50",
        price:"11.25",
        validity:"day",
        validityDate:"2022-12-02T06:00:00.000Z",
        disclosedQuantity:"0",
        expiryDate:"2022-12-08T06:00:00.000Z",
        right:"call",
        strikePrice:"19000",
        orderTypeFresh:"Limit",
        orderRateFresh:"20",
        userRemark:"Test"
    }
)
.then(function(resp){
    console.log(resp);
})

breeze.placeOrder(
    {
        stockCode:"NIFTY",
        exchangeCode:"NFO",                                     
        product:"futureplus",                                    
        action: "Buy",                                            
        orderType: "limit",
        stoploss:"18720",                                            
        quantity:"50",                                          
        price: "18725",                                                                             
        validity:"Day",       
        disclosedQuantity:"0",                                  
        expiryDate:"29-DEC-2022"
    }
)
.then(function(resp){
    console.log(resp);
})
breeze.getOrderDetail(
    {
        exchangeCode:"NSE",
        orderId:"20220819N100000001"
    }
)
.then(function(resp){
    console.log(resp);
})
breeze.getOrderList(
    {
        exchangeCode:"NSE",
        fromDate:"2022-08-01T10:00:00.000Z",
        toDate:"2022-08-19T10:00:00.000Z"
    }
)
.then(function(resp){
    console.log(resp);
})
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);
})
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:"margin",
        stockCode:"NIFTY",
        quantity:"10",
        price:"0",
        action:"sell",
        orderType:"market",
        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);
})
breeze.getTradeDetail(
    {
        exchangeCode:"NSE",
        orderId:"20220819N100000005"
    }
)
.then(function(resp){
    console.log(resp);
})
breeze.getNames({exchangeCode :'NSE',stockCode : 'TATASTEEL'})
.then(function(resp){
    console.log(resp);
})

breeze.getNames({exchangeCode : 'NSE',stockCode : 'RELIANCE'})
.then(function(resp){
    console.log(resp);
})

Back to Index


    breeze.previewOrder(
        {
        stockCode : "ICIBAN",
        exchangeCode : "NSE",
        productType : "margin",
        orderType  : "limit",
        price : "907.05",
        action :"buy",
        quantity : "1",
        specialFlag : "N"
        }
        ).then(function(resp){
        console.log(resp);
        }).catch((err)=>{
            console.log(err);
        })

Back to Index


breeze.limitCalculator(strikePrice = "19200",                                    
    productType = "optionplus",                 
    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")

Back to Index


    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": "futureplus",
            "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": "optionplus",
            "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")