Before you start
- An Angel One account
Create your Angel One SmartAPI API key
- 1
Sign up on SmartAPI
Register at smartapi.angelbroking.com with your client code.
- 2
Create an app
Create a trading app and copy its API key.
- 3
Enable TOTP
Enable external TOTP and save the base32 secret.
- 4
Store credentials
Save
ANGEL_API_KEY,ANGEL_CLIENT_CODE,ANGEL_PINandANGEL_TOTP_SECRET.
Test the key
Before wiring the key into a strategy, make one request by hand. It separates “the key is wrong” from “my code is wrong”.
# pip install smartapi-python pyotp
import os, pyotp
from SmartApi import SmartConnect
api = SmartConnect(api_key=os.environ["ANGEL_API_KEY"])
print(api.generateSession(os.environ["ANGEL_CLIENT_CODE"], os.environ["ANGEL_PIN"],
pyotp.TOTP(os.environ["ANGEL_TOTP_SECRET"]).now())["status"])True means the login works.Keep the credentials safe
- Store values in a password manager or a git-ignored
.env, never in code or notebooks you share. - In an AlgoGP project you can still add them under APIs & keys (encrypted at rest) and read them with
strategy_runtime.secrets.get("ANGEL_API_KEY"). - Give each bot its own credential so you can revoke one without stopping the others.
ANGEL_API_KEY=paste-your-value-here
ANGEL_CLIENT_CODE=paste-your-value-here
ANGEL_PIN=paste-your-value-here
ANGEL_TOTP_SECRET=paste-your-value-hereDesign and backtest your Angel One SmartAPI strategy first
AlgoGP turns an idea into Python and tests it on years of history before you connect it to Angel One SmartAPI. The exported code keeps the broker behind four small adapter methods.
- AI copilot writes and revises the rules
- Backtests with realistic costs
- Exported Python ready to wire to Angel One SmartAPI
Free plan, no card required.
How the Angel One SmartAPI API works
AlgoGP is not affiliated with Angel One SmartAPI. Menus get renamed from time to time; if a label differs, the official documentation has the current path.