Put call option chain
Get put/call option chain
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/option/chain?instrument_key=NSE_INDEX%7CNifty%2050&expiry_date=2024-03-28' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'
import requests
url = 'https://api.upstox.com/v2/option/chain'
params = {
'instrument_key': 'NSE_INDEX|Nifty 50',
'expiry_date': '2024-03-28'
}
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
}
response = requests.get(url, params=params, headers=headers)
print(response.json())
const axios = require('axios');
const url = 'https://api.upstox.com/v2/option/chain';
const params = {
instrument_key: 'NSE_INDEX|Nifty 50',
expiry_date: '2024-03-28'
};
const headers = {
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
};
axios.get(url, { params, headers })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error('Error:', error);
});
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
HttpClient httpClient = HttpClient.newBuilder().build();
HttpRequest request = null;
try {
request = HttpRequest.newBuilder()
.uri(new URI("https://api.upstox.com/v2/option/chain?instrument_key=NSE_INDEX%7CNifty%2050&expiry_date=2024-03-28"))
.header("Accept", "application/json")
.header("Authorization", "Bearer {your_access_token}")
.build();
} catch (URISyntaxException e) {
e.printStackTrace();
}
try {
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
}
<?php
$url = 'https://api.upstox.com/v2/option/chain';
$params = [
'instrument_key' => 'NSE_INDEX|Nifty 50',
'expiry_date' => '2024-03-28'
];
$headers = [
'Accept: application/json',
'Authorization: Bearer {your_access_token}'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . '?' . http_build_query($params));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
import upstox_client
from upstox_client.rest import ApiException
configuration = upstox_client.Configuration()
configuration.access_token = "{your_access_token}"
api_instance = upstox_client.OptionsApi(upstox_client.ApiClient(configuration))
try:
api_response = api_instance.get_put_call_option_chain("NSE_INDEX|Nifty 50", "2024-10-31")
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->options apis: %s\n" % e.body)
let UpstoxClient = require('upstox-js-sdk');
let defaultClient = UpstoxClient.ApiClient.instance;
var OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = "{your_access_token}";
let apiInstance = new UpstoxClient.OptionsApi();
apiInstance.getPutCallOptionChain("NSE_INDEX|Nifty 50","2024-10-31",(error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiClient;
import com.upstox.ApiException;
import com.upstox.Configuration;
import com.upstox.api.GetOptionChainResponse;
import com.upstox.auth.OAuth;
import io.swagger.client.api.OptionsApi;
public class Main {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
OAuth OAUTH2 = (OAuth) defaultClient.getAuthentication("OAUTH2");
OAUTH2.setAccessToken("{your_access_token}");
OptionsApi apiInstance = new OptionsApi();
try {
GetOptionChainResponse result = apiInstance.getPutCallOptionChain("NSE_INDEX|Nifty 50", "2024-10-31");
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling API= " + e.getResponseBody());
e.printStackTrace();
}
}
}