Practise login on Sandbox (UAT / Test — NOT live) first. The order on this page hits your real account. It uses a 1-share limit priced far below the market, so it cannot fill, and then cancels it. The script is a dry run until you change one line and type YES.
Before the clock starts
- An active trading account with INFINN that you can log in to on trade.infinn.in.
- A TOTP app (Google Authenticator, Microsoft Authenticator or similar) on your phone.
- API key approved for your account.
- Static IP registered: trade.infinn.in → log in → top-right profile icon → Generate Key → API Key panel → fill Display Name, Redirect URL and Primary IP → Update. Find your IP by searching "what is my IP" on the computer that will run the script. See Login in 5 minutes for pictures.
- Market open (NSE cash 9:15 AM-3:30 PM IST), or AMO (after-market order) enabled on your account.
- Python 3.8 or newer installed. Download the script: infinn_first_trade.py.
The 30-minute plan
| Minute | Step | Result |
|---|---|---|
| 0-3 | Read Login in 5 minutes and the "Just do this" box | You know the path |
| 3-8 | Credentials: API key, secret, redirect URL | All three in hand |
| 8-12 | TOTP setup | A 6-digit code is being generated |
| 12-18 | OAuth login → code → checksum → GenAcsTok | access_token received |
| 18-22 | UserDetails call | uid, actid, exarr, prarr received |
| 22-28 | 1-share LMT order far from market → order book → cancel | norenordno, then status CANCELED |
| 28-30 | Check and buffer | First trade flow complete |
The script (fill 4-5 values)
Open infinn_first_trade.py in any text editor and fill only the top block:
USER_ID = "YOUR_USER_ID"
API_KEY = "YOUR_API_KEY" # App Key
SECRET = "YOUR_SECRET_CODE" # Secret Code
REDIRECT_URL = "https://example.com/callback" # exactly as saved
SYMBOL = "RELIANCE-EQ" # optional
DRY_RUN = True # change to False only when readyRun it with python infinn_first_trade.py (or python3). It uses only the Python standard library. Secrets are never printed in full.
0-3 min — Read the path
Skim Login in 5 minutes. The whole flow is: open a login link → log in → copy the code from the address bar → swap it for a token → call the API with Authorization: Bearer <token>.
What success looks like
You can say in one line: link -> login -> code -> token -> API calls.Common mistakes in this step
| You see | Why | Fix |
|---|---|---|
| Looking for a username/password API call | Login is OAuth only | Use the browser login link; there is no password API |
3-8 min — Credentials
On trade.infinn.in → profile icon → Generate Key, copy the App Key (your API_KEY) and Secret Code (your SECRET), and note the Redirect URL you saved. Paste them into the script top block.
What success looks like
USER_ID = "DEMO123"
API_KEY = "DEMO123_U"
SECRET = "****a1b2" (yours is longer; never share it)
REDIRECT_URL = "https://example.com/callback"Common mistakes in this step
| You see | Why | Fix |
|---|---|---|
| Login works in browser but token step fails | Primary IP in the panel is not your current IP | Check "what is my IP", update Primary IP, click Update |
| Redirect goes to an unexpected page | Redirect URL in the script differs from the panel | Copy it exactly, including https:// and trailing path |
| Spaces in key or secret | Copy-paste picked up extra spaces | Re-copy; the script uses values exactly as typed |
| Update fails or is incomplete | "Applicable for more than 10 orders per second" is ticked but no exchange-approved algo IDs were entered | Untick it if you need 10 orders per second or fewer; otherwise select the exchanges and fill each "Algo ID for <EXCHANGE>" field |
8-12 min — TOTP setup
Follow TOTP setup to add INFINN to your authenticator app. You need the 6-digit code at login.
What success looks like
Authenticator app shows: INFINN DEMO123 482 913 (changes every 30 seconds)Common mistakes in this step
| You see | Why | Fix |
|---|---|---|
| "Invalid OTP" | Phone clock is off | Turn on automatic date and time on the phone |
| Code rejected near the end of the 30 s | Code expired while typing | Wait for a fresh code and type it at once |
12-18 min — OAuth login → code → checksum → GenAcsTok
Run the script. It prints and opens a login link (https://api.infinn.in/OAuthlogin/investor-entry-level/login?api_key=...&route_to=..., where route_to = sha256(USER_ID|SECRET)). Log in with password and TOTP. The browser then goes to your Redirect URL with ?code=... at the end. The page itself may show an error — that is fine. Copy the whole address bar, paste it into the script, press Enter immediately. The script computes checksum = sha256(API_KEY + SECRET + code) and calls GenAcsTok.
What success looks like
--- GenAcsTok ---
{
"stat": "Ok",
"USERID": "DEMO123",
"uid": "DEMO123",
"actid": "DEMO123",
"access_token": "****9f3c",
"refresh_token": "****77ab",
"susertoken": "****9f3c",
"expires_in": 86400
}
Token received: ****9f3cThe expires_in value above is a dummy; in practice the token works until about 4 AM IST the next morning.
Common mistakes in this step
| You see | Why | Fix |
|---|---|---|
stat: Not_Ok | Your IP is not whitelisted | Register the current IP as Primary IP in Generate Key, then retry |
Not_Ok after a slow paste | The code expired (it lives only seconds) | Log in again and paste at once |
| Invalid checksum | Wrong secret, or key/secret swapped | Re-copy App Key and Secret Code |
| Invalid checksum though values are right | Code was URL-decoded (e.g. %3D turned into =) | Paste the raw address-bar URL; the script does not decode it |
| Code used twice | Each code works once | Log in again for a new code |
18-22 min — UserDetails
The script calls UserDetails with your token (jData={"uid":"..."} plus Authorization: Bearer).
What success looks like
--- UserDetails ---
{
"stat": "Ok",
"uid": "DEMO123",
"actid": "DEMO123",
"uname": "DEMO USER",
"exarr": ["NSE", "BSE", "NFO"],
"prarr": [{"prd": "C", "s_prdt_ali": "CNC"}, {"prd": "I", "s_prdt_ali": "MIS"}]
}Common mistakes in this step
| You see | Why | Fix |
|---|---|---|
| Session expired / invalid token | Token is past ~4 AM IST or from another login | Log in again |
actid missing in your own calls | actid is required by many calls | Use actid = your uid |
22-28 min — 1-share LMT order far from market → order book → cancel
The script looks up the last price of SYMBOL, sets a limit price at half of it, and shows the order. With DRY_RUN = True it stops there. To send it, set DRY_RUN = False, run again, and type YES. It then places the order, shows it in the order book, and cancels it (the cancel runs even if something fails in between).
What success looks like
Last price 1412.40 -> safe limit price 706.2 (far below market)
Type YES to send this REAL order (anything else cancels): YES
--- PlaceOrder ---
{ "stat": "Ok", "norenordno": "26101600000123" }
--- OrderBook (this order) ---
[ { "norenordno": "26101600000123", "tsym": "RELIANCE-EQ", "qty": "1", "prc": "706.20", "status": "OPEN" } ]
--- CancelOrder ---
{ "stat": "Ok", "result": "26101600000123" }
Final status: CANCELEDCommon mistakes in this step
| You see | Why | Fix |
|---|---|---|
| Order rejected: symbol not found | & in a symbol like M&M broke the jData | URL-encode the value (M%26M-EQ); the script encodes jData for you |
| Rejected: outside price band / circuit | Exchange rejects prices outside the day’s band | Use a price inside the band but still well below the last price |
| Rejected: market closed | Outside market hours and AMO not enabled | Try during market hours, or use AMO |
| Status COMPLETE | Price was too close to the market | Never move the price close; you now hold 1 share |
Not_Ok on PlaceOrder only | Order from a non-registered IP | Run from the static IP registered in Generate Key |
28-30 min — Check
Open the order book on trade.infinn.in and confirm the test order shows CANCELED and no position or holding was created.
What success looks like
trade.infinn.in > Orders: RELIANCE-EQ BUY 1 @ 706.20 CANCELED
Positions: noneCommon mistakes in this step
| You see | Why | Fix |
|---|---|---|
| Order still OPEN | Cancel failed (network) | Cancel it on trade.infinn.in |