GET/us/market/status
Market Status
API to retrieve the live status of the US market. Use it to check whether the US market is open right now, for example before you place an order.
The response gives the current market status, such as NORMAL_OPEN or NORMAL_CLOSE, and the time the status last changed. To get the open and close times for a specific date, use Market Timings. To see which days the market is closed, use Market Holidays.
Request
curl --location 'https://api.upstox.com/v2/us/market/status' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'
For samples in other languages, see the Sample Code section on this page.
Responses
- 200
Response Body
{
"status": "success",
"data": {
"exchange": "US_EQ",
"status": "NORMAL_OPEN",
"last_updated": 1792762200000
}
}
| Name | Type | Description |
|---|---|---|
| status | string | Outcome of the request. Typically success. |
| data | object | Status of the US market. |
| data.exchange | string | Segment. Always US_EQ. |
| data.status | string | Current market status, for example NORMAL_OPEN or NORMAL_CLOSE. |
| data.last_updated | number | When the status last changed, as epoch milliseconds. |
Sample Code
Get the US market status
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
- PHP SDK
- .NET SDK
import requests
url = 'https://api.upstox.com/v2/us/market/status'
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
}
response = requests.get(url, headers=headers)
print(response.status_code)
print(response.json())
const axios = require('axios');
const url = 'https://api.upstox.com/v2/us/market/status';
const headers = {
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
};
axios.get(url, { headers })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error.response ? error.response.data : error.message);
});
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 {
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.upstox.com/v2/us/market/status"))
.header("Accept", "application/json")
.header("Authorization", "Bearer {your_access_token}")
.GET()
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
}
}
<?php
$url = 'https://api.upstox.com/v2/us/market/status';
$headers = [
'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.UsMarketHolidaysAndTimingsApi(upstox_client.ApiClient(configuration))
try:
api_response = api_instance.get_us_market_status()
print(api_response)
except ApiException as e:
print("Exception when calling UsMarketHolidaysAndTimingsApi->get_us_market_status: %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.USMarketHolidaysAndTimingsApi();
apiInstance.getUsMarketStatus((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.UsMarketHolidaysAndTimingsApi;
public class Main {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
OAuth OAUTH2 = (OAuth) defaultClient.getAuthentication("OAUTH2");
OAUTH2.setAccessToken("{your_access_token}");
UsMarketHolidaysAndTimingsApi apiInstance = new UsMarketHolidaysAndTimingsApi();
try {
GetMarketStatusResponse result = apiInstance.getUsMarketStatus();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsMarketHolidaysAndTimingsApi#getUsMarketStatus");
e.printStackTrace();
}
}
}
<?php
$config = (new Upstox\Client\Configuration())
->setAccessToken('{your_access_token}');
$apiInstance = new Upstox\Client\Api\USMarketHolidaysAndTimingsApi(
new GuzzleHttp\Client(),
$config
);
try {
$result = $apiInstance->getUsMarketStatus();
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling USMarketHolidaysAndTimingsApi->getUsMarketStatus: ' . $e->getMessage();
}
using UpstoxClient.Api;
using UpstoxClient.Client;
using UpstoxClient.Extensions;
using UpstoxClient.Model;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
var host = Host.CreateDefaultBuilder()
.ConfigureApi((context, services, options) =>
{
options.AddTokens(new OAuthToken("{your_access_token}"));
}).Build();
await host.StartAsync();
var apiInstance = host.Services.GetRequiredService<IUSMarketHolidaysAndTimingsApi>();
try
{
var response = await apiInstance.GetUsMarketStatusAsync();
Console.WriteLine(response.RawContent);
}
catch (Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}
await host.StopAsync();