Exchange Status
API to retrieve the market status for a particular exchange.
Path Parameters
Name | Required | Type | Description |
---|---|---|---|
exchange | true | string | The unique identifier for an exchange for which market status data is being queried. For the regex pattern applicable to this field, see the Field Pattern Appendix. |
Request
curl --location 'https://api.upstox.com/v2/market/status/NSE' \
--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.
Responses
- 200
- 4XX
Response Body
{
"status": "success",
"data": {
"exchange": "NSE",
"status": "NORMAL_OPEN",
"last_updated": 1705549500000
}
}
Name | Type | Description |
---|---|---|
status | string | A string indicating the outcome of the request. Typically success for successful operations. |
data | object | Data object holding market status information for an exchange. |
data.exchange | string | Exchange to which the market status is associated. Valid exchanges can be found in the Exchange Appendix |
data.status | string | Current exchange status. Valid market statuses can be found in the Market Status Appendix |
data.last_updated | number | The timestamp at which the market status was last updated. |
Error codes
Error code | Description |
---|---|
UDAPI1089 | Invalid exchange - The provided exchange does not confirm to the accepted format. |
Sample Code
Get market status for a particular exchange
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
import requests
url = 'https://api.upstox.com/v2/market/status/NSE'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
}
response = requests.get(url, headers=headers)
print(response.json())
const axios = require('axios');
const url = 'https://api.upstox.com/v2/market/status/NSE';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
};
axios.get(url, { 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 Hello {
public static void main(String[] args) throws URISyntaxException, IOException, InterruptedException {
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI("https://api.upstox.com/v2/market/status/NSE"))
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.header("Authorization", "Bearer {your_access_token}")
.GET()
.build();
HttpClient client = HttpClient.newHttpClient();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$url = 'https://api.upstox.com/v2/market/status/NSE';
$headers = array(
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}'
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if(curl_errno($ch)) {
echo 'Error: ' . curl_error($ch);
} else {
echo $response;
}
curl_close($ch);
?>
import upstox_client
from upstox_client.rest import ApiException
configuration = upstox_client.Configuration()
configuration.access_token = "{your_access_token}"
api_instance = upstox_client.MarketHolidaysAndTimingsApi(upstox_client.ApiClient(configuration))
try:
api_response = api_instance.get_market_status("NSE")
print(api_response)
except ApiException as e:
print("Exception when calling MarketHolidaysAndTimingsApi: %s\n" %e)
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.MarketHolidaysAndTimingsApi();
apiInstance.getMarketStatus("NSE",(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.GetMarketStatusResponse;
import com.upstox.auth.OAuth;
import io.swagger.client.api.MarketHolidaysAndTimingsApi;
public class Main {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
OAuth OAUTH2 = (OAuth) defaultClient.getAuthentication("OAUTH2");
OAUTH2.setAccessToken("{your_access_token}");
MarketHolidaysAndTimingsApi apiInstance = new MarketHolidaysAndTimingsApi();
try {
GetMarketStatusResponse result = apiInstance.getMarketStatus("NSE");
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling API= " + e.getResponseBody());
e.printStackTrace();
}
}
}
Loading...