Skip to content

Get Option Chain

The Get Option Chain APIs enable you to find all option scrip code for the usderlaying instrument.

using scrip code you can subscrib for websocket data

POST: /api/optionChain

https://connect.thefirstock.com/api/optionChain

Request Details

Parameter Description
userId Logged in User Id
exchange Exchange - NFO
tradingSymbol Trading Symbol (use url encoding to avoid special char error for symbols like M&M) NSE NFO.
strikePrice Mid price for option chain selection
count Number of strike to return on one side of the mid price for PUT and CALL. (example cnt is 4, total 16 contracts will be returned, if cnt is is 5 total 20 contract will be returned)
jKey Key Obtained on login success.

Code

from thefirstock import thefirstock

OC = thefirstock.firstock_OptionChain(
tradingSymbol='BANKNIFTY28APR22C37400',
exchange='NFO',
strikePrice="37400",
count="5",
)
 curl -X POST 'https://connect.thefirstock.com/api/optionChain' \
    -H 'Content-Type: application/json' \
    -d '{
    "userId": "",
    "jKey": "",
    "exchange": "",
    "tradingSymbol": "",
    "strikePrice": "",
    "count": ""
    }'
 const Firstock = require('thefirstock');

 const firstock = new Firstock();

 firstock.getOptionChain({
    tradingSymbol: "",
    exchange: "",
    strikePrice: "",
    count: ""
 }, (err, result) => {
 console.log("Error, ", err)
 console.log("Result: ", result)
 })
using thefirstock;

class Program
{
public static void Main()
{
    Firstock firstock = new Firstock();
    var result = firstock.getOptionChain(exchange: "NFO", tradingSymbol: "BANKNIFTY28APR22C37400", strikePrice: "37400", count: "5");
}
}

Response Details

Response data will be in json format with below fields.

Parameter Description
stat Market watch success or failure indication.
values Array of json objects. (object fields given in below table)
emsg This will be present only in case of errors. That is : 1) Invalid Input 2) Session Expired

Response Details: Json Fields of object in values Array

Parameter Description
exch NFO
tsym Trading symbol of the scrip (contract)
token Token of the scrip (contract)
optt Option Type
strprc Strike price
pp Price precision
ti Tick size
ls Lot size
request_time 20:40:01 19-05-2020

Sample Response

{
"stat": "Ok",
"values": [
{
  "exch": "NFO",
  "token": "48831",
  "tsym": "BANKNIFTY02JUN22C35500",
  "optt": "CE",
  "pp": "2",
  "ls": "25",
  "ti": "0.05",
  "strprc": "35500.00"
},
{
  "exch": "NFO",
  "token": "48834",
  "tsym": "BANKNIFTY02JUN22C35600",
  "optt": "CE",
  "pp": "2",
  "ls": "25",
  "ti": "0.05",
  "strprc": "35600.00"
},
{
  "exch": "NFO",
  "token": "48840",
  "tsym": "BANKNIFTY02JUN22C35700",
  "optt": "CE",
  "pp": "2",
  "ls": "25",
  "ti": "0.05",
  "strprc": "35700.00"
},
{
  "exch": "NFO",
  "token": "48848",
  "tsym": "BANKNIFTY02JUN22C35800",
  "optt": "CE",
  "pp": "2",
  "ls": "25",
  "ti": "0.05",
  "strprc": "35800.00"
},
{
  "exch": "NFO",
  "token": "48851",
  "tsym": "BANKNIFTY02JUN22C35900",
  "optt": "CE",
  "pp": "2",
  "ls": "25",
  "ti": "0.05",
  "strprc": "35900.00"
},
{
  "exch": "NFO",
  "token": "48829",
  "tsym": "BANKNIFTY02JUN22C35400",
  "optt": "CE",
  "pp": "2",
  "ls": "25",
  "ti": "0.05",
  "strprc": "35400.00"
},
{
  "exch": "NFO",
  "token": "48825",
  "tsym": "BANKNIFTY02JUN22C35300",
  "optt": "CE",
  "pp": "2",
  "ls": "25",
  "ti": "0.05",
  "strprc": "35300.00"
},
{
  "exch": "NFO",
  "token": "48823",
  "tsym": "BANKNIFTY02JUN22C35200",
  "optt": "CE",
  "pp": "2",
  "ls": "25",
  "ti": "0.05",
  "strprc": "35200.00"
},
{
  "exch": "NFO",
  "token": "48818",
  "tsym": "BANKNIFTY02JUN22C35100",
  "optt": "CE",
  "pp": "2",
  "ls": "25",
  "ti": "0.05",
  "strprc": "35100.00"
},
{
  "exch": "NFO",
  "token": "48816",
  "tsym": "BANKNIFTY02JUN22C35000",
  "optt": "CE",
  "pp": "2",
  "ls": "25",
  "ti": "0.05",
  "strprc": "35000.00"
},
{
  "exch": "NFO",
  "token": "48833",
  "tsym": "BANKNIFTY02JUN22P35500",
  "optt": "PE",
  "pp": "2",
  "ls": "25",
  "ti": "0.05",
  "strprc": "35500.00"
},
{
  "exch": "NFO",
  "token": "48839",
  "tsym": "BANKNIFTY02JUN22P35600",
  "optt": "PE",
  "pp": "2",
  "ls": "25",
  "ti": "0.05",
  "strprc": "35600.00"
},
{
  "exch": "NFO",
  "token": "48847",
  "tsym": "BANKNIFTY02JUN22P35700",
  "optt": "PE",
  "pp": "2",
  "ls": "25",
  "ti": "0.05",
  "strprc": "35700.00"
},
{
  "exch": "NFO",
  "token": "48849",
  "tsym": "BANKNIFTY02JUN22P35800",
  "optt": "PE",
  "pp": "2",
  "ls": "25",
  "ti": "0.05",
  "strprc": "35800.00"
},
{
  "exch": "NFO",
  "token": "48853",
  "tsym": "BANKNIFTY02JUN22P35900",
  "optt": "PE",
  "pp": "2",
  "ls": "25",
  "ti": "0.05",
  "strprc": "35900.00"
},
{
  "exch": "NFO",
  "token": "48830",
  "tsym": "BANKNIFTY02JUN22P35400",
  "optt": "PE",
  "pp": "2",
  "ls": "25",
  "ti": "0.05",
  "strprc": "35400.00"
},
{
  "exch": "NFO",
  "token": "48828",
  "tsym": "BANKNIFTY02JUN22P35300",
  "optt": "PE",
  "pp": "2",
  "ls": "25",
  "ti": "0.05",
  "strprc": "35300.00"
},
{
  "exch": "NFO",
  "token": "48824",
  "tsym": "BANKNIFTY02JUN22P35200",
  "optt": "PE",
  "pp": "2",
  "ls": "25",
  "ti": "0.05",
  "strprc": "35200.00"
},
{
  "exch": "NFO",
  "token": "48822",
  "tsym": "BANKNIFTY02JUN22P35100",
  "optt": "PE",
  "pp": "2",
  "ls": "25",
  "ti": "0.05",
  "strprc": "35100.00"
},
{
  "exch": "NFO",
  "token": "48817",
  "tsym": "BANKNIFTY02JUN22P35000",
  "optt": "PE",
  "pp": "2",
  "ls": "25",
  "ti": "0.05",
  "strprc": "35000.00"
}
]
} 
{
"stat": "Not_Ok",
"request_time": "20:40:01 19-05-2020",
"emsg": "Error Occurred : 2 \"invalid input\""
}