TechfaneTechnologies / SaveKiteEnctoken

Save KiteEnctoken to jsonbin.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SaveKiteEnctoken

The Script Save KiteEnctoken to jsonbin.io, which can be used to synchronized Kite Enctoken between your local pc/laptop browser and Algo Trading Code at Remote Servers.

To set it up for the first time, you need to follow these steps. (Once all the steps completed, from next login onwards it will work automatically)

Browser Setup
  1. Go to https://jsonbin.io/login ans signup wth your gmail/github/facebook/twitter account. image
  2. Now Click on Create New image
  3. Now Type {"enctoken":"abcdefghijklmnopqrstuvwxyz"} in the text box and click create. image
  4. Now Click on the Profile Picture, Then Click on Dashboard image
  5. Now Copy the 24 Charachter long BIN_ID and save it on a notepad as BIN_ID = <PASTE 24 Charachter BIN_ID HERE> (For Example in this case it shall be BIN_ID = 6129d9bd2aa800361271257f) image
  6. Now Click on the VIEW MASTER KEY image
  7. And Copy the 60 Character long Master Key by clicking on COPY KEY and save it on a notepad as YOUR_API_KEY = <PASTE 60 Charachter Master Key HERE> (For Example in this case it shall be YOUR_API_KEY = $2b$10$IIWfEN3l97/jWpsxjBli0eUQopUdqzt0Ksx9dl87xGINSKxCesLte) image
  8. Now You may close the jsonbin.io website and open https://www.tampermonkey.net/ and download for chrome/firefox/edge/safari (whatever you use, In my case i will download for chrome) image image
  9. Once TamperMonkey has been added to chrome click the extension button and find tampermonkey and click on pin so it should be visible image image
  10. Now open SaveKiteEnctoken.user.js and click Install when prompted image
  11. Now Open https://kite.zerodha.com/ and you will see the TamperMonkey Icon has a red notification with 1 written on it. image
  12. Click on It, and then click on the setting below SaveKiteEnctoken image
  13. Now Fill the Your Api Key with the MASTER KEY Saved in Point No. 7 and Bin id with the BIN ID saved in Point No.5 and then click on save. image
  14. Now Login to kite as usual, and the enctoken will automatically be updated.
Python Program Modification for obtaining enctoken automatically.
###############################################################################
import requests

def get_enctoken(YOUR_API_KEY, BIN_ID):
    enctoken_url = "https://api.jsonbin.io/v3/b/"+BIN_ID+"/latest"
    headers = {
        'X-Master-Key': YOUR_API_KEY
    }
    req = requests.get(enctoken_url, json=None, headers=headers)
    enctoken = req.json()['record']['enctoken']
    return enctoken

YOUR_API_KEY = <PASTE 60 Charachter Master Key HERE from Point No.7>
BIN_ID = <PASTE 24 Charachter BIN_ID HERE from point No. 5>
enctoken = get_enctoken(YOUR_API_KEY, BIN_ID)

#################################################################################
  # For Example in our case it will be
  # YOUR_API_KEY = "$2b$10$IIWfEN3l97/jWpsxjBli0eUQopUdqzt0Ksx9dl87xGINSKxCesLte"
  # BIN_ID = "6129d9bd2aa800361271257f"
  # enctoken = get_enctoken(YOUR_API_KEY, BIN_ID)
#################################################################################
  1. Hence, For Example if you want to run your code from colab just do like this and it wont log you out of your browser session. (and when your browser session expires and you relogin, the enctoken will automatically be updated and your algo code will work as intended without interruption) image

Disclaimer: I have made this tool for my personal use and it may have bugs.

About

Save KiteEnctoken to jsonbin.io

License:MIT License


Languages

Language:JavaScript 100.0%