On this page
Do this in order
- Open an INFINN account and turn on TOTPYou need a funded account at trade.infinn.in. Set up TOTP; the login page asks for it.
- Register your static IP and create your API keyWhitelisting is mandatory. You create the key yourself. Create your credentials
- Log in with OAuth and get a tokenOpen the login URL, copy the code, exchange it at GenAcsTok. Log in with OAuth
- Make your first callRead your limits with the example below. Your first request
- Place a safe test orderOne share, far from the market, then cancel it. Place your first order safely
A tiny runnable example
After step 3, set INFINN_ACCESS_TOKEN and INFINN_USER_ID, then run either program. It prints your cash.
# first_call.py -- the smallest useful call: read your cash limits.
# pip install requests
# INFINN_ACCESS_TOKEN=... INFINN_USER_ID=IN001 python first_call.py
import json, os, requests
BASE = os.environ.get("INFINN_BASE", "https://api.infinn.in")
TOKEN = os.environ["INFINN_ACCESS_TOKEN"]
UID = os.environ.get("INFINN_USER_ID", "IN001")
res = requests.post(BASE + "/NorenWClientAPI/Limits",
headers={"Authorization": f"Bearer {TOKEN}", "Content-Type": "text/plain"},
data="jData=" + json.dumps({"uid": UID, "actid": UID}), timeout=15)
res.raise_for_status() # layer 1: HTTP
data = res.json()
if data.get("stat") != "Ok": # layer 2: application
raise SystemExit(data.get("emsg"))
print("Cash:", data.get("cash"))// first_call.js -- the smallest useful call: read your cash limits (Node 18+).
// INFINN_ACCESS_TOKEN=... INFINN_USER_ID=IN001 node first_call.js
const BASE = process.env.INFINN_BASE || 'https://api.infinn.in';
const TOKEN = process.env.INFINN_ACCESS_TOKEN;
const UID = process.env.INFINN_USER_ID || 'IN001';
(async () => {
const res = await fetch(BASE + '/NorenWClientAPI/Limits', {
method: 'POST',
headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'text/plain' },
body: 'jData=' + JSON.stringify({ uid: UID, actid: UID }),
});
if (res.status !== 200) throw new Error(`HTTP ${res.status}`); // layer 1: HTTP
const data = await res.json();
if (data.stat !== 'Ok') throw new Error(data.emsg); // layer 2: application
console.log('Cash:', data.cash);
})().catch((err) => { console.error(err.message); process.exit(1); });Four things, in this order. The first two are done by hand in a browser, once; the last two are code.
- An active Infinn trading accountYou need a funded account at trade.infinn.in that you can log into. The API acts as that account: there is no separate developer account and no demo account. Your login ID is also your
uidand, for an individual account, youractidas well. - A static, known public IP addressInfinn authorises requests by IP address as well as by token. You register one address, and calls from anywhere else are refused - with no explanation. Find your current address at api.ipify.org. Decide now where your code will run, because this constrains the answer more than anything else on this page.
- API credentialsAn app key and a secret key, generated in the Infinn terminal under Profile → Generate Key. These are not your password and not your user ID. Step-by-step, with pictures
- Any HTTP clientNo SDK is required.
curl, Python'srequests, Node's built-infetch, or anything else that can send aPOST. Official client libraries exist for six languages if you prefer one.
The IP address requirement, before you build around it
This single constraint shapes more architectures than anything else in the API, so it is worth confronting now rather than discovering later.
Only requests from the registered IP address are accepted. That rules out, or complicates, several common patterns.
| Where your code runs | Works? | What to know |
|---|---|---|
| A cloud VM with a static IP | recommended | The usual answer. One address, registered once, that never changes. A small instance is enough for API traffic. |
| An office line with a fixed IP | works | Fine, provided the address really is static. Confirm with whoever runs the connection rather than assuming. |
| Home broadband | fragile | Most residential connections reassign the address periodically. It will work until it silently does not, and the symptom is a 403. |
| A laptop that moves between networks | no | Every network change means re-registering. Workable for a day of experimenting, not for anything that runs unattended. |
| Autoscaling containers or serverless | no | Outbound addresses vary per instance. You would need a NAT gateway with a fixed address, and to route all API traffic through it. |
| An end-user mobile or web app | no | Every user has a different IP, and only one is registered. Calls must go through your own server. |
Put the API-facing part of your system on one small server with a static IP, and have everything else talk to that. It keeps one address registered, it keeps your secret key off end-user devices, and it means a laptop moving between networks never breaks anything.
What you will have at the end
By the end of this section you will hold four values. Three are long-lived; one is not.
| Value | Where it comes from | Lifetime | Used for |
|---|---|---|---|
| Client ID your user ID | Top row of the API Key panel. The same ID you log in with. | Permanent | The uid field in almost every request body. Also your actid on an individual account. |
| App Key | Third row of the same panel. It is your client ID with _U appended - a client ID of IN001 gives an app key of IN001_U. | Until regenerated | The api_key in the login URL, and the first part of the checksum. Send the whole thing including _U. |
| Secret Code the secret key | Second row, masked. The eye icon reveals it; the icon beside it copies it. | Until regenerated | The second part of the checksum. Never transmitted; never put it on a user's device. |
| Login code | The ?code= parameter on your redirect URL after logging in | single use | Exchanged once for an access token. 36 characters with dashes. |
| Access token | The GenAcsTok response | Until it expires or is invalidated | The Authorization: Bearer header on every other call. 64 hex characters, no dashes. |
Before you start, two warnings
Every call you make runs against your real account. An order placed from a code sample is a real order for real money.
Until you are confident, use a limit order for one share of a liquid stock at a price far from the market, so it rests in the order book without trading, and cancel it immediately. The safe-ordering guide does exactly this.
The secret key is used to compute a checksum during login. It should live on a server you control, or in a local script on your own machine - never in a mobile app bundle, a browser page, or a public repository. Anyone with your app key and secret key can mint tokens for your account.