Use the stock market holidays api to get the open/closed status for any day in the past, present, or future. The market status endpoint will return either “open” or “closed” depending on whether there was trading activity on the date(s) requested.
By default Market Data’s API uses Unix timestamps. However, for improved readability, we’ve prepared this article below using human-readable timestamps. Using the optional dateformat parameter, you can control how Market Data outputs dates in all endpoints.
Consulting Today’s Open/Closed Status
Endpoint: https://api.marketdata.app/v1/markets/status/
If you call the endpoint without any optional parameters, it will provide a response about the current trading day in the United States:
{"s": "ok","date":["2023-04-27"],"status": ["open"]}
Getting The Market Status for a Range of Dates
To verify the open/close status for a range of dates, just add the from and to parameters, as you would on the rest of the Market Data endpoints. This will return an array of dates and open/close status. Relative date keywords such as “today”, “yesterday”, “tomorrow” and “now” are also supported. Use countback together with “to” if you want a specific number of days.
Example queries:
- All of 2020
- Yesterday through Tomorrow
- Last 7 Days, Including Today
Stock Market Holidays API: Using The Country Parameter
Only “US” is supported as a country parameter at this time. However, this will change as Market Data adds additional countries. For each country Market Data adds, the Market Status endpoint will be updated to include its holiday dates. This parameter can be safely omitted and the endpoint will assume the user is requesting the United States.