Open Interest (OI) Dataโ
API for retrieving Open Interest data across all strike prices for an underlying asset on a given expiry and date. It accepts the instrument key, expiry, and date, and returns aggregate call and put OI totals along with a per-strike breakdown of call OI and put OI.
Requestโ
curl --location 'https://api.upstox.com/v2/market/oi?instrument_key=NSE_INDEX%7CNifty%2050&expiry=2026-05-29&date=2026-05-07' \
--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 OI data is required, in YYYY-MM-DD format. |
Responses
- 200
- 4XX
Response bodyโ
{
"status": "success",
"data": {
"total_puts": 12500000,
"total_calls": 9800000,
"spot_closing_price": 24450.75,
"expiry": "2026-05-29",
"call_put_oi_data_list": [
{
"call_oi": 450000,
"put_oi": 680000,
"strike_price": 24000.0
},
{
"call_oi": 1200000,
"put_oi": 950000,
"strike_price": 24500.0
}
]
}
}
| Name | Type | Description |
|---|---|---|
| status | string | Outcome of the request. Typically success for successful operations. |
| data | object | OI data object. |
| data.total_puts | integer | Aggregate put open interest across all strikes. |
| data.total_calls | integer | Aggregate call open interest 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 | OI data for each strike price. |
| data.call_put_oi_data_list[].call_oi | integer | Call open interest at this strike. |
| data.call_put_oi_data_list[].put_oi | integer | Put open interest at this strike. |
| data.call_put_oi_data_list[].strike_price | number | Strike price. |
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. |
Sample Codeโ
Get OI dataโ
- Curl
- Python
- Node.js
- Java
- PHP
curl --location 'https://api.upstox.com/v2/market/oi?instrument_key=NSE_INDEX%7CNifty%2050&expiry=2026-05-29&date=2026-05-07' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'
import requests
url = 'https://api.upstox.com/v2/market/oi'
params = {
'instrument_key': 'NSE_INDEX|Nifty 50',
'expiry': '2026-05-29',
'date': '2026-05-07'
}
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/oi';
const params = {
instrument_key: 'NSE_INDEX|Nifty 50',
expiry: '2026-05-29',
date: '2026-05-07'
};
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/oi"
+ "?instrument_key=NSE_INDEX%7CNifty%2050"
+ "&expiry=2026-05-29"
+ "&date=2026-05-07";
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/oi?'
. http_build_query([
'instrument_key' => 'NSE_INDEX|Nifty 50',
'expiry' => '2026-05-29',
'date' => '2026-05-07',
]);
$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...