Broker APIs in India let you log in, place and modify orders, stream live prices, fetch historical candles and read positions, holdings and funds directly from Python code. Almost every Indian broker exposes the same broad set of APIs, but details such as login flow, symbol format and limits differ, and since 1 April 2026 SEBI’s retail algo framework adds static IP and order rate rules on top.
In recent years, the rise of algorithmic trading in India has opened the doors for retail traders and developers to automate their trading strategies using broker APIs. These APIs serve as the technical bridge between trading platforms and custom-built applications, allowing users to place orders, fetch market data, monitor positions, and build advanced analytics tools directly through code. While the concept of trading via code might seem complex at first, understanding the structure and purpose of each API type can simplify the process. This article breaks down the essential APIs provided by most brokers in the Indian market and highlights the key aspects traders need to know before getting started with automation.

This post walks through the different types of APIs brokers generally offer in India, explained in simple terms and without referring to any specific provider.
Key Takeaways
- Every session starts with authentication: an API key and secret plus a daily login that produces an access token, valid only for that trading day.
- The core groups are order management, market data (REST and WebSocket), portfolio (positions, holdings, funds) and utilities such as margin calculators, EDIS and kill switches.
- Under SEBI’s retail algo framework, applicable to all brokers from 1 April 2026, API orders must come from a registered app mapped to a whitelisted static IP, and algos above 10 orders per second need exchange registration.
- Authentication, symbol formats, master contracts and order parameters vary from broker to broker, which is the main reason a broker-neutral layer such as OpenAlgo exists.
A Note Before We Begin
Not every broker provides all the features listed below. While the basics like order placement and market data are widely available, brokers often differentiate themselves by offering specialized APIs, such as advanced option greeks, basket orders, or kill switches, to attract serious algo traders.
As a developer, you should always verify the available features with your broker’s API documentation.
1. Authentication and Session Management
Before using any broker API, you need to authenticate using your trading credentials and an API key provided by the broker. Once authenticated, an access token is generated, which is required for all subsequent API requests.
Important: Daily Token Expiry
- The access token typically expires at midnight, and as part of SEBI compliance, traders are required to generate a new token every trading day.
- The invalidation time may vary across brokers but usually occurs between 1:00 a.m. and 6:00 a.m. IST the following day.
- You must log in through the API each morning and generate a fresh token before sending any other request.
Security Note:
Never expose yourapi_secretby embedding it in a mobile app or any client-side application. Similarly, do not expose theaccess_tokenpublicly. These credentials are sensitive and should always be stored securely on the server side.
2. Profile and Account Information APIs
These APIs help you retrieve basic user-related data such as:
- User profile details (name, email, PAN, etc.)
- Available funds in the trading account
- Margin details and exposure across segments
3. Order Management APIs
This is the core set of APIs for placing and managing trades. These allow you to:
- Place orders (Market, Limit, Stop Loss, Bracket, Cover, GTT)
- Modify or cancel existing orders
- Access order book and trade book
- Place multi-leg or basket orders
- Track and convert positions (Intraday to Delivery or vice versa)
Some brokers also support GTT (Good Till Triggered) orders and BO/CO orders for advanced strategy setups. Note that several brokers have discontinued bracket orders in recent years, so check before building a strategy around them.
4. Basket Order API
Basket orders let you submit multiple trades in one go, typically with predefined weights or capital allocation. This is useful for:
- Options strategies (like straddle, strangle)
- Multi-stock trades
- Portfolio rebalancing
You can submit multiple trades in a single API call, depending on the broker’s limit.
5. Position Conversion API
These APIs allow you to convert existing trades:
- From Intraday (MIS) to Delivery (CNC or NRML)
- From Delivery to Intraday
Useful when changing your trade horizon mid-day.
6. Market Data APIs
These APIs provide access to:
- Live quotes (LTP, OHLC, volume)
- Market depth (typically up to 5 levels)
- Historical candles (1-minute, 5-minute, daily)
Advanced Depth
While 5 levels of market depth is common, some brokers provide 20 or even 50 levels, often called Level 3 depth, which helps detect deeper supply/demand activity.
I covered one example of deeper depth in the post on FYERS 50 market depth.
7. Real-Time Streaming via WebSocket
Many brokers offer WebSocket-based APIs for fast, persistent data delivery.
a) Live Market Feed
Streams real-time LTP, volume, and depth data.
b) Live Order Updates
Instant updates about order placement, modification, and execution status.
8. Option Chain and Greeks APIs
Useful for building options trading tools, these APIs provide:
- Full option chain for a symbol
- Real-time Greeks like Delta, Gamma, Theta, Vega, IV, and OI
9. EDIS API (Delivery Sell Approval)
Before selling shares from your demat account, you must authorize the transaction using EDIS APIs, which serve as an electronic delivery instruction.
10. Margin and Brokerage Calculator APIs
Helps calculate:
- Margin required to execute a trade
- Total brokerage and tax impact
Ensures you’re not caught off guard by hidden costs or insufficient funds.
11. Kill Switch API
Some brokers provide an emergency Kill Switch API. When activated, it disables all trading for the current day, providing an added safety mechanism during unexpected events.
12. Postback and Webhook Support
A postback URL is a server endpoint you define, where the broker can send:
- Order execution status
- Trade confirmation
- Margin calls or risk alerts
13. Holdings and Positions APIs
- Holdings: Shows delivery-based stocks and mutual funds.
- Positions: Shows open positions across segments.
14. Mutual Fund APIs
Some brokers now offer APIs for managing mutual fund investments, including:
- SIP and lumpsum investments
- NAV tracking
- Redemption and switching
15. Statement and Ledger Report APIs
Used for record-keeping and analysis:
- Trade statement APIs list past trades
- Ledger report APIs summarize all credits and debits
Typically filtered by date range.
16. Additional Market Insight APIs
APIs for analytics and scanning:
- Top gainers/losers
- Sector performance
- Index composition
Supported Exchange Segments
| Code | Exchange / Segment |
|---|---|
| NSE | NSE Equity |
| NFO | NSE Futures & Options |
| CDS | NSE Currency Derivatives |
| BSE | BSE Equity |
| BFO | BSE Futures & Options |
| BCD | BSE Currency Derivatives |
| MCX | MCX Commodity |
| NCDEX | NCDEX Commodity |
Product Types for Orders
| Code | Description |
|---|---|
| CNC | Cash & Carry – for delivery trades |
| MIS | Margin Intraday Square-off |
| NRML | Carry-forward F&O trades |
| BO | Bracket Order with SL and Target |
| CO | Cover Order with SL only |
| GTT | Good Till Triggered Order |
Order Types
| Code | Description |
|---|---|
| MARKET | Executes at current market price |
| LIMIT | Executes at your defined price |
| SL | Stop Loss with limit price |
| SL-M | Stop Loss with market execution |
Order Actions
| Action | Description |
|---|---|
| BUY | Place a buy order |
| SELL | Place a sell order |
SEBI Rules for Retail Algo Trading Through Broker APIs
When this post was first written in April 2025, SEBI had just issued its circular on safer participation of retail investors in algorithmic trading (4 February 2025). After two extensions, the circular of 30 September 2025 made the framework applicable to all brokers from 1 April 2026. What it means for a Python trader using a broker API:
- Static IP whitelisting: orders through the API are accepted only from your registered App ID mapped to a whitelisted static IP address. A home broadband connection with a dynamic IP will not work for order placement. Check with your broker whether it applies the same check to data calls.
- Order rate threshold: up to 10 orders per second per exchange is treated as a self-built algo for personal use. Above that, the strategy has to be registered with the exchange through the broker and gets an algo ID.
- Daily session: the daily login and token expiry described above remain, and brokers log out API sessions before the next trading day.
- Your responsibility: API credentials must not be shared, and the broker is responsible for orders that pass through its API, which is why brokers now enforce these checks strictly.
Brokers have published their own implementation notes; for example, FYERS explains the April 2026 rules here. For a practical guide on getting a static IP from an Indian ISP, see how to get a static IP in India for algo trading compliance.
What Varies from Broker to Broker
While most brokers offer similar types of APIs for trading and data access, there are several key differences in how these APIs are implemented and used:
1. Authentication Process
Each broker follows their own approach for user authentication:
- Some use OAuth 2.0 with single-use codes and access tokens.
- Others require a multi-step session setup with checksum, API secret, and session tokens.
- Additional layers like TOTP (Time-based OTP) for two-factor authentication may also be required.
2. Trading Symbols Format
There is no universal format for trading symbols:
- Some brokers use exchange-prefixed formats (e.g.,
NSE:INFY-EQ), - Others may use plain symbols like
INFY, or internal security tokens. - This inconsistency requires symbol mapping when switching between brokers or aggregating data.
3. Master Contract Download Process
Brokers differ in how they expose instrument/master contract data:
- Some offer it via dedicated APIs (REST/JSON).
- Others provide CSV downloads via static links.
- A few still require you to manually download ZIP files and parse them offline.
4. Order Placement Parameters
Order placement conventions also vary:
- Some brokers require symbol strings for placing orders.
- Others mandate the use of exchange-specific tokens (instrument identifiers).
- A few support both symbol and token, depending on the segment (equity, F&O, currency).
A Typical Python Workflow with a Broker API
- Morning login: authenticate (often with TOTP) and store the access token securely on the server.
- Download the master contract: map your symbols to the broker’s instrument tokens for the day.
- Subscribe to the WebSocket feed for the instruments you trade, and to order updates.
- Run strategy logic on incoming ticks or completed candles.
- Place orders through the order API, respecting the 10 orders per second limit and your own risk checks.
- Reconcile: confirm fills from the order update stream or postback, then check positions and funds.
- End of day: square off intraday positions, pull the trade book and ledger for records.
Because the login flow, symbol format and order parameters differ between brokers, I prefer writing strategies against a single broker-neutral API. That is what OpenAlgo does: it runs on your own machine or server, connects to your broker, and exposes one Python SDK and one symbol format for all supported brokers. Placing an order and reading a quote look the same whichever broker is connected:
from openalgo import api
client = api(api_key="your_openalgo_api_key", host="http://127.0.0.1:5000")
# Live quote
print(client.quotes(symbol="RELIANCE", exchange="NSE"))
# Market order, intraday product
response = client.placeorder(
strategy="Python",
symbol="SBIN",
action="BUY",
exchange="NSE",
price_type="MARKET",
product="MIS",
quantity=1
)
print(response)
# Positions and funds
print(client.positionbook())
print(client.funds())
The method names and parameters above follow the OpenAlgo Python SDK documentation. For pulling long intraday histories without hitting broker rate limits, see fetching broker historical data with OpenAlgo.
Common Mistakes When Starting with Broker APIs
- Hard-coding the access token: it expires daily. Automate the login and keep secrets in environment variables, not in code.
- Ignoring rate limits: brokers limit requests per second for quotes, history and orders. Batch quote requests, cache master contracts and back off on HTTP 429 errors.
- Assuming an order filled: an order ID only means the order was accepted. Confirm the status from the order book, WebSocket order updates or postback.
- No WebSocket reconnect logic: connections drop. Reconnect and resubscribe automatically, and log gaps in data.
- Using yesterday’s instrument tokens for F&O after expiry. Download the master contract every morning.
- Slow order calls: opening a new HTTP connection for every order adds latency. Connection pooling helps, as I measured in cutting API order latency with HTTP connection pooling.
Frequently Asked Questions
Is algo trading through broker APIs legal for retail traders in India?
Yes. SEBI’s retail algo framework, applicable to all brokers from 1 April 2026, explicitly allows retail investors to use broker APIs, subject to static IP whitelisting, registered app IDs and exchange registration for algos above 10 orders per second.
Do I need a static IP to use a broker API in India?
For placing orders through the API, yes. Orders are accepted only from a registered app mapped to a whitelisted static IP. Whether data calls also need it depends on the broker, so check its documentation.
How long is a broker API access token valid?
Typically for one trading day. Tokens are invalidated overnight, usually between midnight and 6 a.m. IST depending on the broker, so you must log in and generate a new token every morning.
What is the 10 orders per second rule?
Under the SEBI framework, an algo sending up to 10 orders per second per exchange is treated as a personal algo that does not need registration. Above that threshold the strategy must be registered with the exchange through the broker.
Which programming language is best for broker APIs?
Python is the most common choice because most Indian brokers publish official Python SDKs and the data analysis ecosystem (pandas, NumPy) is strong. Any language that can make HTTPS and WebSocket calls will work.
Final Thoughts
Broker APIs are the foundation for building automated trading systems. They allow you to place orders, stream real-time data, manage positions, calculate margins, and perform post-trade analytics, all from your Python code.
While many APIs are standardized across the industry, brokers may differ in what they offer. Be sure to explore the documentation, compare available features, and always follow best security practices to protect your credentials and sessions.
Learn by watching: free videos every week
Market Profile, order flow, Python, AI and OpenAlgo tutorials on YouTube.

