Market Timings
API to retrieve the market timings for each exchange for a particular date.
Request
curl --location 'https://api.upstox.com/v2/market/timings/2024-01-22' \
--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.
Path Parameters
Name | Required | Type | Description |
---|---|---|---|
date | true | string | The date for retrieving market timing information. Format: 'YYYY-MM-DD'. |
Responses
- 200
- 4XX
Response Body
{
"status": "success",
"data": [
{
"exchange": "MCX",
"start_time": 1704079800000,
"end_time": 1704108600000
},
{
"exchange": "NSE",
"start_time": 1704080700000,
"end_time": 1704103200000
},
{
"exchange": "NFO",
"start_time": 1704080700000,
"end_time": 1704103200000
},
{
"exchange": "CDS",
"start_time": 1704079800000,
"end_time": 1704108600000
},
{
"exchange": "BSE",
"start_time": 1704080700000,
"end_time": 1704103200000
},
{
"exchange": "BCD",
"start_time": 1704079800000,
"end_time": 1704108600000
},
{
"exchange": "BFO",
"start_time": 1704080700000,
"end_time": 1704103200000
}
]
}
Name | Type | Description |
---|---|---|
status | string | A string indicating the outcome of the request. Typically success for successful operations. |
data | object | Data object holding information about the market timings |
data[].exchange | string | Exchange for which the market is open. Valid exchanges can be found in the Exchange Appendix |
data[].start_time | number | Timestamp at which market will start. |
data[].end_time | number | Timestamp at which market will end. |
Error codes
Error code | Description |
---|---|
UDAPI1088 | Invalid date - The provided date does not confirm to the accepted format. |
Sample Code
Get market timings of a date
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
import requests
url = 'https://api.upstox.com/v2/market/timings/2024-01-22'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
data = response.json()
# Process the JSON response
print(data)
else:
print("Failed to retrieve data. Status code:", response.status_code)
const axios = require('axios');
const url = 'https://api.upstox.com/v2/market/timings/2024-01-22';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
};
axios.get(url, { headers })
.then(response => {
// Process the JSON 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/timings/2024-01-22"))
.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/timings/2024-01-22';
$headers = array(
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}'
);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
if ($response === false) {
echo 'Error: ' . curl_error($curl);
} else {
// Process the response
echo $response;
}
curl_close($curl);
?>
import upstox_client
from upstox_client.rest import ApiException
configuration = upstox_client.Configuration()
api_instance = upstox_client.MarketHolidaysAndTimingsApi(upstox_client.ApiClient(configuration))
try:
api_response = api_instance.get_exchange_timings("2024-01-22")
print(api_response)
except ApiException as e:
print("Exception when calling MarketHolidaysAndTimingsApi: %s\n" %e)
let UpstoxClient = require('upstox-js-sdk');
let apiInstance = new UpstoxClient.MarketHolidaysAndTimingsApi();
apiInstance.getExchangeTimings("2024-01-22",(error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiException;
import com.upstox.api.GetExchangeTimingResponse;
import io.swagger.client.api.MarketHolidaysAndTimingsApi;
public class Main {
public static void main(String[] args) {
MarketHolidaysAndTimingsApi apiInstance = new MarketHolidaysAndTimingsApi();
try {
GetExchangeTimingResponse result = apiInstance.getExchangeTimings("2024-01-22");
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling API= " + e.getResponseBody());
e.printStackTrace();
}
}
}
Loading...