# Service Outages

Market Data, as stated in our [terms of service](https://www.marketdata.app/terms/), makes no representation as to the reliability, availability, or timeliness of our service. **This is not just a standard disclaimer.** We have not yet been able to achieve 99.9% reliability, which is a metric we consider a minimum level of reliability that is needed to operate without a backup provider.

**Market Data is a low cost provider** and we have determined that cost, rather than reliability, is our key driver. While we hope to achieve 99.9% reliability in the future, our focus will remain on keeping down costs and avoiding price increases for our users.

> [!TIP]
> **Recommendation**
>
> We highly encourage users with mission critical applications to have a backup provider or utilize Market Data as their secondary provider.

## How To Confirm Downtime

Market Data provides real-time status monitoring for each of our API endpoints. You can check the status of individual endpoints either through our status webpage or programmatically via our status API endpoint.

### Status Webpage

Visit our [status page](https://www.marketdata.app/status/) to view the current status of all Market Data API endpoints, including historical uptime statistics.

- Status Page: [https://www.marketdata.app/status/](https://www.marketdata.app/status/)

### Confirm Downtime Programmatically

Use the [status endpoint](https://www.marketdata.app/docs/api/utilities/status) at `https://api.marketdata.app/status/` to programmatically check the status of all Market Data API endpoints. This endpoint returns the current status for each endpoint (e.g., `/v1/stocks/quotes/`, `/v1/options/chain/`, etc.) and will remain online during outages, allowing you to determine which specific endpoints are affected. Unlike every other endpoint, the status endpoint is not versioned: it is served at `/status/`, not under `/v1/`.

> [!TIP]
> This endpoint is ideal to allow for automatic switching between Market Data and your backup provider when specific endpoints are down.

### JavaScript

```js title="status.js"
import { MarketDataClient } from "@marketdata/sdk";

const client = new MarketDataClient();

// Look up the status of a specific endpoint in the API status response.
function findEndpointStatus(status, endpointPath) {
  const index = status.service.indexOf(endpointPath);
  if (index === -1) return null;
  return {
    online: status.online[index],
    status: status.status[index],
    uptime30d: status.uptimePct30d?.[index],
    uptime90d: status.uptimePct90d?.[index],
  };
}

try {
  const status = await client.utilities.status();

  const stocksQuotes = findEndpointStatus(status, "/v1/stocks/quotes/");
  const optionsChain = findEndpointStatus(status, "/v1/options/chain/");
  const stocksCandles = findEndpointStatus(status, "/v1/stocks/candles/");

  console.log(`Stocks Quotes: ${stocksQuotes ? (stocksQuotes.online ? "Online" : "Offline") : "Not found"}`);
  console.log(`Options Chain: ${optionsChain ? (optionsChain.online ? "Online" : "Offline") : "Not found"}`);
  console.log(`Stocks Candles: ${stocksCandles ? (stocksCandles.online ? "Online" : "Offline") : "Not found"}`);
} catch (error) {
  console.error("Error fetching API status:", error);
}
```

### TypeScript

```typescript title="status.ts"
import { MarketDataClient } from "@marketdata/sdk";
import type { ApiStatusResponse } from "@marketdata/sdk";

const client = new MarketDataClient();

// Look up the status of a specific endpoint in the API status response.
function findEndpointStatus(status: ApiStatusResponse, endpointPath: string) {
  const index = status.service.indexOf(endpointPath);
  if (index === -1) return null;
  return {
    online: status.online[index],
    status: status.status[index],
    uptime30d: status.uptimePct30d?.[index],
    uptime90d: status.uptimePct90d?.[index],
  };
}

try {
  const status: ApiStatusResponse = await client.utilities.status();

  const stocksQuotes = findEndpointStatus(status, "/v1/stocks/quotes/");
  const optionsChain = findEndpointStatus(status, "/v1/options/chain/");
  const stocksCandles = findEndpointStatus(status, "/v1/stocks/candles/");

  console.log(`Stocks Quotes: ${stocksQuotes ? (stocksQuotes.online ? "Online" : "Offline") : "Not found"}`);
  console.log(`Options Chain: ${optionsChain ? (optionsChain.online ? "Online" : "Offline") : "Not found"}`);
  console.log(`Stocks Candles: ${stocksCandles ? (stocksCandles.online ? "Online" : "Offline") : "Not found"}`);
} catch (error) {
  console.error("Error fetching API status:", error);
}
```

### Python

```python title="status.py"
# Importing the required library
import requests

# URL to the status endpoint
url = "https://api.marketdata.app/status/"
json_data = requests.get(url).json()

# Function to check the status of a specific endpoint
def check_endpoint_status(endpoint_path):
    try:
        index = json_data["service"].index(endpoint_path)
        return {
            "online": json_data["online"][index],
            "status": json_data["status"][index],
            "uptime30d": json_data["uptimePct30d"][index],
            "uptime90d": json_data["uptimePct90d"][index]
        }
    except ValueError:
        return None

# Checking the status of specific endpoints
stocks_quotes = check_endpoint_status("/v1/stocks/quotes/")
options_chain = check_endpoint_status("/v1/options/chain/")
stocks_candles = check_endpoint_status("/v1/stocks/candles/")

print(f"Stocks Quotes: {'Online' if stocks_quotes and stocks_quotes['online'] else 'Offline' if stocks_quotes else 'Not found'}")
print(f"Options Chain: {'Online' if options_chain and options_chain['online'] else 'Offline' if options_chain else 'Not found'}")
print(f"Stocks Candles: {'Online' if stocks_candles and stocks_candles['online'] else 'Offline' if stocks_candles else 'Not found'}")
```

### Java

```java title="Status.java"
import com.marketdata.sdk.MarketDataClient;
import com.marketdata.sdk.utilities.ServiceStatus;
import java.util.List;

try (MarketDataClient client = new MarketDataClient()) {
  List<ServiceStatus> services = client.utilities().status().values();

  for (String path : List.of("/v1/stocks/quotes/", "/v1/options/chain/", "/v1/stocks/candles/")) {
    String state = services.stream()
        .filter(s -> s.service().equals(path))
        .findFirst()
        .map(s -> s.online() ? "Online" : "Offline")
        .orElse("Not found");
    System.out.println(path + ": " + state);
  }
}
```

### Kotlin

```kotlin title="Status.kt"
import com.marketdata.sdk.MarketDataClient

MarketDataClient().use { client ->
    val services = client.utilities().status().values()

    for (path in listOf("/v1/stocks/quotes/", "/v1/options/chain/", "/v1/stocks/candles/")) {
        val svc = services.firstOrNull { it.service() == path }
        val state = svc?.let { if (it.online()) "Online" else "Offline" } ?: "Not found"
        println("$path: $state")
    }
}
```

### C#

```csharp title="Status.cs"
using MarketDataApp;

using var client = await MarketDataClient.CreateAsync();

var services = (await client.Utilities.GetStatusAsync()).Values;

foreach (var path in new[] { "/v1/stocks/quotes/", "/v1/options/chain/", "/v1/stocks/candles/" })
{
    var service = services.FirstOrDefault(s => s.Service == path);
    var state = service is null ? "Not found" : service.Online ? "Online" : "Offline";
    Console.WriteLine($"{path}: {state}");
}
```

## What To Do During Downtime

It is not necessary to advise us of downtime or service outages. We monitor the status of our systems and we investigate and respond to all service outages. During Market Data service outages, we encourage you to switch your systems over to your back-up provider until our systems come back online.
