What a trading API does
An application programming interface (API) is a set of rules for one program to talk to another. A broker's trading API lets a program:
- log in to your account with your permission,
- read your funds, margin, holdings, positions and orders,
- receive market prices,
- place, modify and cancel orders, and
- receive confirmation when an order fills.
The program can be a platform such as QuantPower, a spreadsheet, or code you write yourself. The broker's systems apply the same risk checks to API orders as to orders from its app.
The parts of a trading API
| Part | What it does | Technology |
|---|---|---|
| Authentication | Confirms who you are and issues a session token | OAuth-style login with two-factor authentication |
| REST endpoints | Request and response calls: get positions, place an order | HTTPS requests returning JSON |
| WebSocket feed | A continuous stream of prices and order updates | A persistent connection that pushes data |
| Postbacks or webhooks | The broker notifies your program when an order status changes | HTTPS calls to a URL you register |
| Historical data | Past candles for backtesting | REST, often rate-limited or paid |
Authentication and the daily login
Broker APIs use a login flow in which you enter your credentials and two-factor code on the broker's own page. The broker then issues an access token to the program. Under SEBI's framework, every API session ends before the next trading day, so you log in again each morning. The program never sees your password.
Tokens are the keys to your account for the day. A program that stores them must protect them, and you should revoke a program's access in your broker's settings if you stop using it. Our guide to broker connection security explains what a connected program can and cannot do.
Market data
APIs provide two kinds of price data:
- Quotes on request: the latest price, depth and open interest for an instrument, fetched when the program asks.
- Streaming ticks: every price change pushed over a WebSocket, for hundreds or thousands of instruments at once.
Brokers differ on what they include. Some bundle live data with free API access, others charge for it, and historical candles for backtesting are often a separate product. A strategy that needs tick data for many option strikes should check the subscription limits before relying on them.
Orders through an API
An API order carries the same fields as an order in the app: instrument, exchange, side, quantity, order type, price, trigger price, product type and validity. The broker returns an order ID, and the order's status changes through open, complete, cancelled or rejected. Our guide to order types explains the choices.
Three things differ from manual trading:
- Speed. A program can place an order within milliseconds of a signal, and many in a second. SEBI's framework caps unregistered algos at 10 orders per second per exchange segment.
- Errors are silent. A rejected order does not pop up on screen. The program must read the response and decide what to do, for example closing a filled hedge leg if the other leg was rejected.
- No confirmation step. There is no "are you sure" dialog. A bug places real orders.
What the SEBI framework requires
SEBI's rules on retail algorithmic trading, in force for all brokers since 1 April 2026, apply to API trading:
- API orders must come from a static IP address registered with the broker. With QuantPower or your own code, it is the static IP of the computer or VPS you run it on.
- Algos that send more than 10 orders per second must be registered with the exchange through the broker and carry an Algo ID.
- API access uses OAuth-style authentication with two-factor login, and sessions end daily.
- Brokers keep an audit trail of API orders.
Our guide to SEBI's algo trading rules covers the framework in full.
Broker API charges
| Broker | Trading API | Market data |
|---|---|---|
| Zerodha | Kite Connect, ₹500 a month per API key; a free personal tier covers orders and portfolio without live data | Included in the paid plan; historical data as an add-on |
| Upstox | Free | Included |
| Fyers | Free | Included |
| Dhan | Free | Data API ₹499 a month plus taxes |
Charges checked on 10 October 2026 and subject to change. When you trade through a platform such as QuantPower, prices come from your connected broker account, so a broker that charges for data charges you whether you code or not. See broker connection requirements.
Using an API directly vs through a platform
| Your own code | A platform such as QuantPower | |
|---|---|---|
| Skills needed | Programming, server management, error handling | None beyond the strategy rules |
| Static IP | You register and maintain one | Yours too: the computer or VPS QuantPower runs on |
| Reliability | Your server, your internet, your monitoring | Your computer or VPS, with built-in error handling |
| Flexibility | Anything the API allows | The platform's strategy builder, signals and tools |
| Cost | Server, data, your time | Subscription from ₹299 a month |
| Compliance | You stay within the order-rate rules | Your API key, static IP and daily login; under 10 orders a second |
Writing to an API directly suits traders who need logic a builder cannot express, or who want to integrate their own data. Our guide to Python algo trading with Zerodha shows the first steps. For most rule-based strategies, a platform is faster to set up and easier to run every day.
A minimal API trading loop
Whether in code or in a platform, every automated strategy runs the same loop:
- Log in and confirm the session.
- Subscribe to prices for the instruments the strategy needs.
- On each new candle, evaluate the entry rules.
- If a rule triggers, check margin, then place the order and read the response.
- Place the stop loss and target as soon as the entry fills.
- Track order status and positions; handle rejections and partial fills.
- Exit on the stop, the target or the time rule.
- Log every order and every decision for review.
Steps 4 to 6 are where most errors occur, and where a platform's built-in handling saves the most effort.
Start your free trial
Connect your broker, build a strategy and test it on paper before a single live order goes out.
Frequently asked questions
Do I need to know programming to use a trading API?
To call the API yourself, yes. To use it through a platform, no: the platform's software talks to the API on your behalf, and you set rules in its interface.
Is API trading legal in India?
Yes, through a SEBI-registered broker that offers API access under SEBI's framework for retail algo trading.
Can a trading API withdraw money from my account?
No. Broker APIs do not offer withdrawals. Money leaves a trading account only to your registered bank account on your instruction to the broker.
Why does my API session expire every day?
SEBI's framework requires brokers to end every API session before the next trading day. The daily login limits how long a stolen token could be used.
Which broker has the best API for algo trading?
It depends on what you need. Upstox and Fyers offer free APIs with data; Zerodha's Kite Connect is widely used but costs ₹500 a month. QuantPower works with all of them, so the choice can rest on brokerage and service.
Sources
- SEBI circular SEBI/HO/MIRSD/MIRSD-PoD/P/CIR/2025/0000013: Safer participation of retail investors in algorithmic trading, 4 Feb 2025
- NSE, Implementation standards for retail algo trading, 5 May 2025
- Zerodha Kite Connect, Upstox, Fyers and Dhan developer pages, checked 10 Oct 2026
