Navigation

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

    what am i doing wrong regarding feed token its not generating pardon my amateurness

    Python SDK
    4
    4
    132
    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
      aishvergil last edited by

      feedtoken.PNG

      can someone help me regarding the process

      S 1 Reply Last reply Reply Quote 0
      • S
        shenoytech @aishvergil last edited by

        @RazorFangs

        following is the code for your help.

        # from smartapi.smartSocket import SmartSocket
        # from smartapi import SmartSocket
        from pprint import pprint
        from smartapi.smartConnect import SmartConnect
        from smartapi import SmartConnect
        from smartapi import WebSocket
        
        
        api_key = "your API key"
        client_code = "your Client code"
        password = "your password#"
        
        obj = SmartConnect(api_key=api_key)
        
        data = obj.generateSession(client_code, password)
        tokens = obj.generateToken(data["data"]["refreshToken"])
        feed_token = tokens["data"]["feedToken"]
        
        token = "nse_cm|2885"
        
        ss = WebSocket(feed_token, client_code)
        
        def on_tick(ws, tick):
            print("Ticks: {}".format(tick))
        
        def on_connect(ws, response):
            ws.send_request(token)
        
        
        def on_close(ws, code, reason):
            ws.stop()
        
        # Assign the callbacks.
        ss.on_ticks = on_tick
        ss.on_connect = on_connect
        ss.on_close = on_close
        
        ss.connect()
        
        1 Reply Last reply Reply Quote 0
        • M
          Mohammed last edited by

          From where do we get the "Client Code"?

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

            Hi @Mohammed its the same which you use to login your web based platform.

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