On this page
Knowing which systems your request passes through explains most of the API's behaviour: why some failures carry no message, why a timeout is not the same as a rejection, and why the rate limit bites before your order is ever seen by a market.
The four parties
Your program
Anything that can make an HTTPS request. There is no required language, framework or SDK.
The Infinn API
The public front door at
api.infinn.in
. It checks your token and your IP address, applies the rate limit, and forwards what is left.
The order management system
Infinn's internal engine. It knows your balance, your positions and your risk limits. It is what decides whether you can afford an order. The error strings beginning
RED:RULE:
come from here.
The exchange
NSE, BSE or MCX. The actual market. It has the final word on whether an order is accepted and whether it trades.
Following one order all the way
- Your program sends the requestA
POSTto/NorenWClientAPI/PlaceOrdercarrying your access token and a JSON body describing the order. - The API checks the doorIs the token valid? Is it from a registered IP address? Have you exceeded 20 orders this second, or 200 this minute? If any answer is no, you get a
401or a429with no body at all, and nothing further happens. - The order management system checks the orderDo you have the margin? Is the price inside the circuit limits? Is this product allowed on this exchange for this account? A failure here comes back as
HTTP 200withstat: "Not_Ok"and anemsgexplaining why. - The exchange receives itIf everything passed, the order is forwarded. You get back
stat: "Ok"and anorenordno- your order number. - The order waits, or tradesThe order number means accepted, not filled. The order now sits in the market until it matches, you cancel it, or the day ends.
- You find out what happenedEither by reading the order book, or - much better - by having subscribed to order updates, which push each change to you as it occurs.
A great many first integrations treat step 4 as the end: order number received, job done, move on. It is not. Between "accepted" and "filled" an order can be rejected by the exchange, partially filled, or left sitting all day.
The order lifecycle page sets out every state and which transitions are possible.
Two kinds of conversation
Infinn offers two quite different ways to get information, and choosing wrongly is the most common performance mistake.
The rule of thumb: if you would otherwise write a loop with a sleep in it, you want the WebSocket.
Where each kind of failure comes from
The layer that rejects you determines the shape of what you get back, which is why one error-handling branch is never enough.
| Code | Meaning | Body |
|---|---|---|
401 | The gateway rejected your credentials before the request reached the trading system. | empty body |
400 | Missing or bad request parameters or values. | |
403 | Session expired or invalidated. Must relogin. | |
404 | The requested resource was not found. | empty body |
405 | The request method is not allowed on this endpoint. | |
410 | The requested resource is gone permanently. | |
429 | Too many requests to the API (rate limiting). | |
500 | Something unexpected went wrong. | |
502 | The backend OMS is down and the API is unable to communicate with it. | |
503 | Service unavailable; the API is down. | |
504 | Gateway timeout; the API is unreachable. |
Full detail, with causes and fixes for each, is on the error reference.
What this means for how you build
Check both layers, every time
Look at the HTTP status, and then look at stat in the body.
Every code sample on this site does both; see
the two error layers.
Treat a timeout as "unknown", not "failed"
If a PlaceOrder call times out, the order may well be live.
Read the order book before retrying, or you will end up with two positions.
Retrying safely
Keep one WebSocket, not many REST loops
A single connection replaces an unbounded number of polling calls and keeps you comfortably inside the rate limit. Worked example
Fix your IP address early
Because the API authorises by IP as well as by token, decide where your code will run before you build around it. A dynamic home IP will stop working without warning. Credentials
Drive your UI from the account's own entitlements
User Details returns the exchanges, products and order types this account may actually use. Hard-coding them instead produces rejections that look like bugs in your own code.