# Market-wide breadth, advance/decline, and sector rotation

`GET https://flow-api.skylit.ai/v1/flow/market-breadth`

API: Flowseeker. Credits: 3.

Combines SPY/QQQ/IWM aggregate sentiment with an advance/decline
ratio (over directional FIR) and per-sector rotation signals. Ideal
as a single "is the market risk-on or risk-off right now" probe.

## Authentication

Send your Skylit API key as a bearer token: `Authorization: Bearer <key>`. No other header is accepted.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `date` | query | string (date) | no | Trading date (YYYY-MM-DD). Defaults to today. |
| `fir_threshold` | query | number (double) | no | Absolute FIR threshold (in %) used to classify a ticker as advancing or declining. Tickers with `\|fir\| < threshold` count as unchanged. (default `10`) |

## Example request

```bash
curl "https://flow-api.skylit.ai/v1/flow/market-breadth" \
  -H "Authorization: Bearer $SKYLIT_API_KEY"
```

## Responses

### 200

Market breadth + advance/decline + sector rotation.

Shape (placeholder values):

```json
{
  "data": {
    "date": "string",
    "majorIndices": [
      {
        "ticker": "string",
        "bullishPremium": 0,
        "bearishPremium": 0,
        "netPremium": 0,
        "fir": 0,
        "sentiment": "strong_bullish"
      }
    ],
    "aggregateSentiment": {
      "combinedBullish": 0,
      "combinedBearish": 0,
      "combinedNetPremium": 0,
      "combinedFir": 0,
      "sentiment": "strong_bullish"
    },
    "advanceDecline": {
      "advancing": 0,
      "declining": 0,
      "unchanged": 0,
      "total": 0,
      "ratio": 0,
      "breadthPct": 0,
      "marketAvgFir": 0
    },
    "sectorRotation": [
      {
        "sector": "string",
        "etf": "string",
        "fir": 0,
        "netPremium": 0,
        "signal": "strong_inflow"
      }
    ]
  },
  "meta": {
    "timestamp": "string",
    "requestId": "d7574836"
  }
}
```

### 400

Request validation failed.

invalidParam:

```json
{
  "error": {
    "code": "BAD_REQUEST",
    "message": "Invalid parameter 'timeframe': must be one of [1m, 5m, 15m, 1h, 4h, 1d, 1w, 1M]"
  }
}
```

### 401

Missing or invalid API key.

missingKey:

```json
{
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Authentication required"
  }
}
```

### 402

The account's shared Skylit credit balance is lower than this route's cost. Top up to continue. Carries `X-Credits-Remaining: 0`.

Headers: `X-Credits-Remaining`.

outOfCredits:

```json
{
  "error": {
    "code": "insufficient_credits",
    "message": "Out of credits. Top up to continue making requests."
  }
}
```

### 403

API key invalid, revoked or expired, or the account's API access is suspended (`account_suspended`).

accountSuspended:

```json
{
  "error": {
    "code": "account_suspended",
    "message": "API access has been suspended for this account. Contact support."
  }
}
```

### 429

Per-minute rate limit exceeded.

Headers: `Retry-After`.

tooFast:

```json
{
  "error": {
    "code": "RATE_LIMITED",
    "message": "Rate limit of 100 req/min exceeded. Retry after 18s."
  }
}
```

### 503

Underlying data source temporarily unavailable, or the credit balance could not be verified (`credit_check_failed`). Safe to retry.

ingestionLag:

```json
{
  "error": {
    "code": "UNAVAILABLE",
    "message": "Live feed is degraded; please retry in a few seconds."
  }
}
```

creditCheckFailed:

```json
{
  "error": {
    "code": "credit_check_failed",
    "message": "Could not verify credit balance. Please retry."
  }
}
```
