Authenticate and initialize SmartConnect
mainTo interact with the Angel trading platform, initialize the SmartConnect class with your api_key. Use pyotp to generate a TOTP (Time-based One-Time Password) from your QR token to authenticate via generateSession.
from SmartApi import SmartConnect
import pyotp
api_key = 'Your Api Key'
username = 'Your client code'
pwd = 'Your pin'
smartApi = SmartConnect(api_key)
token = "Your QR value"
totp = pyotp.TOTP(token).now()
# Authenticate and get session data
data = smartApi.generateSession(username, pwd, totp)
if data['status']:
authToken = data['data']['jwtToken']
refreshToken = data['data']['refreshToken']