This page places a live order

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

Have these ready first (they can take hours or days, so they are not part of the 30 minutes)
  • 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

MinuteStepResult
0-3Read Login in 5 minutes and the "Just do this" boxYou know the path
3-8Credentials: API key, secret, redirect URLAll three in hand
8-12TOTP setupA 6-digit code is being generated
12-18OAuth login → code → checksum → GenAcsTokaccess_token received
18-22UserDetails calluid, actid, exarr, prarr received
22-281-share LMT order far from market → order book → cancelnorenordno, then status CANCELED
28-30Check and bufferFirst trade flow complete

The script (fill 4-5 values)

Open infinn_first_trade.py in any text editor and fill only the top block:

Text
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 ready

Run 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

Text
You can say in one line: link -> login -> code -> token -> API calls.

Common mistakes in this step

You seeWhyFix
Looking for a username/password API callLogin is OAuth onlyUse 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

Text
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 seeWhyFix
Login works in browser but token step failsPrimary IP in the panel is not your current IPCheck "what is my IP", update Primary IP, click Update
Redirect goes to an unexpected pageRedirect URL in the script differs from the panelCopy it exactly, including https:// and trailing path
Spaces in key or secretCopy-paste picked up extra spacesRe-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 enteredUntick 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

Text
Authenticator app shows: INFINN  DEMO123  482 913  (changes every 30 seconds)

Common mistakes in this step

You seeWhyFix
"Invalid OTP"Phone clock is offTurn on automatic date and time on the phone
Code rejected near the end of the 30 sCode expired while typingWait 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

Text
--- GenAcsTok ---
{
"stat": "Ok",
"USERID": "DEMO123",
"uid": "DEMO123",
"actid": "DEMO123",
"access_token": "****9f3c",
"refresh_token": "****77ab",
"susertoken": "****9f3c",
"expires_in": 86400
}
Token received: ****9f3c

The 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 seeWhyFix
stat: Not_OkYour IP is not whitelistedRegister the current IP as Primary IP in Generate Key, then retry
Not_Ok after a slow pasteThe code expired (it lives only seconds)Log in again and paste at once
Invalid checksumWrong secret, or key/secret swappedRe-copy App Key and Secret Code
Invalid checksum though values are rightCode was URL-decoded (e.g. %3D turned into =)Paste the raw address-bar URL; the script does not decode it
Code used twiceEach code works onceLog 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

Text
--- 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 seeWhyFix
Session expired / invalid tokenToken is past ~4 AM IST or from another loginLog in again
actid missing in your own callsactid is required by many callsUse 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

Text
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: CANCELED

Common mistakes in this step

You seeWhyFix
Order rejected: symbol not found& in a symbol like M&M broke the jDataURL-encode the value (M%26M-EQ); the script encodes jData for you
Rejected: outside price band / circuitExchange rejects prices outside the day’s bandUse a price inside the band but still well below the last price
Rejected: market closedOutside market hours and AMO not enabledTry during market hours, or use AMO
Status COMPLETEPrice was too close to the marketNever move the price close; you now hold 1 share
Not_Ok on PlaceOrder onlyOrder from a non-registered IPRun 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

Text
trade.infinn.in > Orders: RELIANCE-EQ  BUY 1 @ 706.20  CANCELED
Positions: none

Common mistakes in this step

You seeWhyFix
Order still OPENCancel failed (network)Cancel it on trade.infinn.in
Esc
↑↓ navigate↵ openEsc close/ to search