Status and Holidays
Learn to fetch the market status and upcoming holidays.
The marketstatus
endpoint
The marketstatus
endpoint tells us the current status of exchanges and other financial markets. This endpoint determines which markets are open or closed at a given point.
The base URL for this endpoint is as follows:
https://api.polygon.io/v1/marketstatus/now
Request parameters
The marketstatus
endpoint doesn’t require any request parameters other than our API key.
Let’s call the marketstatus
endpoint in the following code. Click “Run” to see the output.
// Importing libraries hereimport fetch from "node-fetch";// Define API key hereconst apiKey = '{{API_KEY}}';// Define endpoint URL hereconst endpointUrl = new URL('https://api.polygon.io/v1/marketstatus/now');// Define Header Parameters hereconst headerParameters = {authorization: `Bearer ${apiKey}`};// Setting API call optionsconst options = {method: 'GET',headers: headerParameters,};// Function to make API callasync function MarketStatus() {try {const response = await fetch(endpointUrl, options);// Custom function for printing the API responseprintResponse(response);}catch (error) {// Custom function for printing the error messageprintError(error);}}// Calling function to make API callMarketStatus();
Here’s an explanation for the above code:
Line 8: We define the endpoint URL.
Lines 11–13: We define the API key in the header parameter.
Lines 16–19: We define the options parameters and set the request type as
GET
.Lines 22–32: We define the function,
MarketStatus
, which calls the endpoint.Lines 23–27: We call the API in a try block and print the response.
Lines 28–31: We define a catch block to catch all errors and exceptions and print them.
Line 35: We call the
MarketStatus
function.
Response fields
The following table gives details about attributes in the response object.
Name | Type | Description |
| Boolean | This is |
| Object | This gives us the current status of |
| Boolean | This is |
| Object | This gives the current status of Nasdaq, NYSE, and otc exchanges. |
| String | This gives the status of the overall market. |
| String | The current time of the server. |
The market holidays endpoint
The stock markets are closed on weekends. However, other regional holidays also affect the market opening and closing times. The market holiday endpoint gives information about market holidays and opening and closing times. Additionally, it provides information on unusual opening hours. This information is important as the market often faces a phenomenon known as the holiday effect, where an increase in trading is observed a day before the holiday.
The base URL for this endpoint is as follows:
https://api.polygon.io/v1/marketstatus/upcoming
Request parameters
This endpoint doesn’t require any input parameters other than our API key. We’ll call the market holiday endpoint in the following code. Click the “Run” button to view the output of this endpoint.
// Importing libraries hereimport fetch from "node-fetch";// Define API key hereconst apiKey = '{{API_KEY}}';// Define endpoint URL hereconst endpointUrl = new URL('https://api.polygon.io/v1/marketstatus/upcoming');// Define Header Parameters hereconst headerParameters = {authorization: `Bearer ${apiKey}`};// Setting API call optionsconst options = {method: 'GET',headers: headerParameters,};// Function to make API callasync function MarketHoliday() {try {const response = await fetch(endpointUrl, options);// Custom function for printing the API responseprintResponse(response);}catch (error) {// Custom function for printing the error messageprintError(error);}}// Calling function to make API callMarketHoliday();
Here’s an explanation for the above code:
Line 8: We define the endpoint URL.
Lines 11–13: We define the API key in the header parameter.
Lines 16–19: We define the options parameters and set the request type as
GET
.Lines 22–32: We define the function,
MarketHoliday
, which calls the endpoint.Lines 23–27: We call the API in a try block and print the response.
Lines 28–31: We define a catch block to catch all errors and exceptions and print them.
Line 35: We call the
MarketHoliday
function.
Response fields
The following table gives details about attributes in the response object.
Name | Type | Description |
| String | The closing time on a holiday. |
| String | The date when the holiday is observed. |
| String | The name of the exchange market. |
| String | The name of the holiday. |
| String | The special opening time of the exchange on the holiday. |
| String | This provides the status of the exchange place on holiday. It will be |