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


  • feedtoken.PNG

    can someone help me regarding the process


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


  • From where do we get the "Client Code"?


  • @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()