Skip to content

Latest commit

 

History

History
247 lines (196 loc) · 8.09 KB

File metadata and controls

247 lines (196 loc) · 8.09 KB

OpenAlgo API Documentation

Welcome to the OpenAlgo REST API Documentation. This comprehensive guide covers all API endpoints available for algorithmic trading operations.

Base URL

Local Host   :  http://127.0.0.1:5000/api/v1
Ngrok Domain :  https://<your-ngrok-domain>.ngrok-free.app/api/v1
Custom Domain:  https://<your-custom-domain>/api/v1

Authentication

All API endpoints require authentication using an API key. Include your API key in the request body:

{
  "apikey": "<your_app_apikey>"
}

API Categories

Order Management

Execute and manage trading orders across all supported exchanges.

Endpoint Description
PlaceOrder Place a new order
PlaceSmartOrder Place position-aware smart order
OptionsOrder Place options order with offset
OptionsMultiOrder Place multi-leg options order
BasketOrder Place multiple orders simultaneously
SplitOrder Split large order into smaller chunks
ModifyOrder Modify an existing order
CancelOrder Cancel a specific order
CancelAllOrder Cancel all open orders
ClosePosition Close all open positions
PlaceGTTOrder Place a SINGLE or OCO GTT (Good Till Triggered) order
ModifyGTTOrder Modify an active GTT trigger
CancelGTTOrder Cancel an active GTT trigger
GTTOrderBook List active GTT triggers

Order Information

Query order status and position information.

Endpoint Description
OrderStatus Get current status of an order
OpenPosition Get open position for a symbol

Market Data

Access real-time and historical market data.

Endpoint Description
Quotes Get market quotes for a symbol
MultiQuotes Get quotes for multiple symbols
Depth Get market depth (Level 2) data
History Get historical OHLCV data
Intervals Get available time intervals

Symbol Services

Symbol lookup, search, and instrument data.

Endpoint Description
Symbol Get detailed symbol information
Search Search for symbols
Expiry Get expiry dates for F&O
Instruments Get all instruments list

Options Services

Options-specific operations and analytics.

Endpoint Description
OptionSymbol Get option symbol by offset
OptionChain Get full option chain data
SyntheticFuture Calculate synthetic futures price
OptionGreeks Calculate option Greeks and IV

Account Services

Account information, funds, and portfolio data.

Endpoint Description
Funds Get account funds information
Margin Calculate margin requirement
OrderBook Get all orders for the day
TradeBook Get all trades for the day
PositionBook Get all current positions
Holdings Get portfolio holdings

Market Calendar

Market timing and holiday information.

Endpoint Description
Holidays Get market holidays for a year
Timings Get market timings for a date
CheckHoliday Check if a date is a holiday

Analyzer Services

Sandbox/analyzer mode for testing.

Endpoint Description
AnalyzerStatus Get analyzer mode status
AnalyzerToggle Toggle analyzer mode on/off

WebSocket Streaming

Real-time market data streaming.

Endpoint Description
LTP Subscribe to last traded price
Quote Subscribe to quote updates
Depth Subscribe to market depth

WhatsApp Services

Send trade alerts via WhatsApp. Send-only public surface — pairing, start/stop, config, users, broadcast, stats, and preferences are all admin-only and live behind the session-authed /whatsapp web UI. A leaked API key cannot create, mutate, or enumerate the device session.

Endpoint Description
Overview Architecture, security model, command reference
Notify Send text / image / document to self, one user, or up to 5 recipients

Order Constants

Exchange Codes

Code Description
NSE National Stock Exchange (Equity)
BSE Bombay Stock Exchange (Equity)
NFO NSE Futures & Options
BFO BSE Futures & Options
CDS Currency Derivatives (NSE)
BCD Currency Derivatives (BSE)
MCX Multi Commodity Exchange
NCO NSE Commodities (futures + options, Zerodha only)
NSE_INDEX NSE Index (for options trading)
BSE_INDEX BSE Index (for options trading)
GLOBAL_INDEX Global indices (US30, JAPAN225, HANGSENG, GIFTNIFTY, etc.) — quote-only, Zerodha only

Product Types

Code Description
MIS Margin Intraday Square-off
CNC Cash and Carry (Equity Delivery)
NRML Normal (F&O Overnight)

Price Types

Code Description
MARKET Market order
LIMIT Limit order
SL Stop-loss limit order
SL-M Stop-loss market order

Action Types

Code Description
BUY Buy order
SELL Sell order

Symbol Format Reference

Equity

SYMBOL
Example: RELIANCE, SBIN, TCS

Futures

[SYMBOL][DD][MMM][YY]FUT
Example: NIFTY30JAN25FUT, BANKNIFTY27FEB25FUT

Options

[SYMBOL][DD][MMM][YY][STRIKE][CE/PE]
Example: NIFTY30JAN2525000CE, BANKNIFTY27FEB2552000PE

Response Format

All API responses follow a consistent JSON format:

Success Response

{
  "status": "success",
  "data": { ... }
}

Error Response

{
  "status": "error",
  "message": "Error description"
}

HTTP Status Codes

Code Description
200 Success
400 Bad Request (validation error)
403 Forbidden (invalid API key)
404 Not Found
429 Rate Limit Exceeded
500 Internal Server Error

Rate Limits

OpenAlgo implements differentiated rate limiting for various API operations:

API Type Rate Limit
Order Management 10 per second
Smart Orders 2 per second
General APIs 50 per second
Webhooks 100 per minute

For detailed rate limiting information including configuration options, see Rate Limiting.

SDK Support

OpenAlgo provides official SDKs for popular programming languages:

  • Python: pip install openalgo
  • Node.js: Coming soon
  • Java: Coming soon

Support