What is public token? and how can I get it?

suraj
Hi,
As per the docs,to get a websocket connection I need to initiate a websocket like below.

WebSocket("your_api_key", "your_public_token", "logged_in_user_id")

I am not getting what is that public token which I need to pass as an argument while initialising? Is it same as request token? If no, can anybody please explain me how can I get public token?
  • suraj
    Thanks kailash. can you please let me know what is the symbol I should use for nifty cash? I am trying to fetch quotes of nifty cash. I used 'NIFTY' and 'NIFTY50' its not working.
  • Vivek
    @suraj Please try 'NIFTY 50'
  • suraj
    @Kailash @vivek To start with, I just modified the example code that is given in documentation like below and tried to run the code. This code didn't receive back any ticks. Can you please have a look at the code. Please correct me if I my code is wrong .

    from kiteconnect import WebSocket

    kws = WebSocket(api_key, public_token, kite_uid) # I changed only this line

    # Callback for tick reception.
    def on_tick(tick, ws):
    print tick

    # Callback for successful connection.
    def on_connect(ws):
    # Subscribe to a list of instrument_tokens (RELIANCE and ACC here).
    ws.subscribe([738561, 5633])

    # Set RELIANCE to tick in `full` mode.
    ws.set_mode(ws.MODE_FULL, [738561])

    # Assign the callbacks.
    kws.on_tick = on_tick
    kws.on_connect = on_connect

    # Infinite loop on the main thread. Nothing after this will run.
    # You have to use the pre-defined callbacks to manage subscriptions.
    kws.connect()

  • Vivek
    @suraj Please don't hijack the thread topic, please open a new thread for new issues.
This discussion has been closed.