---
title: Status
sidebar_position: 1
---

Get the past, present, or future status for a stock market. The endpoint will respond with "open" for trading days or "closed" for weekends or market holidays.

import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

## Endpoint
```
https://api.marketdata.app/v1/markets/status/
```
#### Method
```
GET
```
## Request Example

<Tabs>
<TabItem value="HTTP" label="HTTP" default>

**GET** [https://api.marketdata.app/v1/markets/status/?from=2020-01-01&to=2020-12-31](https://api.marketdata.app/v1/markets/status/?from=2020-01-01&to=2020-12-31)

**GET** [https://api.marketdata.app/v1/markets/status/?date=yesterday](https://api.marketdata.app/v1/markets/status/?date=yesterday)

</TabItem>
<TabItem value="NodeJS" label="NodeJS">

```js title="app.js"
fetch(
  "https://api.marketdata.app/v1/markets/status/?from=2020-01-01&to=2020-12-31"
)
  .then((res) => {
    console.log(res);
  })
  .catch((err) => {
    console.log(err);
  });

fetch("https://api.marketdata.app/v1/markets/status/?date=yesterday")
  .then((res) => {
    console.log(res);
  })
  .catch((err) => {
    console.log(err);
  });
```

</TabItem>
<TabItem value="Python" label="Python">

```python title="app.py"
from marketdata.client import MarketDataClient

client = MarketDataClient()
status1 = client.markets.status(from_date="2020-01-01", to_date="2020-12-31")
status2 = client.markets.status(date="yesterday")

print(status1)
print(status2)
```

</TabItem>
<TabItem value="Go" label="Go">

```go title="marketstatus.go"

import (
  "fmt"

  api "github.com/MarketDataApp/sdk-go"
)

func ExampleMarketStatus() {
	msr, err := api.MarketStatus().From("2020-01-01").To("2020-12-31").Get()
	if err != nil {
		fmt.Print(err)
		return
	}

	for _, report := range msr {
		fmt.Println(report)
	}
}

func ExampleMarketStatus_relativeDates() {
	msr, err := api.MarketStatus().Date("yesterday").Get()
	if err != nil {
		fmt.Print(err)
		return
	}

	for _, report := range msr {
		fmt.Println(report)
	}
}
```

</TabItem>
</Tabs>

## Response Example

```json
{
  "s": "ok",
  "date": [1680580800],
  "status": ["open"]
}
```

## Request Parameters

<Tabs>
<TabItem value="required" label="Required">

- There are no required parameters for `status`. If no parameter is given, the request will return the market status in the United States for the current day.

</TabItem>
<TabItem value="optional" label="Optional" default>

- **country** `string`

  Use to specify the country. Use the two digit ISO 3166 country code. If no country is specified, `US` will be assumed. Only countries that Market Data supports for stock price data are available (currently only the United States).

- **date** `date`

  Consult whether the market was open or closed on the specified date. Accepted timestamp inputs: ISO 8601, unix, spreadsheet, relative date strings.

- **from** `date`

  The earliest date (inclusive). If you use countback, from is not required. Accepted timestamp inputs: ISO 8601, unix, spreadsheet, relative date strings.

- **to** `date`

  The last date (inclusive). Accepted timestamp inputs: ISO 8601, unix, spreadsheet, relative date strings.

- **countback** `number`

  Countback will fetch a number of dates before `to` If you use from, countback is not required.

</TabItem>
</Tabs>

## Response Attributes

<Tabs>
<TabItem value="Success" label="Success" default>

- **s** `string`

  ll always be `ok` when there is data for the dates requested.

- **date** `array[dates]`

  The date.

- **status** `array[string]`

  The market status. This will always be `open` or `closed` or `null`. Half days or partial trading days are reported as `open`. Requests for days further in the past or further in the future than our data will be returned as `null`.

</TabItem>
<TabItem value="NoData" label="No Data">

- **s** `string`

  Status will be `no_data` if no data is found for the request.

</TabItem>
<TabItem value="Error" label="Error">

- **s** `string`

  Status will be `error` if the request produces an error response.

- **errmsg** `string`
  An error message.

</TabItem>
</Tabs>
