On this page
We will call User Details. It is the right first call for three reasons: it changes nothing, it needs only your user ID, and its answer tells you what the rest of your integration is allowed to do.
It reads. It places no orders, moves no money and alters no state. You can run it as often as you like - within the rate limit.
What you need
- An access token from authentication.
- Your user ID - the ID you log into
trade.infinn.inwith. - To be running on the machine whose IP you registered.
The request, part by part
POST /NorenWClientAPI/UserDetails HTTP/1.1
Host: api.infinn.in
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: text/plain
jData={"uid":"IN001"}Five lines, and every one matters.
| Line | What it is | Why it must be exactly this |
|---|---|---|
POST /NorenWClientAPI/UserDetails | Method and path | Every Infinn endpoint is POST, including the ones that only read. A GET returns 405. |
Host: api.infinn.in | The server | The only host. HTTPS only. Your HTTP client adds this for you. |
Authorization: Bearer … | Who you are | The word Bearer, one space, then the token. Missing or wrong gives an empty 401. |
Content-Type: text/plain | The body format | Not application/json. Not x-www-form-urlencoded. Getting this wrong gives a 400 with no explanation. |
jData={"uid":"…"} | What you are asking | One form field named jData, whose value is a JSON string. Not a JSON document. |
Not application/json, even though the body contains JSON. Not application/x-www-form-urlencoded, even though the body looks like a form field.
This is unusual - most APIs would use one of those - and getting it wrong produces a 400 that gives no hint as to why. Why it is this way
Run it
Pick a language. Each of these is complete: paste it, replace the two placeholder values, run it.
# Replace both placeholders, then run.
curl --request POST \
--url 'https://api.infinn.in/NorenWClientAPI/UserDetails' \
--header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
--header 'Content-Type: text/plain' \
--data 'jData={"uid":"IN001"}'
# Add -i to see the status code and headers as well as the body:
# curl -i --request POST ..."""First Infinn API request: read the account's entitlements.
Requires: pip install requests
"""
import json
import os
import requests
ACCESS_TOKEN = os.environ.get("INFINN_ACCESS_TOKEN", "YOUR_ACCESS_TOKEN")
UID = os.environ.get("INFINN_USER_ID", "IN001")
response = requests.post(
"https://api.infinn.in/NorenWClientAPI/UserDetails",
headers={
"Authorization": f"Bearer {ACCESS_TOKEN}",
"Content-Type": "text/plain",
},
data="jData=" + json.dumps({"uid": UID}),
timeout=10,
)
# ---- Layer 1: did the message get through? --------------------------------
# A rejected token or an unregistered IP gives 401 with an EMPTY body, so
# calling .json() first would raise a confusing decode error instead.
if response.status_code != 200:
raise SystemExit(
f"HTTP {response.status_code}. "
"If this is 401, check the token AND that this machine's public IP "
"is the one registered on your Infinn profile."
)
data = response.json()
# ---- Layer 2: did the thing you asked for actually happen? ---------------
if data.get("stat") != "Ok":
raise SystemExit(f"API error: {data.get('emsg', data)}")
# ---- Use the answer ------------------------------------------------------
print("Account: ", data.get("actid"))
print("Exchanges:", ", ".join(data.get("exarr", [])))
print("Order types:", ", ".join(data.get("orarr", [])))
print("Products:")
for product in data.get("prarr", []):
allowed = ", ".join(product.get("exch", []))
print(f" {product['prd']} {product['s_prdt_ali']:<16} {allowed}")/**
* First Infinn API request: read the account's entitlements.
* Node 18+ (global fetch) -- no dependencies.
*/
const ACCESS_TOKEN = process.env.INFINN_ACCESS_TOKEN || 'YOUR_ACCESS_TOKEN';
const UID = process.env.INFINN_USER_ID || 'IN001';
async function main() {
const response = await fetch(
'https://api.infinn.in/NorenWClientAPI/UserDetails',
{
method: 'POST',
headers: {
Authorization: `Bearer ${ACCESS_TOKEN}`,
'Content-Type': 'text/plain',
},
body: 'jData=' + JSON.stringify({ uid: UID }),
},
);
// ---- Layer 1: transport -------------------------------------------------
// 401 arrives with an empty body, so check the status before parsing.
if (!response.ok) {
throw new Error(
`HTTP ${response.status}. If this is 401, check the token AND that ` +
`this machine's public IP is registered on your Infinn profile.`,
);
}
const data = await response.json();
// ---- Layer 2: application ----------------------------------------------
if (data.stat !== 'Ok') {
throw new Error(`API error: ${data.emsg || JSON.stringify(data)}`);
}
// ---- Use the answer -----------------------------------------------------
console.log('Account: ', data.actid);
console.log('Exchanges: ', (data.exarr || []).join(', '));
console.log('Order types:', (data.orarr || []).join(', '));
console.log('Products:');
for (const p of data.prarr || []) {
console.log(` ${p.prd} ${p.s_prdt_ali.padEnd(16)} ${(p.exch || []).join(', ')}`);
}
}
main().catch((err) => {
console.error(err.message);
process.exit(1);
});<?php
/**
* First Infinn API request: read the account's entitlements.
* PHP 7.4+ with the cURL extension.
*/
$accessToken = getenv('INFINN_ACCESS_TOKEN') ?: 'YOUR_ACCESS_TOKEN';
$uid = getenv('INFINN_USER_ID') ?: 'IN001';
$ch = curl_init('https://api.infinn.in/NorenWClientAPI/UserDetails');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $accessToken,
'Content-Type: text/plain',
],
CURLOPT_POSTFIELDS => 'jData=' . json_encode(['uid' => $uid]),
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// Layer 1: transport. A error responses have an empty body.
if ($status !== 200) {
fwrite(STDERR, "HTTP {$status}. If 401, check the token and your registered IP.\n");
exit(1);
}
$data = json_decode($body, true);
// Layer 2: application.
if (($data['stat'] ?? '') !== 'Ok') {
fwrite(STDERR, 'API error: ' . ($data['emsg'] ?? $body) . "\n");
exit(1);
}
printf("Account: %s\n", $data['actid'] ?? '');
printf("Exchanges: %s\n", implode(', ', $data['exarr'] ?? []));
printf("Order types: %s\n", implode(', ', $data['orarr'] ?? []));The response, part by part
A successful call looks like this.
{
"request_time": "20:20:04 19-05-2020",
"stat": "Ok",
"exarr": ["NSE", "NFO"],
"orarr": ["MKT", "LMT", "SL-LMT", "SL-MKT", "DS", "2L", "3L", "4L"],
"prarr": [
{ "prd": "C", "s_prdt_ali": "Delivery", "exch": ["NSE", "BSE"] },
{ "prd": "I", "s_prdt_ali": "Intraday", "exch": ["NSE", "BSE", "NFO"] },
{ "prd": "H", "s_prdt_ali": "High Leverage", "exch": ["NSE", "BSE", "NFO"] },
{ "prd": "B", "s_prdt_ali": "Bracket Order", "exch": ["NSE", "BSE", "NFO"] }
],
"brkname": "VIDYA",
"brnchid": "VIDDU",
"email": "user@example.com",
"actid": "IN001",
"uprev": "INVESTOR"
}| Field | What it tells you |
|---|---|
stat | Check this first. Ok means the request succeeded. The HTTP status alone does not tell you this - see the two error layers. |
exarr | Exchanges this account may trade. Use it to populate your exchange dropdown. |
orarr | Order types enabled. Note that the sample includes 4L, which is not in the documented prctyp list - trust this array. |
prarr | Products enabled, each with the exchanges it is allowed on. Show s_prdt_ali to the user; send prd. |
actid | Your account ID. Send it as actid on the endpoints that want one. |
uprev | Always INVESTOR. The documentation notes that no other user type may log in through this API. |
request_time | When Infinn processed the request, as HH:MM:SS dd-mm-yyyy in IST. |
Those three arrays are the correct source for your order form. exarr populates the exchange dropdown, orarr the order types, and prarr the products - showing s_prdt_ali to the user and sending prd.
Hard-coding them instead produces rejections on accounts with different entitlements, and those look exactly like bugs in your own code.
If it did not work
Work down this list in order. It is ordered by how often each cause is the real one.
| What you saw | Most likely cause | What to do |
|---|---|---|
401, empty body | This machine's public IP is not the registered one. This is the most common cause, and almost nobody checks it first. | Run curl -s https://api.ipify.org and compare with Primary IP Address on your profile. Update it |
401, and the IP is correct | A malformed or expired token. | Check the header is Bearer <token> exactly. Confirm you are sending the 64-character access token, not the 36-character login code. Then get a fresh token. |
400 | The content type, or malformed JSON. | Send Content-Type: text/plain, and serialise with a JSON library rather than building the string by hand. |
404 | A typo in the path. These are case-sensitive. | Copy it from the endpoint page. UserDetails, not userdetails. |
405 | You used GET. | Use POST. All 58 endpoints are POST. |
200 with stat: "Not_Ok" | The request arrived and was declined. Read emsg. | Look the message up in the error reference. |
| A JSON decode error in your own code | You parsed before checking the status. A 401 has an empty body, so there is nothing to parse. | Check response.status_code before calling .json(). |
| Connection timed out | Network, or a firewall blocking outbound HTTPS. | Test with curl -sI https://api.infinn.in from the same machine. |
Anything not covered here is in the error reference, or run through the debugging checklist.