Your order is placed. How do you know when it is filled? There are two main ways: keep asking, or get told. In technical words, these are REST and WebSocket.
REST: you ask, it answers
With REST, your program sends a request, and the server sends one reply. It is like calling a shop to ask, “Is my order ready?”
- Simple and works everywhere
- Good for placing orders, changing them and cancelling them
- If you keep asking again and again for updates (polling), it wastes time and requests
WebSocket: one open line
With a WebSocket, your program opens a connection once, and the server sends updates as soon as something changes. It is like the shop calling you when your order is ready.
- Updates arrive without asking
- Good for live orders, positions and funds
- You must handle disconnects and reconnect
Webhooks: the server calls you
A webhook is a message that the server sends to your own server when an event happens. It is useful when you want your system to react, for example when an order is filled.
Which one to use?
Need | Best choice |
Place, modify or cancel an order | REST |
See live orders, positions and funds | WebSocket |
Let your server react to events | Webhook |
How Cirrus works
Cirrus offers all three, using plain HTTPS and JSON.
REST API
- One call can send an order to many accounts. Send an Idempotency-Key so a retry never doubles an order.
- Limits: 20 requests a second per API key, and 10 order actions a second per broker account, in line with SEBI’s threshold for retail API orders. Short bursts wait up to two seconds instead of failing.
Live stream (WebSocket)
- One WebSocket at /v1/stream sends your orders, positions, holdings and funds as they change, without polling.
- It first sends a snapshot of everything, then every change.
- Every message has a sequence number. If you notice a gap, ask for a fresh snapshot with a resync message.
- Changes carry the full state, never just a difference, so a missed message is fixed by the next one.
- The server pings every 15 seconds. If you fall too far behind, it closes the connection, and you reconnect.
Webhooks
- Events: order_update for every state change, trade for each fill, positions when positions change, and account_alert for things like an expired session or a rejected order.
- Each delivery is signed with HMAC-SHA256 in the Standard Webhooks format.
- Failed deliveries are retried seven times over about four hours, and you can see every attempt in the app.
- You can set up to five endpoints per user.
Cirrus works with 15 brokers, including Zerodha, Upstox, Groww, Dhan, Fyers, 5paisa, Motilal Oswal, Alice Blue, Tradejini and Pocketful, so you write your code once.
Quick takeaway
Use REST to act and a WebSocket or webhook to listen. Polling again and again is the slow way.
At a Glance
Features | REST API | WebSocket | Webhook |
Who starts it | You | You open it once, then the server sends | The server |
Best for | Placing and changing orders | Live account updates | Reacting to events on your server |
Polling needed | Yes, for updates | No | No |
Connection | One request, one reply | Stays open | One call per event |
Cirrus limit or setting | 20 requests a second per key | Ping every 15 seconds | Seven retries over about four hours |
Frequently Asked Questions
1. What is the difference between REST and WebSocket? REST answers one request at a time. A WebSocket stays open and sends updates by itself.
2. Which is faster for order updates? A WebSocket, because it sends the change as it happens.
3. What if my WebSocket connection drops? Reconnect with a short wait. Each new connection starts with a fresh snapshot.
4. What is a webhook? It is a message sent by the server to your server when an event happens.
5. Are Cirrus webhooks secure? Each one is signed with HMAC-SHA256, so you can check that it really came from Cirrus.
6. Do I need my own static IP to use the Cirrus API? No. Each account’s orders reach its broker from that account’s Cirrus static IP, as SEBI requires.
7. What does Cirrus cost? Cirrus Prime is ₹499 per account per month, GST included. The static IP is ₹0 extra on IPv6 brokers and ₹350 on IPv4 brokers.
Disclaimer: This blog is for education only and is not investment advice. Cirrus is a technology platform and does not give investment advice.
Sources: cirrus.trade (Trading API and webhooks), Cirrus API docs (The live stream, Webhooks, Errors and rate limits)
