Free trial
Menu
Learn guide

Understand How Trading APIs Work

A trading API is the interface a broker provides so that software can read your account and place orders without a person clicking in an app. Every algo platform in India, including QuantPower, works through broker APIs. This guide explains what a trading API does, how authentication, market data and orders work, what the SEBI framework requires, what brokers charge and when it makes sense to use an API directly rather than through a platform.

QuantPower Research · Updated 3 Nov 2026 · 6 min read

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

PartWhat it doesTechnology
AuthenticationConfirms who you are and issues a session tokenOAuth-style login with two-factor authentication
REST endpointsRequest and response calls: get positions, place an orderHTTPS requests returning JSON
WebSocket feedA continuous stream of prices and order updatesA persistent connection that pushes data
Postbacks or webhooksThe broker notifies your program when an order status changesHTTPS calls to a URL you register
Historical dataPast candles for backtestingREST, 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

BrokerTrading APIMarket data
ZerodhaKite Connect, ₹500 a month per API key; a free personal tier covers orders and portfolio without live dataIncluded in the paid plan; historical data as an add-on
UpstoxFreeIncluded
FyersFreeIncluded
DhanFreeData 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 codeA platform such as QuantPower
Skills neededProgramming, server management, error handlingNone beyond the strategy rules
Static IPYou register and maintain oneYours too: the computer or VPS QuantPower runs on
ReliabilityYour server, your internet, your monitoringYour computer or VPS, with built-in error handling
FlexibilityAnything the API allowsThe platform's strategy builder, signals and tools
CostServer, data, your timeSubscription from ₹299 a month
ComplianceYou stay within the order-rate rulesYour 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:

  1. Log in and confirm the session.
  2. Subscribe to prices for the instruments the strategy needs.
  3. On each new candle, evaluate the entry rules.
  4. If a rule triggers, check margin, then place the order and read the response.
  5. Place the stop loss and target as soon as the entry fills.
  6. Track order status and positions; handle rejections and partial fills.
  7. Exit on the stop, the target or the time rule.
  8. 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.

Loop of the eight steps every automated strategy runs, with steps 4 to 6 marked as where most errors occur (illustration)

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
Trading involves substantial risk. This page is for education and is not investment advice. API charges and terms change; check each broker's current page.