On this page

Do this in order

  1. 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.
  2. Register your static IP and create your API keyWhitelisting is mandatory. You create the key yourself. Create your credentials
  3. Log in with OAuth and get a tokenOpen the login URL, copy the code, exchange it at GenAcsTok. Log in with OAuth
  4. Make your first callRead your limits with the example below. Your first request
  5. 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
# 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"))

Four things, in this order. The first two are done by hand in a browser, once; the last two are code.

  1. 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 uid and, for an individual account, your actid as well.
  2. 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.
  3. 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
  4. Any HTTP clientNo SDK is required. curl, Python's requests, Node's built-in fetch, or anything else that can send a POST. 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.

Where your code runs is a design decision, not a detail

Only requests from the registered IP address are accepted. That rules out, or complicates, several common patterns.

Where your code runsWorks?What to know
A cloud VM with a static IPrecommendedThe usual answer. One address, registered once, that never changes. A small instance is enough for API traffic.
An office line with a fixed IPworksFine, provided the address really is static. Confirm with whoever runs the connection rather than assuming.
Home broadbandfragileMost 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 networksnoEvery network change means re-registering. Workable for a day of experimenting, not for anything that runs unattended.
Autoscaling containers or serverlessnoOutbound 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 appnoEvery user has a different IP, and only one is registered. Calls must go through your own server.
The usual answer

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.

ValueWhere it comes fromLifetimeUsed for
Client ID your user IDTop row of the API Key panel. The same ID you log in with.PermanentThe uid field in almost every request body. Also your actid on an individual account.
App KeyThird 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 regeneratedThe api_key in the login URL, and the first part of the checksum. Send the whole thing including _U.
Secret Code the secret keySecond row, masked. The eye icon reveals it; the icon beside it copies it.Until regeneratedThe second part of the checksum. Never transmitted; never put it on a user's device.
Login codeThe ?code= parameter on your redirect URL after logging insingle useExchanged once for an access token. 36 characters with dashes.
Access tokenThe GenAcsTok responseUntil it expires or is invalidatedThe Authorization: Bearer header on every other call. 64 hex characters, no dashes.

Before you start, two warnings

There is no test environment

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.

Your secret key must never reach a user's device

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.

Next

Esc
↑↓ navigate↵ openEsc close/ to search