Option Chain
Option Chain
Endpoint URL
This API Function Fetches Option Chain Data with Real-time Quotes for All Strikes
Local Host : POST http://127.0.0.1:5000/api/v1/optionchain
Ngrok Domain : POST https://<your-ngrok-domain>.ngrok-free.app/api/v1/optionchain
Custom Domain: POST https://<your-custom-domain>/api/v1/optionchainSample API Request (Full Chain)
{
"apikey": "your_api_key",
"underlying": "NIFTY",
"exchange": "NSE_INDEX",
"expiry_date": "30DEC25"
}Sample API Response (Full Chain)
Sample API Request (10 Strikes Around ATM)
This returns 10 strikes above ATM + 10 strikes below ATM + ATM = 21 total strikes.
Sample API Request (Future as Underlying)
Note: When using a future as underlying, expiry_date is extracted from the future symbol.
Sample API Request (Stock Options)
Parameter Description
apikey
App API key
Mandatory
-
underlying
Underlying symbol (NIFTY, BANKNIFTY, RELIANCE, etc.)
Mandatory
-
exchange
Exchange code (NSE_INDEX, NSE, NFO, BSE_INDEX, BSE, BFO)
Mandatory
-
expiry_date
Expiry date in DDMMMYY format (e.g., 30DEC25)
Mandatory*
-
strike_count
Number of strikes above and below ATM (1-100)
Optional
All strikes
*Note: expiry_date is optional if underlying includes expiry (e.g., NIFTY30DEC25FUT)
Response Parameters
status
API response status (success/error)
string
underlying
Base underlying symbol
string
underlying_ltp
Last Traded Price of underlying
number
expiry_date
Expiry date in DDMMMYY format
string
atm_strike
At-The-Money strike price
number
chain
Array of strike data with CE and PE
array
Chain Item Structure
Each item in the chain array contains:
strike
Strike price
number
ce
Call option data (null if not found)
object
pe
Put option data (null if not found)
object
CE/PE Data Structure
symbol
Option symbol (e.g., NIFTY30DEC2524000CE)
string
label
Strike label (ATM, ITM1, OTM1, etc.)
string
ltp
Last Traded Price
number
bid
Best bid price
number
ask
Best ask price
number
open
Day's open price
number
high
Day's high price
number
low
Day's low price
number
prev_close
Previous day's close price
number
volume
Traded volume
number
oi
Open Interest
number
lotsize
Lot size for the option
number
tick_size
Minimum price movement
number
Strike Labels
Strike labels indicate the position relative to ATM and are different for CE and PE:
At ATM
ATM
ATM
At-The-Money strike
1 below ATM
ITM1
OTM1
CE is In-The-Money, PE is Out
2 below ATM
ITM2
OTM2
CE is In-The-Money, PE is Out
1 above ATM
OTM1
ITM1
CE is Out-The-Money, PE is In
2 above ATM
OTM2
ITM2
CE is Out-The-Money, PE is In
Label Logic:
Strikes below ATM: CE is ITM, PE is OTM
Strikes above ATM: CE is OTM, PE is ITM
ATM strike: Both CE and PE are labeled as ATM
Exchange Mapping
NSE_INDEX
NFO
NIFTY, BANKNIFTY, FINNIFTY
BSE_INDEX
BFO
SENSEX, BANKEX
NSE
NFO
RELIANCE, TCS, INFY
BSE
BFO
Stock options on BSE
Error Response
Common Error Messages
Invalid openalgo apikey
API key is incorrect or expired
Check API key in settings
No strikes found for {symbol}
Expiry doesn't exist in database
Check expiry date format
Failed to fetch LTP for {symbol}
Underlying quote not available
Check underlying symbol/exchange
Failed to determine ATM strike
No valid strikes near current price
Check if market is open
Expiry date is required
Missing expiry for non-future
Provide expiry_date parameter
Master contract needs update
Symbol database is outdated
Update master contract data
Use Cases
1. Fetch Full Option Chain for Analysis
Use this to get all available strikes for comprehensive analysis.
2. Fetch 10 Strikes Around ATM
Returns 10 strikes above and 10 strikes below ATM (21 total including ATM).
3. Find ATM Strike and Premium
Use the response to identify:
ATM strike from
atm_strikefieldATM CE and PE premiums from chain items where
labelis "ATM"
4. Calculate Put-Call Ratio (PCR)
Sum OI from all PE options and divide by sum of OI from all CE options:
5. Identify Max Pain
Strike with maximum combined OI for CE and PE indicates potential max pain level.
Index Reference
NIFTY
NSE_INDEX
50
25
BANKNIFTY
NSE_INDEX
100
15
FINNIFTY
NSE_INDEX
50
25
MIDCPNIFTY
NSE_INDEX
25
50
SENSEX
BSE_INDEX
100
10
BANKEX
BSE_INDEX
100
15
Features
Full Chain Support: Returns entire option chain when strike_count is not provided
Separate CE/PE Labels: Each option has its own ITM/OTM/ATM label
Real-time Quotes: Fetches live LTP, bid, ask, volume, and OI for all strikes
Future as Underlying: Supports using futures for ATM calculation
Stock Options: Works for both index and stock options
Comprehensive Data: Includes lotsize and tick_size for each option
Rate Limiting
Limit: 10 requests per second
Scope: Per API endpoint
Response: 429 status code if limit exceeded
Best Practices
Use strike_count for Performance: Limit strikes when full chain is not needed
Cache Results: Option chain data can be cached for short periods (5-10 seconds)
Handle Null Values: CE or PE can be null if symbol doesn't exist
Check Market Hours: Quotes may be stale outside market hours
Update Master Contracts: Ensure symbol database is current for accurate results
Use Correct Expiry Format: Always use DDMMMYY format (e.g., 30DEC25)
Integration Examples
Python Example
JavaScript Example
Last updated
Was this helpful?