How to get NSE and BSE Live Market Data in Nodejs


  • How to get live NSE and BSE Live data in Nodejs cause the code

    let web_socket = new WebSocketClient({
        clientcode: "CLIENT_CODE",    
        jwttoken: "jwt_token",
        apikey: "smartapi_key",
        feedtype: "order_feed",
    });
    
    web_socket.connect()
        .then(() => {
            web_socket.fetchData("ACTION_TYPE", "FEED_TYPE");  // ACTION_TYPE: subscribe | unsubscribe FEED_TYPE: order_feed
    
            setTimeout(function () {
                web_socket.close()
            }, 60000)
        });
    
    web_socket.on('tick', receiveTick);
    
    
    function receiveTick(data) {
        console.log("receiveTick:::::", data);
    }
    
    

    is not working


  • Hi @vvarthan7 you can call ltp function for ltp also the above reposes has ltp in it.


  • @admin the feed is not having the correct response structure. Unable to get LTP.

    [{"ak":"ok","task":"cn","msg":"connected"}][][{"tvalue":"18/05/2021 14:20:53","name":"tm"},{"to":"8962863338.88","lo":"1972.50","e":"nse_cm","sp":"1992.15","c":"1960.35","ltp":"1992.00","ltq":"9","tk":"2885","bs":"7","ltt":"18/05/2021 14:20:52","tsq":"586609","v":"4508664","bp":"1992.00","cng":"31.65","bq":"82","ap":"1987.92","nc":"01.6145","name":"sf","tbq":"373643"}][{"e":"nse_cm","name":"sf","ltp":"1992.00","ltq":"1","tk":"2885","ltt":"NA"}][{"tvalue":"18/05/2021 14:20:54","name":"tm"},{"to":"8962865326.80","lo":"1972.50","e":"nse_cm","sp":"1992.15","c":"1960.35","ltp":"1992.00","ltq":"1","tk":"2885","bs":"7","ltt":"18/05/2021 14:20:53","tsq":"586600","v":"4508665","bp":"1992.05","cng":"31.65","bq":"1","ap":"1987.92","nc":"01.6145","name":"sf","tbq":"373462"}][{"tvalue":"18/05/2021 14:20:55","name":"tm"},{"to":"8962968698.64","lo":"1972.50","e":"nse_cm","sp":"1992.15","c":"1960.35","ltp":"1992.15","ltq":"2","tk":"2885","bs":"7","ltt":"18/05/2021 14:20:54","tsq":"586600","v":"4508717","bp":"1992.00","cng":"31.80","bq":"101","ap":"1987.92","nc":"01.6222","name":"sf","tbq":"373462"}][{"e":"nse_cm","name":"sf","ltp":"1992.15","ltq":"2","tk":"2885","ltt":"NA"}][{"e":"nse_cm","name":"sf","ltp":"1992.00","ltq":"15","tk":"2885","ltt":"NA"}][{"tvalue":"18/05/2021 14:20:56","name":"tm"},{"to":"8963103877.20","lo":"1972.50","e":"nse_cm","sp":"1992.15","c":"1960.35","ltp":"1992.00","ltq":"30","tk":"2885","bs":"7","ltt":"18/05/2021 14:20:55","tsq":"586809","v":"4508785","bp":"1992.00","cng":"31.65","bq":"170","ap":"1987.92","nc":"01.6145","name":"sf","tbq":"373505"}][{"e":"nse_cm","name":"sf","ltp":"1992.15","ltq":"1","tk":"2885","ltt":"NA"}][{"tvalue":"18/05/2021 14:20:57","name":"tm"}][{"to":"8963133696.00","lo":"1972.50","e":"nse_cm","sp":"1992.05","c":"1960.35","ltp":"1992.15","ltq":"13","tk":"2885","bs":"5","ltt":"18/05/2021 14:20:56","tsq":"586803","v":"4508800","bp":"1992.00","cng":"31.80","bq":"269","ap":"1987.92","nc":"01.6222","name":"sf","tbq":"373878"}][{"e":"nse_cm","name":"sf","ltp":"1992.15","ltq":"13","tk":"2885","ltt":"NA"}][{"tvalue":"18/05/2021 14:20:58","name":"tm"}][{"to":"8963159538.96","lo":"1972.50","e":"nse_cm","sp":"1992.05","c":"1960.35","ltp":"1992.00","ltq":"1","tk":"2885","bs":"55","ltt":"18/05/2021 14:20:58","tsq":"586724","v":"4508813","bp":"1992.00","cng":"31.65","bq":"332","ap":"1987.92","nc":"01.6145","name":"sf","tbq":"374092"}][{"e":"nse_cm","name":"sf","ltp":"1992.05","ltq":"5","tk":"2885","ltt":"NA"}]
    

    This is how the response looks now. Also meanwhile the new WebSocket implementation is not working at all.


  • @admin the old WebSocket code seems to be working. Just wanted to know until what time I will get data in WebSocket? is it till 3:20 pm?


  • @admin I am not getting any error. But when I checked the promise is not getting resolved.

    let web_socket = new WebSocketClient({
        clientcode: "V27127",    
        jwttoken: jwtToken,
        apikey: "85hgcaVa",
        feedtype: "order_feed"
      });
      
      web_socket.connect()
        .then(() => {
            web_socket.fetchData("subscribe", "order_feed");  // ACTION_TYPE: subscribe | unsubscribe FEED_TYPE: order_feed
      
            setTimeout(function () {
                web_socket.close()
            }, 60000)
        });
      
      web_socket.on('tick', receiveTick);
      
      function receiveTick(data) {
        console.log("receiveTick:::::", data);
      }
    

    When I tried to remove the feed type parameter, I am not getting any error for this as well. After 60000ms I am getting a message socket closed.


  • Hi @vvarthan7 kindly post your error snip here.


  • @admin any updates here? WebSocket connection for nodejs is not working. Any workaround?


  • HI @NyctoNid @vvarthan7 we will update you on web socket issue at EOD.


  • Any update here? @NyctoNid can you please help me resolve this issue?


  • Hi @NyctoNid you can connect us for further issue as discussed on the call.


  • @admin
    This is actual code

    let web_socket = new WebSocketClient({
        clientcode: "N199330",    
        jwttoken: jwtToken,
        apikey: "GHfVT7N7",
        feedtype: "order_feed",
    });
    
    web_socket.connect()
        .then(() => {
            web_socket.fetchData("subscribe", "order_feed");  // ACTION_TYPE: subscribe | unsubscribe FEED_TYPE: order_feed
    
            setTimeout(function () {
                web_socket.close()
            }, 60000)
        });
    
    web_socket.on('tick', receiveTick);
    function receiveTick(data) {
        console.log("receiveTick:::::", data);
    }
    

  • @admin Sure!


  • Dear @NyctoNid we have noted your issue we will get back to you.