Navigation

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

    How to get the live data from market feed for different stocks ?

    Bugs
    3
    19
    296
    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
      admin @Jeet Pattani last edited by

      Hi @Jeet-Pattani You need to call login api to get the tokens.

      1 Reply Last reply Reply Quote 0
      • J
        Jeet Pattani last edited by

        var axios = require('axios');
        var data = JSON.stringify({
            "clientcode": "jety2619@gmail.com",
            "password": "Info@money1411"
        });
        
        var config = {
            method: 'post',
            url: 'https://apiconnect.angelbroking.com//rest/auth/angelbroking/user/v1/loginByPassword',
        
            headers: {
                'Content-Type': 'application/json',
                'Accept': 'application/json',
                'X-UserType': 'USER',
                'X-SourceID': 'WEB',
                'X-ClientLocalIP': 'CLIENT_LOCAL_IP',
                'X-ClientPublicIP': 'CLIENT_PUBLIC_IP',
                'X-MACAddress': 'MAC_ADDRESS',
                'X-PrivateKey': 'vtJ7Ks0m'
            },
            data: data
        };
        
        axios(config)
            .then(function(response) {
                console.log(JSON.stringify(response.data));
            })
            .catch(function(error) {
                console.log(error);
            });
        

        I entered the code given to login but it shows this error

        {"status":false,"message":"YOUR USER ID OR PASSWORD IS INVALID","errorcode":"AB1007","data":null}

        I tried it with both api key and secret key.

        Please tell me how to fix this.

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

          @Jeet-Pattani said in How to get the live data from market feed for different stocks ?:

          I entered the code given to login but it shows this error
          {"status":false,"message":"YOUR USER ID OR PASSWORD IS INVALID","errorcode":"AB1007","data":null}
          I tried it with both api key and secret key.
          Please tell me how to fix this.

          Have you migrated your account.

          J 1 Reply Last reply Reply Quote 0
          • J
            jety_22 @admin last edited by

            @admin

            var websocket = require(WebSocket);
            let web_socket = new WebSocketClient({
               clientcode: "P529774",
               jwttoken: "eyJhbGciOiJIUzUxMiJ9.eyJ1c2VybmFtZSI6IlA1Mjk3NzQiLCJyb2xlcyI6MCwidXNlcnR5cGUiOiJVU0VSIiwiaWF0IjoxNjM4ODUyODY1LCJleHAiOjE3MjUyNTI4NjV9.ExqXu3cKYv2xh1hAlbI2xZHknfF1ZwfbPDu7cIKM0ljRQM5nUn1wmCOFdirEwLRzQxM-G6CsfmlDYkaMED_uIg",
               apikey: "erZDHFHD",
               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);
            }
            

            I am not able to connect to websocket. I am getting the error as below.

            node:internal/validators:119
                throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
                ^
            
            TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received function WebSocket
                at new NodeError (node:internal/errors:371:5)
                at validateString (node:internal/validators:119:11)
                at Module.require (node:internal/modules/cjs/loader:998:3)
                at require (node:internal/modules/cjs/helpers:102:18)
                at Object.<anonymous> (d:\home page\smart api\test.js:35:17)
                at Module._compile (node:internal/modules/cjs/loader:1101:14)
                at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
                at Module.load (node:internal/modules/cjs/loader:981:32)
                at Function.Module._load (node:internal/modules/cjs/loader:822:12)
                at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
              code: 'ERR_INVALID_ARG_TYPE'
            }
            

            Is there a requirement to get any other websocket client?

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

              @jety_22 please go through below doc
              https://smartapi.angelbroking.com/docs/WebSocketStreaming

              J 2 Replies Last reply Reply Quote 0
              • J
                Jeet Pattani @admin last edited by

                @admin There is no clear mention on how to connect to the websocket.

                A 1 Reply Last reply Reply Quote 0
                • J
                  Jeet Pattani @admin last edited by

                  @admin I also used the wss url but it still showed error.

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

                    @Jeet-Pattani said in How to get the live data from market feed for different stocks ?:

                    @admin There is no clear mention on how to connect to the websocket.

                    post your client id here our team will connect you.

                    J 1 Reply Last reply Reply Quote 0
                    • J
                      jety_22 @admin last edited by

                      @admin CLIENT ID P529774
                      PHONE 8460920114
                      PLEASE CONTACT ASAP

                      1 Reply Last reply Reply Quote 0
                      • J
                        jety_22 last edited by

                        This post is deleted!
                        A 2 Replies Last reply Reply Quote 0
                        • A
                          admin @jety_22 last edited by

                          Hi @jety_22 Dont expose your password publicly.

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

                            @jety_22 as cordinated with the team our team is working on web socket we will update you on this.

                            1 Reply Last reply Reply Quote 0
                            • J
                              jety_22 @admin last edited by

                              @admin I connected using websocket.

                              let { SmartAPI, WebSocket } = require("smartapi-javascript");
                              
                              
                              let web_socket = new WebSocket({
                                  client_code: "P529774",
                                  feed_token: "097948399"
                              });
                              
                              web_socket.connect()
                                  .then(() => {
                                      web_socket.runScript("nse_cm|2885", "cn")// SCRIPT: nse_cm|2885, mcx_fo|222900  TASK: mw|sfi|dp
                                      web_socket.runScript("nse_cm|2885", "mw")
                                      setTimeout(function() {
                                          web_socket.close()
                                      }, 3000)
                                  })
                              
                              web_socket.on('tick', receiveTick)
                              
                              
                              function receiveTick(data) {
                                  console.log("receiveTick:::::", data)
                              }
                              

                              But I am getting the following response.

                              receiveTick::::: [ { ak: 'ok', task: 'cn', msg: 'connected' } ]
                              receiveTick::::: []
                              receiveTick::::: [ { tvalue: '07/12/2021 16:19:25', name: 'tm' } ]
                              receiveTick::::: [ { tvalue: '07/12/2021 16:19:26', name: 'tm' } ]
                              receiveTick::::: [ { tvalue: '07/12/2021 16:19:27', name: 'tm' } ]
                              Socket closed
                              

                              will it send response during market hours only?

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post