What are API Vendors?
API vendors provide the infrastructure for automated trading. They fall into two categories: execution APIs (broker APIs that place trades) and data APIs (market data feeds for analysis). For AI/XGBoost trading, you need both.
Execution APIs (Broker APIs)
| Broker | API Name | Cost | Rate Limit | Best For |
|---|---|---|---|---|
| Zerodha | Kite Connect | ₹2,000/month | 3 orders/sec | Best documentation |
| Angel One | SmartAPI | Free | 10 orders/sec | Best free option |
| Upstox | API v2 | Free | 25 orders/sec | Highest rate limit |
| Fyers | API v3 | Free | 10 orders/sec | Free historical data |
| Dhan | DhanHQ | Free | 25 orders/sec | Options trading |
| Alice Blue | ANT API | Free | 10 orders/sec | Low brokerage |
Data APIs for AI Trading
Free Data Sources
- Yahoo Finance (yfinance): Free historical data, but delayed and sometimes inaccurate
- NSE Website: Free end-of-day data for all NSE stocks
- Kaggle Datasets: Historical data for backtesting
- Fyers API: Free minute-level data for 1-2 years
Paid Data Sources
- Kite Connect Historical: ₹2,000/month for minute-level data
- Trendlyne: ₹500-₹2,000/month for real-time data
- Chartink: ₹500/month for scanning and data
- Amibroker Data Feeds: ₹1,000-₹5,000/month
Building Your Own XGBoost Trading System
Here is the architecture for a complete AI trading system:
- Data Layer: Fyers API or Yahoo Finance for historical data
- Feature Engineering: Python (pandas, numpy)
- Model Training: XGBoost/LightGBM in Python
- Signal Generation: Your trained model produces buy/sell signals
- Execution: Zerodha Kite Connect or Angel SmartAPI
- Monitoring: Grafana dashboard or custom web app
Python Code Example: XGBoost + Zerodha
import xgboost as xgb
from kiteconnect import KiteConnect
# Initialize Zerodha
kite = KiteConnect(api_key="your_api_key")
kite.set_access_token("your_access_token")
# Fetch data
data = kite.historical_data(
instrument_token=12345, # Nifty
from_date="2024-01-01",
to_date="2026-01-01",
interval="day"
)
# Train XGBoost model
model = xgb.XGBRegressor(n_estimators=100, max_depth=4)
model.fit(X_train, y_train)
# Generate signals
predictions = model.predict(X_live)
# Execute trades
if predictions > threshold:
kite.place_order(
tradingsymbol="NIFTY",
transaction_type="BUY",
quantity=50,
order_type="MARKET"
)
Cost Analysis
- Free setup: Angel One API + yfinance + Python = ₹0 upfront, ₹20/order brokerage
- Professional setup: Zerodha Kite + paid data + VPS = ₹5,000-10,000/month
- Institutional setup: Co-location + real-time data + custom infra = ₹50,000+/month
SEBI Disclaimer
This article is for educational purposes only. Algo trading involves substantial risk. Verify API terms and SEBI compliance before trading.
Latency, Rate Limits, and Reliability Math
The first technical constraint every Indian algo builder meets is the rate limit. A typical retail broker API allows between 1 and 10 REST requests per second and tens of thousands of tokens per day; Kite-style sessions renew for a fixed validity window, while OAuth-style flows refresh at scheduled intervals. Map your strategy's worst-case polling rate before choosing a vendor. A strategy that fires an order every five seconds is comfortable on nearly any broker, but a market-making logic that needs a book refresh every 200 milliseconds forces you into the WebSocket feed and drops you out of the cheap REST tier.
REST Polling vs WebSocket Streaming
REST polling asks a question and receives an answer; the latency is one round trip plus server cost, usually visible in milliseconds but expensive if repeated. WebSockets push updates the moment the exchange publishes them, which is the only way to build real-time position and price screens. Most Indian vendors expose both: subscribe to the websocket for ticks and keep REST for order placement, confirmation, and reconciliation. Never read a live strategy's exit decision from a REST poll alone, because the 100-to-500 millisecond polling gap turns a working stop into a vanilla limit order.
Sandbox Testing and Paper Accounts
Every serious vendor ships a sandbox or paper environment. The trick is to treat the sandbox as a waste of time if it cannot simulate fills: a sandbox that fills every limit order instantly at your price teaches nothing about the Indian order book, where a 500-lot sell sits visibly above the touch and your market order pays the second or third price level. Test the fill engine on the vendor's historical daily data instead, and use the sandbox only for code correctness - authentication, payload shape, error handling - not for profitability estimates.
Vendor Security: Keys, Tokens, and the Network
The API token is ownership of your trading account. Store it outside the code repository, load it from an environment variable or a secrets file that never enters git, and regenerate it on a fixed schedule. Add IP whitelisting if the provider supports it, so a leaked token from a coffee-shop laptop cannot place trades. Keep the bot on a small always-on Linux box or a free-tier cloud instance with the broker's endpoint whitelisted, and never expose the server's admin port to the public internet. A single incident teaches why the token's permissions should be read-only until the strategy is battle-tested.
A Costed Reference Setup
A workable beginner stack costs surprisingly little. A no-cost data pull from the exchange's public end-of-day endpoints covers historical bars; a broker's free market depth websocket covers live ticks; and the same broker's execution API handles orders. Add a 2,000-rupee-a-month cloud instance if you want the system to run while your laptop sleeps, plus the broker's brokerage on filled trades. Budget nothing for premium data until the strategy has a year of results, because the modelling problem comes first and the data upgrade rarely changes a losing idea into a winning one.
- Choose the broker for execution, a vendor for historical data, and a feed for ticks separately.
- Test login, order, and position endpoints in sandbox before wiring the strategy.
- Set the polling cadence under the vendor's documented limits.
- Whitelist IPs, rotate tokens, and keep secrets out of the repository.
- Record a fallback vendor for a 5-minute failover decision.
Fallback Chains and the Failover Decision
No vendor is failproof, and the serious system draws the emergency tree before the outage: a primary broker API, a secondary vendor for market data if the primary feed stalls, and a manual order path for the minutes that matter. Define the failover trigger - two failed websocket heartbeats, a REST reply slower than a documented ceiling, a token refresh that returns an error - and script the switch so the strategy pauses rather than flailing when the chain swaps. A system that halts on a feed disruption beats one that keeps trading blind, and a recorded runbook makes the pause a decision instead of a scramble. The cost of redundancy is a second token and a scheduled rehearsal of the fallback path, which is cheaper than the first unrehearsed outage.