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.
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:
- 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_secret
by embedding it in a mobile app or any client-side application. Similarly, do not expose theaccess_token
publicly. 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.
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.
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 |
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).
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.