Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    how to connect to websocket and retrieve data

    Bugs
    4
    7
    384
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      akshayavivek06 last edited by

      i am using websocket.org and connecting using the uri provided in api docs.. i generated feed token and sent it to websocket uri as provided in docs.. all i m getting in return is this eJyLrlZKzFayUsrLVtJRKkksBrFzy4Hs3OJ0CLM2FgDEBQq2

      please help

      A 1 Reply Last reply Reply Quote 0
      • A
        admin @akshayavivek06 last edited by

        Hi @akshayavivek06 , please install our NodeJS SDK to establish websocket connection

        https://github.com/angelbroking-github/smartapi-javascript

        A 1 Reply Last reply Reply Quote 0
        • A
          akshayavivek06 @admin last edited by

          @admin I am able to connect to the websocket with help of SDK provided
          please see below my code
          const app = require('express')();
          const http = require('http').Server(app);
          let { WebSocket } = require("smartapi-javascript");

          var msg="";
          let web_socket = new WebSocket({
          client_code: "XX",
          feed_token: "XX",
          script: "nse_cm|1594" //exchange|token for multi stocks use & seperator
          });
          web_socket.connect();
          web_socket.on("tick", receiveTick);

          function receiveTick(data) {
          console.log("Receive stock ticks::", data);
          msg=data.msg;
          }

          app.get('/',function(req, res){
          res.sendFile(__dirname + '/index.html');
          });

          http.listen(8000,function(){
          console.log('listening on *:8000');
          });

          how to get this data streaming in console to show in the index,html ??

          i am new to node js please help

          D 1 Reply Last reply Reply Quote 0
          • D
            Diljeet @akshayavivek06 last edited by

            @akshayavivek06 when you send html file, you need to write code snippet to insert those data into html file.

            This requirement is not part of forum. Please study seperately.

            A 1 Reply Last reply Reply Quote 0
            • A
              akshayavivek06 @Diljeet last edited by

              @mihirk i am trying to learn this.. any video or tutorial if you can direct me to will be great. Thank you appreciate your response

              D 1 Reply Last reply Reply Quote 0
              • D
                Diljeet @akshayavivek06 last edited by

                @akshayavivek06 Please take help of nodeJS tutorials on YouTube. I too learned from those only.

                1 Reply Last reply Reply Quote 0
                • R
                  rohithmaccs last edited by

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post