Best overall free API: Angel One SmartAPI (₹0/month, 5-year data, sandbox, automated login). Best for options traders: Dhan DhanHQ (free Greeks via API, basket orders, SPAN margin calculator). Best for data scientists: Upstox API (2-year 1-min history, highest rate limits, clean OpenAPI spec). Most mature ecosystem: Zerodha Kite Connect (largest community, most third-party tools, paid at ₹4,720/month). Best budget F&O API: Fyers API (free, excellent options chain, solid Python SDK).
📋 Table of Contents
1. Why API Choice Matters for Algo Traders
Choosing the wrong broker API can silently kill your algo trading strategy. Common failure modes include:
- Rate limit errors (HTTP 429) causing missed signal executions during volatile market opens
- WebSocket disconnections with no auto-reconnect, resulting in stale prices and wrong signals
- Insufficient historical data making backtests statistically unreliable
- Manual browser login requirements crashing your headless server deployment at 9 AM each day
- Opaque fee structures consuming all profits for small-capital traders
The right API choice depends on your strategy type, capital size, Python skill level, and deployment environment. This guide helps you navigate that decision.
2. Master Comparison Table: All 6 Broker APIs
| Feature | Angel One | Dhan | Upstox | Zerodha | Fyers | 5paisa |
|---|---|---|---|---|---|---|
| Monthly API Cost | ₹0 ✅ | ₹0 ✅ | ₹0 ✅ | ₹4,720 🟠 | ₹0 ✅ | ₹0 ✅ |
| Historical Data (free) | 5yr daily / 30d 1-min | 10yr daily / 30d 1-min | 10yr daily / 2yr 1-min 🏆 | Paid only | 5yr daily / 100d 1-min | 5yr daily / 30d 1-min |
| WebSocket Instruments | 1,000 | 1,000 | 1,000 | 3,000 🏆 | 200 | 500 |
| REST Rate Limit (req/sec) | 25 | ~15 | 25 ✅ | 10 | 10 | 10 |
| Automated TOTP Login | ✅ Yes | ✅ Yes | ✅ Yes | ❌ Browser | ✅ Yes | ✅ Yes |
| Sandbox / Paper Trade | ✅ Yes | ✅ Yes | ❌ | ❌ | ❌ | ❌ |
| Options Greeks API | ❌ | ✅ Yes 🏆 | ✅ WebSocket | ❌ | ✅ Yes | ❌ |
| Basket Orders | ❌ | ✅ Yes | ❌ | ❌ | ❌ | ❌ |
| Official Python SDK | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Community Size | Medium | Growing | Large | Largest 🏆 | Medium | Small |
| F&O Markets | NSE, BSE | NSE, BSE ✅ | NSE, BSE | NSE, BSE, BFO 🏆 | NSE | NSE |
| MCX Commodities | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
3. 🏆 #1 Angel One SmartAPI — Best Overall Free API
Angel One SmartAPI
- Zero API fees — saves ₹56,640/year vs Zerodha
- 5-year free daily OHLCV for long-term backtests
- Official sandbox for paper trading
- Fully automated TOTP login (headless-friendly)
- 25 req/sec — highest REST rate limit in the class
- NSE, BSE, NFO, MCX, CDS all supported
- Only 30 days of 1-minute intraday history
- WebSocket limited to 1,000 instruments (vs Zerodha's 3,000)
- No options Greeks in REST API (compute client-side)
- Smaller developer community vs Zerodha
4. 🏈 #2 Dhan DhanHQ API — Best for Options Traders
Dhan DhanHQ API
- Live Delta, Gamma, Theta, Vega via options chain API
- Basket order support for multi-leg strategies
- SPAN + Exposure margin calculator API
- 10-year daily data — best in the class for long backtests
- Forever-free paper trading account
- Binary WebSocket (Protobuf) for low latency
- Lower REST rate limit (~15 req/sec)
- Only 30-day 1-minute intraday history
- Smaller community vs Zerodha and Upstox
- API launched 2022 — less mature track record
5. 🏈 #3 Upstox API — Best Historical Data
Upstox API
- 2-year 1-minute OHLCV history — best free data depth
- 25 req/sec REST limit — highest in class
- Clean OpenAPI 3.0 spec with auto-generated clients
- Large developer community with good Stack Overflow presence
- Options Greeks via WebSocket SnapQuote mode
- 250 orders/day limit (standard accounts)
- No official sandbox for paper trading
- No multi-leg basket orders
- WebSocket instrument limit same as others (1,000)
6. #4 Zerodha Kite Connect — Most Mature Ecosystem
Zerodha Kite Connect
- Largest developer community in India (TradingQ&A)
- 3,000 WebSocket instrument subscriptions
- Battle-tested 10+ year track record
- Rich third-party integrations (Streak, Opstra)
- Binary WebSocket protocol for high throughput
- ₹4,720/month API fees (₹56,640/year)
- No automated login — browser-based OAuth required
- No official paper trading sandbox
- Historical data requires separate paid plan
7. #5 Fyers API — Best Budget F&O API
Fyers API
- Free with options Greeks (Delta, Gamma, Theta, Vega)
- 100 days of 1-minute history — longer than Angel One/Dhan
- Automated TOTP login supported
- Good WebSocket data quality
- Only 200 WebSocket instrument subscriptions (lowest)
- NSE-only for F&O (no BSE F&O)
- Smaller community and SDK update cadence
- No paper trading sandbox
8. #6 5paisa Open API
5paisa Open API
- Free API access
- Reasonable WebSocket capacity (500 instruments)
- Automated login supported
- No MCX commodity support
- Smallest developer community
- Fewer SDK features vs top-tier alternatives
- Less frequent API updates
9. Recommendation by Use Case
| Use Case | Recommended API | Reason |
|---|---|---|
| Complete beginner to algo trading | Angel One SmartAPI | Free, sandbox, automated login, easiest setup |
| NIFTY/BANKNIFTY options strategies | Dhan DhanHQ | Live Greeks, basket orders, SPAN margin API |
| Equity intraday strategies (backtesting) | Upstox API | 2-year 1-min data, highest rate limits |
| Production multi-strategy system (>₹10L AUM) | Zerodha Kite Connect | 3,000 WS instruments, largest ecosystem |
| Headless server auto-deployment | Angel One SmartAPI | Native TOTP login without browser dependency |
| F&O traders on tight budget | Fyers API | Free, options Greeks, 100-day 1-min history |
| Delta-neutral options hedging | Dhan DhanHQ | Live Greeks + SPAN margin calculator |
| Long-term systematic equity investing | Upstox API | 10-year daily data, clean API design |
10. Quick Start: Install All Python SDKs
# Install all major Indian broker Python SDKs pip install kiteconnect # Zerodha Kite Connect pip install smartapi-python # Angel One SmartAPI pip install dhanhq # Dhan DhanHQ pip install upstox-python-sdk # Upstox API pip install fyers-apiv3 # Fyers API v3 pip install py5paisa # 5paisa Open API # Essential supporting libraries pip install pyotp pandas numpy # TOTP login, data processing
Universal Order Placer — Broker-Agnostic Pattern
"""Broker-agnostic order placement pattern for Indian algo trading."""
from abc import ABC, abstractmethod
from dataclasses import dataclass
from enum import Enum
class Exchange(Enum):
NSE = "NSE"
BSE = "BSE"
NFO = "NFO"
MCX = "MCX"
class OrderType(Enum):
MARKET = "MARKET"
LIMIT = "LIMIT"
SL = "SL"
class ProductType(Enum):
INTRADAY = "INTRADAY"
DELIVERY = "DELIVERY"
FUTURES = "FUTURES"
@dataclass
class Order:
symbol: str
exchange: Exchange
transaction: str # "BUY" or "SELL"
quantity: int
order_type: OrderType
product: ProductType
price: float = 0.0
class BrokerAPI(ABC):
@abstractmethod
def place_order(self, order: Order) -> str:
"""Return order ID on success."""
...
@abstractmethod
def get_ltp(self, exchange: Exchange, symbol: str) -> float:
"""Return last traded price."""
...
# Each broker implements this interface:
class AngelOneBroker(BrokerAPI):
def __init__(self, api_key, client_code, pin, totp_secret):
import pyotp
from SmartApi import SmartConnect
self.obj = SmartConnect(api_key=api_key)
totp = pyotp.TOTP(totp_secret).now()
self.obj.generateSession(client_code, pin, totp)
def place_order(self, order: Order) -> str:
response = self.obj.placeOrder({
"variety": "NORMAL",
"tradingsymbol": order.symbol,
"transactiontype": order.transaction,
"exchange": order.exchange.value,
"ordertype": order.order_type.value,
"producttype": order.product.value,
"duration": "DAY",
"price": str(order.price),
"quantity": str(order.quantity),
"squareoff": "0", "stoploss": "0",
"symboltoken": "LOOKUP_TOKEN_HERE" # from instrument list
})
return response
def get_ltp(self, exchange: Exchange, symbol: str) -> float:
resp = self.obj.ltpData(exchange.value, symbol, "TOKEN")
return float(resp["data"]["ltp"])
Related Algo Trading Guides & Comparisons
Frequently Asked Questions
Which is the best free algo trading API in India for 2026?
Angel One SmartAPI is the best overall free algo trading API in India for 2026. It offers zero subscription fees, 5-year historical daily data, an official sandbox, fully automated TOTP login, and a 25 req/sec REST rate limit. Dhan DhanHQ is the best choice specifically for options traders needing live Greeks.
Which Indian broker API is best for Python beginners?
Angel One SmartAPI is best for beginners: zero fees, official sandbox for paper trading, fully automated login with pyotp (no browser needed), and a clean SDK with ready-to-run Python examples in the official documentation.
Do I need SEBI approval to run algo trading strategies in India?
No. Individual retail traders running algorithms on their own personal accounts via registered broker APIs do not need SEBI approval. SEBI's regulations primarily target brokers offering algorithmic execution to clients and third-party strategy providers selling algos to the public.
Which Indian broker API provides the most historical data?
Upstox API provides the deepest free 1-minute intraday history at 2 years (730 days), far exceeding Angel One (30 days), Dhan (30 days), and Fyers (100 days). For daily data, Dhan offers 10+ years. Zerodha's historical data requires a paid subscription.
How can I automate daily broker API login without a browser?
Angel One SmartAPI, Dhan DhanHQ, Upstox, and Fyers all support automated TOTP-based login. Install pyotp via pip, get your broker's TOTP base32 secret from the 2FA setup page, and use pyotp.TOTP(secret).now() to generate the current OTP programmatically — no browser required. Zerodha is the only major broker that still requires a browser-based OAuth redirect.
Can I use multiple broker APIs in the same trading system?
Yes. Many sophisticated retail traders maintain accounts with 2–3 brokers and route different strategies through each — for example, using Angel One for data collection (free historical API), Dhan for options execution (basket orders), and Zerodha as a backup. The broker-agnostic interface pattern shown in this article facilitates this architecture.