Member-only story

Coding Time Compression Scanners: Zerodha API Basics I

Amit Kumar Ghosh
4 min readSep 20, 2023

--

Getting Instrument Token of a Scrip Using Python and Zerodha Kite LTP Method

The KiteConnect APIs

We shall be using Zerodha’s Kite Connect API to back-test the given dataset. We’re a Zerodha Partner and if you’ve signed up with Unofficed, then You’ll get access to the raw file used to make this tutorial.

Kite Connect offers REST-like HTTP APIs with a wide range of capabilities that will suffice our needs.

Step 1 — Initialization of Kite Object

As You can see from the example of KiteConnect Python API from Zerodha’s GitHub, the Step 1 is to create the Kite object

import logging
from kiteconnect import KiteConnect

logging.basicConfig(level=logging.DEBUG)

kite = KiteConnect(api_key="your_api_key")

# Redirect the user to the login url obtained
# from kite.login_url(), and receive the request_token
# from the registered redirect url after the login flow.
# Once you have the request_token, obtain the access_token
# as follows.

data = kite.generate_session("request_token_here", api_secret="your_secret")
kite.set_access_token(data["access_token"])

Discussion on Kite Historical Data Syntax

--

--

Amit Kumar Ghosh
Amit Kumar Ghosh

Written by Amit Kumar Ghosh

Aloha, I’m Amit Ghosh, a web entrepreneur and avid blogger. Bitten by entrepreneurial bug, I got kicked out from college and ended up being millionaire!

No responses yet