Change in Open Interest (OI)โ
API for retrieving the change in Open Interest per strike price for an underlying asset over a specified number of days. It accepts the instrument key, expiry, date, and interval, and returns the net OI change at each strike for both calls and puts โ positive values indicate new positions being built, negative values indicate unwinding.
Requestโ
curl --location 'https://api.upstox.com/v2/market/change-oi?instrument_key=NSE_INDEX%7CNifty%2050&expiry=2026-05-29&date=2026-05-07&interval=2' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'
For additional samples in various languages, please refer to the Sample code section on this page.
Query Parametersโ
| Name | Required | Description |
|---|---|---|
| instrument_key | true | Underlying asset instrument key. For the regex pattern applicable to this field, see the Field Pattern Appendix. |
| expiry | true | Expiry date of the option contract in YYYY-MM-DD format. |
| date | true | Date for which Change in OI data is required, in YYYY-MM-DD format. |
| interval | true | Number of days over which the OI difference is calculated. |
Responses
- 200
- 4XX
Response bodyโ
{
"status": "success",
"data": {
"total_put_change_oi": 2500000,
"total_call_change_oi": -1800000,
"spot_closing_price": 24450.75,
"expiry": "2026-05-29",
"call_put_oi_data_list": [
{
"strike_price": 24000.0,
"call_change_oi": -120000,
"put_change_oi": 350000
},
{
"strike_price": 24500.0,
"call_change_oi": 280000,
"put_change_oi": -150000
}
]
}
}
| Name | Type | Description |
|---|---|---|
| status | string | Outcome of the request. Typically success for successful operations. |
| data | object | Change in OI data object. |
| data.total_put_change_oi | integer | Net change in put OI across all strikes. |
| data.total_call_change_oi | integer | Net change in call OI across all strikes. |
| data.spot_closing_price | number | Closing spot price of the underlying asset. |
| data.expiry | string | Expiry date of the option contract. |
| data.call_put_oi_data_list | array | Change in OI data for each strike price. |
| data.call_put_oi_data_list[].strike_price | number | Strike price. |
| data.call_put_oi_data_list[].call_change_oi | integer | Change in call OI at this strike. Negative values indicate OI unwinding. |
| data.call_put_oi_data_list[].put_change_oi | integer | Change in put OI at this strike. Negative values indicate OI unwinding. |
Error codesโ
| Error code | Description |
|---|---|
| UDAPI100011 | Invalid instrument_key โ The provided instrument_key is invalid or not found. |
| UDAPI1202 | Invalid expiry date format โ The expiry parameter must be in YYYY-MM-DD format. |
| UDAPI1203 | Invalid date format โ The date parameter must be in YYYY-MM-DD format. |
| UDAPI1204 | Invalid interval โ The interval value is not accepted. |
Sample Codeโ
Get Change in OI dataโ
- Curl
- Python
- Node.js
- Java
- PHP
curl --location 'https://api.upstox.com/v2/market/change-oi?instrument_key=NSE_INDEX%7CNifty%2050&expiry=2026-05-29&date=2026-05-07&interval=2' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'
import requests
url = 'https://api.upstox.com/v2/market/change-oi'
params = {
'instrument_key': 'NSE_INDEX|Nifty 50',
'expiry': '2026-05-29',
'date': '2026-05-07',
'interval': 2
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
}
response = requests.get(url, params=params, headers=headers)
print(response.text)
const axios = require('axios');
const url = 'https://api.upstox.com/v2/market/change-oi';
const params = {
instrument_key: 'NSE_INDEX|Nifty 50',
expiry: '2026-05-29',
date: '2026-05-07',
interval: 2
};
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
};
axios.get(url, { params, headers })
.then(response => console.log(response.data))
.catch(error => console.error(error));
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://api.upstox.com/v2/market/change-oi"
+ "?instrument_key=NSE_INDEX%7CNifty%2050"
+ "&expiry=2026-05-29"
+ "&date=2026-05-07"
+ "&interval=2";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.header("Authorization", "Bearer {your_access_token}")
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$url = 'https://api.upstox.com/v2/market/change-oi?'
. http_build_query([
'instrument_key' => 'NSE_INDEX|Nifty 50',
'expiry' => '2026-05-29',
'date' => '2026-05-07',
'interval' => 2,
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}',
]);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);
echo $response;
?>
Loading...