Market Holidays
Get market holidays for current year
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/market/holidays' \
--header 'Accept: application/json'
import requests
url = 'https://api.upstox.com/v2/market/holidays'
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/holidays';
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/holidays"))
.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/holidays';
$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_holidays()
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.getHolidays((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.GetHolidayResponse;
import io.swagger.client.api.MarketHolidaysAndTimingsApi;
public class Main {
public static void main(String[] args) {
MarketHolidaysAndTimingsApi apiInstance = new MarketHolidaysAndTimingsApi();
try {
GetHolidayResponse result = apiInstance.getHolidays();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling API= " + e.getResponseBody());
e.printStackTrace();
}
}
}
Get market holiday status of a date
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/market/holidays/2024-01-22' \
--header 'Accept: application/json'
import requests
url = 'https://api.upstox.com/v2/market/holidays/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/holidays/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/holidays/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/holidays/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_holiday("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.getHoliday("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.ApiClient;
import com.upstox.ApiException;
import com.upstox.Configuration;
import com.upstox.api.GetHolidayResponse;
import io.swagger.client.api.MarketHolidaysAndTimingsApi;
public class Main {
public static void main(String[] args) {
MarketHolidaysAndTimingsApi apiInstance = new MarketHolidaysAndTimingsApi();
try {
GetHolidayResponse result = apiInstance.getHoliday("2024-01-22");
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling API= " + e.getResponseBody());
e.printStackTrace();
}
}
}