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)
- Go to https://jsonbin.io/login ans signup wth your gmail/github/facebook/twitter account.
- Now Click on Create New
- Now Type
{"enctoken":"abcdefghijklmnopqrstuvwxyz"}
in the text box and click create. - Now Click on the Profile Picture, Then Click on Dashboard
- 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 beBIN_ID = 6129d9bd2aa800361271257f
) - Now Click on the VIEW MASTER KEY
- 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 beYOUR_API_KEY = $2b$10$IIWfEN3l97/jWpsxjBli0eUQopUdqzt0Ksx9dl87xGINSKxCesLte
) - 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)
- Once TamperMonkey has been added to chrome click the extension button and find tampermonkey and click on pin so it should be visible
- Now open SaveKiteEnctoken.user.js and click Install when prompted
- Now Open https://kite.zerodha.com/ and you will see the TamperMonkey Icon has a red notification with 1 written on it.
- Click on It, and then click on the setting below SaveKiteEnctoken
- 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.
- Now Login to kite as usual, and the enctoken will automatically be updated.
###############################################################################
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)
#################################################################################