# Statistics

> Live counts of active alerts and GLM lightning, how fast each NWS alert feed delivers, and daily lightning totals in any time zone.

API reference · Reference · https://wxalerts.org/docs/api/stats/

Base URL: `https://api.wxalerts.org`

The headline numbers on this site: how many alerts are in effect, how much
lightning the GOES satellites are seeing, how quickly each alert feed delivers,
and lightning per day.

`/stats/summary` and `/stats/latency` need no key. They are limited per address
as described under [rate limits](/docs/developers/rate-limits/).
`/stats/lightning/daily` **needs an [API key](/docs/developers/api-keys/)**
(`alerts:read`) and is served only under `/v1`; on the bare path it answers
`401` with code `api_key_required`. The two public routes are also served under
`/v1` with the same scope. See [Conventions](/docs/api/conventions/#bare-paths-and-v1)
for what the prefix changes.

Browsers block calls from other websites (CORS allows only wxalerts.org), so
call them from a server, script or app. For the alerts counted here see the
[alerts](/docs/api/alerts/) routes.

Timestamps end in `Z`. `day` is a plain date (`YYYY-MM-DD`) in the requested
time zone.

## Shared errors

| Status | Body | When |
| --- | --- | --- |
| 401 | `{"detail": {"code": "api_key_required", "message": "..."}}` | `/stats/lightning/daily` on the bare path, or `/v1` with no key |
| 401 | `{"detail": {"code": "api_key_invalid", "message": "..."}}` | A key was sent and is unknown, revoked or expired |
| 403 | `{"detail": {"code": "insufficient_scope", "message": "...", "scope": "alerts:read"}}` | The key lacks `alerts:read` |
| 422 | `{"detail": [{"type": "...", "loc": ["query", "days"], "msg": "...", "input": "..."}]}` | A parameter is out of bounds or not the right type |
| 429 | `{"detail": {"code": "rate_limited", "message": "..."}}` with `Retry-After` and `RateLimit-*` | Over the address or key budget |

See [Errors](/docs/developers/errors/) for the whole list.

## `GET /stats/summary`

Active alert counts and the GLM lightning window. No parameters. Public; also at
`/v1/stats/summary`.

The lightning window is whatever the live store holds, measured and not
assumed: read its length from `window_seconds`, and branch on `covers_full_day`
before calling the count a day's worth. Even then it is a rolling window and
never a calendar day, so do not label it "today". For lightning per day use
`/v1/stats/lightning/daily`.

| Field | Type | Description |
| --- | --- | --- |
| `server_time` | timestamp | The database clock |
| `alerts.active` | integer | Alerts currently in effect, the set every alerts route counts |
| `alerts.with_geometry` | integer | The subset that have a shape and can be drawn on a map |
| `lightning.flashes` | integer | GLM flashes between `window_start` and `window_end` |
| `lightning.window_start` | timestamp or null | The oldest flash the live store holds. Null when it holds none |
| `lightning.window_end` | timestamp or null | The newest flash the live store holds. Null when it holds none |
| `lightning.window_seconds` | integer | The span between those two |
| `lightning.rate_per_minute` | number | `flashes` over that span, per minute |
| `lightning.retention_hours` | number | How long the live store keeps flashes; the hard ceiling on any window (24) |
| `lightning.covers_full_day` | boolean | Whether the window spans a full 24 hours. A rolling 24 hours is still not a calendar day |

```json
{
  "server_time": "2026-11-09T19:07:18.638865Z",
  "alerts": {"active": 370, "with_geometry": 370},
  "lightning": {
    "flashes": 1214878,
    "window_start": "2026-11-08T19:30:00.010682Z",
    "window_end": "2026-11-09T19:46:39.319450Z",
    "window_seconds": 87399,
    "rate_per_minute": 834.0,
    "retention_hours": 24.0,
    "covers_full_day": true
  }
}
```

Caching: `Cache-Control: public, max-age=15`, about the data's own cadence, so
polling faster gets the same answer. There is no `ETag` because the payload is
a few hundred bytes.

## `GET /stats/lightning/daily`

GLM flash counts per day, with days cut in any time zone. **Key only:**
`GET /v1/stats/lightning/daily` with `alerts:read`.

Pick the zone your readers live in: a UTC day ends in the evening across the
Americas, so in UTC an evening storm lands on the next day. Days come newest
first: today and the whole days before it, cut at midnight in `timezone`, so
`days=7` is at most seven rows. A day with no flashes at all has no row.
Today's row is still filling in, so use `hours_observed` to tell a partial day
from a complete one. Finished days never change.

| Name | In | Type | Required | Default | Bounds and notes |
| --- | --- | --- | --- | --- | --- |
| `days` | query | integer | no | 30 | 1 to 400. How far back to look, in days from now |
| `timezone` | query | string | no | `UTC` | An IANA zone name such as `America/Chicago`. An unknown zone is a `422`, never a silent fall back to UTC |

| Field | Type | Description |
| --- | --- | --- |
| `server_time` | timestamp | The database clock |
| `timezone` | string | The IANA zone the days are bucketed in |
| `days` | array | One row per local day, newest first |
| `days[].day` | date | The local date in the requested zone |
| `days[].flashes` | integer | Flashes that day |
| `days[].peak_hourly_flashes` | integer or null | Busiest single hour of the day, a severity signal a total hides |
| `days[].hours_observed` | integer | Hourly buckets that carried at least one flash. Well under 24 on a quiet day, but also on a broken one: check it before reading a low count as fair weather |
| `days[].mean_energy_j` | number or null | Mean cloud-top optical energy per flash, in joules. Not a ground-hazard proxy |
| `days[].first_flash`, `days[].last_flash` | timestamp or null | The first and last flash of that day, UTC |

```json
{
  "server_time": "2026-11-09T19:07:13.249615Z",
  "timezone": "America/Chicago",
  "days": [
    {
      "day": "2026-11-09",
      "flashes": 238705,
      "peak_hourly_flashes": 40928,
      "hours_observed": 11,
      "mean_energy_j": 2.0169939528190287e-13,
      "first_flash": "2026-11-09T06:00:00.096895Z",
      "last_flash": "2026-11-09T16:59:59.906157Z"
    }
  ]
}
```

| Status | Body | When |
| --- | --- | --- |
| 422 | `{"detail": "Unknown IANA time zone: 'Mars/Base'"}` (a plain string) | `timezone` is not a known zone |
| 422 | validation array | `days` outside 1 to 400 |

Caching: `Cache-Control: public, max-age=3600` (`private` on `/v1`). Finished
days never change.

## `GET /stats/latency`

How fast each alert feed delivers, measured against the others. Public; also at
`/v1/stats/latency`.

The same hazards arrive from three feeds (`nwws`, `emwin` and `api`) and each
feed's first delivery of each hazard is recorded. Sources come most wins first.
The relative figures (`wins`, `win_share`, `median_behind_seconds` and friends)
are exact to the millisecond and are the fair way to rank the feeds.
`median_issuance_lag_seconds` is measured from the NWS issuance stamp, which is
quantized to the minute, so treat it as an order of magnitude.

| Name | In | Type | Required | Default | Bounds and notes |
| --- | --- | --- | --- | --- | --- |
| `hours` | query | integer | no | 24 | 1 to 168. The ingest prunes receipts on a rolling schedule, so asking for more than it keeps returns a short answer rather than an error |

| Field | Type | Description |
| --- | --- | --- |
| `server_time` | timestamp | The database clock |
| `window_hours` | integer | The window reported over |
| `issuance_resolution_seconds` | integer | Resolution of the NWS issuance timestamp (60). Every absolute lag carries up to this much quantization. Relative figures are unaffected |
| `sources` | array | One row per feed, most wins first |
| `sources[].source` | string | `nwws` (NWWS-OI over XMPP), `emwin` (the GOES broadcast) or `api` (the api.weather.gov CAP feed) |
| `sources[].arrivals` | integer | Hazards this feed delivered in the window |
| `sources[].contested` | integer | The subset also delivered by at least one other feed, the only fair comparison |
| `sources[].wins` | integer | Contested hazards this feed reached us first with |
| `sources[].win_share` | number | `wins / contested`, 0.0 when nothing was contested |
| `sources[].exclusive` | integer | Hazards no other feed carried in the window. Coverage rather than speed |
| `sources[].median_behind_seconds` | number or null | Median gap behind the fastest feed, over contested hazards only. Null when none were contested |
| `sources[].p95_behind_seconds` | number or null | 95th percentile of the same gap |
| `sources[].max_behind_seconds` | number or null | Largest gap. Catches outliers such as a feed that dropped and caught up later; quote the median and p95 instead |
| `sources[].median_issuance_lag_seconds` | number or null | Median issuance to arrival. Minute quantized; indicative only |

```json
{
  "server_time": "2026-11-09T19:07:19.262194Z",
  "window_hours": 24,
  "issuance_resolution_seconds": 60,
  "sources": [
    {
      "source": "nwws",
      "arrivals": 241,
      "contested": 241,
      "wins": 236,
      "win_share": 0.9793,
      "exclusive": 0,
      "median_behind_seconds": 0.0,
      "p95_behind_seconds": 0.0,
      "max_behind_seconds": 9229.67,
      "median_issuance_lag_seconds": 58.6
    }
  ]
}
```

Errors: `422` when `hours` is outside 1 to 168. Caching: `Cache-Control: public,
max-age=60`.
