Market Timings
Get market timings of a date
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/market/timings/2024-01-22' \
--header 'Accept: application/json'
import requests
url = 'https://api.upstox.com/v2/market/timings/2024-01-22'
headers = {'Accept': 'application/json'}
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 = {
'Accept': 'application/json'
};
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("Accept", "application/json")
.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(
'Accept: application/json'
);
$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();
}
}
}