# Conventions

> Base URLs, the bare and /v1 paths, how to authenticate, the scopes, the error format, rate limits, units, timestamps, pagination and caching. What every route shares.

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

The API has no supported OpenAPI document and no interactive documentation.
These pages are the reference, and this one covers what is true of every route. The
per-area pages cover the routes themselves, and the
[route index](/docs/api/rest/#every-route) lists them all.

## Base URL and format

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

Plain HTTPS and JSON, UTF-8. Query parameters are in the URL; request bodies,
where a route takes one, are `application/json`. The API does not compress
responses itself; the edge in front of it does. Parameters are case sensitive,
and an unknown query parameter is ignored rather than refused.

The placefile routes return `text/plain` and the icon sheets `image/png`; every
other route returns JSON.

## Bare paths and `/v1`

Every public read route is served twice:

| | bare path, `/alerts/at` | `/v1` path, `/v1/alerts/at` |
| --- | --- | --- |
| Credential | none needed | an [API key](/docs/developers/api-keys/), the phone app's sign-in, or the website's session cookie. Always required |
| Who is counted | your address (`CF-Connecting-IP`) | the key, or the signed-in account |
| Overall limit | about 120 a minute per address | about 300 a minute per key |
| `Cache-Control` | what the route sets, often `public` | always `private`, with `Vary: Authorization, X-API-Key, Cookie`. `public` and `s-maxage` are removed so a shared cache never stores a keyed answer |
| Scope | none | the route's [scope](#scopes), else `403 insufficient_scope` |
| Key in the URL | n/a | `400 key_in_query` |

Same handlers, same parameters, same response bodies. The prefix changes who is
counted and who may ask, nothing else. A key sent to a bare public path is
accepted and charged to the key instead of your address, so a client can use
one base URL.

Three groups do not follow the pattern:

- **Key-only routes** are served **only** under `/v1`. On the bare path they
  answer `401` with code `api_key_required` and the message names the `/v1`
  path. They are `/alerts/active`, `/alerts/active/geojson`,
  `/stats/lightning/daily`, `/storms/active`, `/storms/{storm_id}`,
  `/storms/couplets/{couplet_id}/cone`, `/forecast/sounding`, `/visibility`,
  `/visibility/point`, `/tropical/for-place`, `/tropical/outlook`,
  `/tropical/storms`, `/tropical/storms/{storm_id}`,
  `/tropical/storms/{storm_id}/models`, `/winter/at`, `/winter/hazards`,
  `/winter/odds` and `/winter/wssi`.
- **`/v1/forecast/raw`** exists only under `/v1`, has no bare path at all, and
  answers only keys WxAlerts has enabled for it. See [Raw model data](/docs/api/raw/).
- **Bare only**, with no `/v1` form that adds anything: `/health` and
  `/health/deep` ([Status](/docs/api/status/)) and the placefile routes, which
  are fetched by radar software that cannot send a header.

Account, sign-in and billing routes are not part of this split. They take a
session or a Bearer token and are under their own pages.

## Authentication

| Method | How it is sent | Where it works |
| --- | --- | --- |
| Anonymous | nothing | bare public paths |
| API key | `X-API-Key: wx_live_...` or `Authorization: Bearer wx_live_...` | `/v1`, and bare public paths |
| App sign-in (native clients) | `Authorization: Bearer <access token>` from the phone app's sign-in | `/v1`, bare public paths and the account routes. A token that does not verify is ignored on a bare public path and is a `401` on `/v1` and on account routes |
| Website session cookie | the cookie the site sets at sign-in | `/v1` (with the same scopes as an app sign-in), and the account routes |

How to make, send and revoke a key is in
[Make, send and revoke an API key](/docs/developers/api-keys/); the key format
and lifetime are on [Authentication](/docs/developers/authentication/). A few
rules apply everywhere:

- A key never goes in the URL. `?key=` or `?api_key=` on `/v1` is `400 key_in_query`.
  (The spotter placefile is the one exception, because radar software cannot send a header.)
- `Authorization: Bearer` carries both keys and app access tokens. A value that
  starts `wx_` is a key; anything else is treated as an access token. The two are
  not interchangeable: an account route given a key answers `401 api_key_not_accepted`.
- A key that is presented and bad is a `401` on bare paths too. It is never
  quietly downgraded to anonymous, so a misconfigured client finds out.
- A signed-in app or browser is treated like a key holding every default
  scope, and is limited per account.
- Cookie authenticated requests that change something (`POST`, `PUT`,
  `PATCH`, `DELETE`) must also send `X-Requested-With: wxalerts`, or they are
  refused with `403` and `{"detail": "Missing X-Requested-With header."}`. Bearer requests do not need it. This only matters if you
  script the website's own account routes; the data routes are all `GET`.

## Scopes

A key reads only what its scopes allow. New keys get every scope except
`placefile:read` unless you choose otherwise; a key without the scope a route
needs gets `403 insufficient_scope`. The app and website sign-ins hold every
default scope.

| Scope | What it opens, under `/v1` |
| --- | --- |
| `alerts:read` | `/alerts/*`, `/stats/*` |
| `weather:read` | `/weather`, `/forecast`, `/forecast/sounding`, `/forecast/raw` (also needs the key to be enabled), `/conditions`, `/stations/*`, `/sky/outlook`, `/visibility/*` |
| `outlooks:read` | `/outlooks/*`, `/tropical/*`, `/winter/*` |
| `storms:read` | `/storms/*`, `/lightning/*` |
| `reports:read` | `/lsr/reports` |
| `locations:read` | `/locations/*` |
| `placefile:read` | the full spotter report placefile. Granted only to meteorologist accounts |

## Errors

Errors are JSON with a `detail` member. There are four shapes, and a client
should handle all of them.

**A coded error.** The key, scope, rate limit and most account errors.
`detail.code` is stable and machine readable; `detail.message` is for people.

```json
{ "detail": { "code": "api_key_required", "message": "This endpoint needs an API key: it is served at /v1/alerts/active. Make one at https://wxalerts.org/account/ and send it as X-API-Key." } }
```

**A plain message.** Most data route errors, such as an unknown place or station.

```json
{ "detail": "No place matched 'xyz'" }
```

**A validation list, `422`.** A parameter or body field is missing, the wrong
type or out of bounds. One entry per problem; see [the 422 format](#the-422-format).

**An unexpected failure, `500`.** Always the same body, so it can be told apart
from the others.

```json
{ "detail": "Something went wrong on our end. Please try again." }
```

A `401` or `403` from the gate also carries a `WWW-Authenticate` header and
`Cache-Control: no-store`, so a cache cannot keep the refusal.

| Status | `detail.code` | Means |
| --- | --- | --- |
| 400 | `key_in_query` | the key was in the URL; move it to a header and revoke it |
| 401 | `api_key_required` | no credential on a route that needs one, or on a key-only path used bare |
| 401 | `api_key_invalid` | the key is unknown, revoked or expired, or is not a WxAlerts key |
| 401 | `api_key_not_accepted` | a key was sent to a route that takes a person's sign-in |
| 403 | `insufficient_scope` | the key lacks the route's scope; the body adds `scope` |
| 403 | `admin_key_required` | `/v1/forecast/raw` with a key that is not enabled for it |
| 404 | none | nothing by that id, or a place or station that matches nothing |
| 429 | `rate_limited` | over a limit; wait `Retry-After` seconds. Some per-route limits send a plain message instead of a coded one |
| 503 | `rate_limit_unavailable` | the shared account limit could not be counted; retry after `Retry-After` |

Other `404`, `409`, `410`, `503` and `422` cases belong to a route, and its page
lists them. [Errors](/docs/developers/errors/) collects them by resource.

### The 422 format

A request that fails validation is answered before the route runs, with the
standard shape: `detail` is a list, one object per problem.

```
GET /locations/search?limit=0
```

```json
{
  "detail": [
    { "type": "missing", "loc": ["query", "q"], "msg": "Field required", "input": null },
    {
      "type": "greater_than_equal",
      "loc": ["query", "limit"],
      "msg": "Input should be greater than or equal to 1",
      "input": "0",
      "ctx": { "ge": 1 }
    }
  ]
}
```

| Member | Meaning |
| --- | --- |
| `type` | the kind of failure: `missing`, `greater_than_equal`, `less_than_equal`, `float_parsing`, `int_parsing`, `string_too_short`, `literal_error` and so on |
| `loc` | where: `["query", "limit"]`, `["path", "station_id"]` or `["body", "reports", 0, "lat"]` |
| `msg` | a sentence |
| `input` | what was sent, as a string for query parameters |
| `ctx` | present for bounds and enums: the limit that was broken |

A route can also raise its own `422` after validation, for a rule that spans
parameters (an inverted `bbox`, two ways of choosing hours). Those use the
plain message form, `{"detail": "bbox must be west<east, south<north, and within the world"}`.
A route page says which kind each case is.

## Rate limits

Limits are token buckets: a burst, then a steady refill. They are held in
memory on each API server, so the figures below are what one address or key
gets across the whole API, and are approximate. The account and admin routes
may be counted separately from the weather routes. Past a limit the answer is
`429` with `Retry-After` in seconds and `Cache-Control: no-store`.

| Who | Limit, approximate |
| --- | --- |
| No credential, per address | 120 requests a minute, burst 60, across every public route together |
| One API key, across every route | 300 requests a minute, burst 120 |
| One signed-in account, on `/v1` and on public routes | the same as a key |
| `/alerts/in-bounds` and `/alerts/ended-in-bounds` | 60 a minute between them, per address or per key, on top of the overall limit |
| `/alerts/active/geojson` | 30 a minute, per key, on top of the overall limit |
| `/forecast/sounding` and `/forecast/raw` | 5 calls in any 60 seconds per **account**, shared by every key on the account and by the two routes together, counted once for every server |
| `POST /visibility/reports` | 60 batches a minute per client |

A key marked as a service key by WxAlerts is counted but never throttled.
Every key currently has the same budget.

**Headers.** A successful response from a credentialed or anonymous request
carries `RateLimit-Limit` (the burst of the bucket that was charged) and
`RateLimit-Remaining` (whole tokens left). Because the buckets are held per
server, these describe the server that answered and can move around between
calls. A `429` adds `RateLimit-Reset` and `Retry-After`, both whole seconds. The shared account
limit sends `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset` on
every call. The headers are exposed to browsers (CORS) so a page can read them.

The practical advice is on [Rate limits](/docs/developers/rate-limits/) and
[Poll the weather API politely](/docs/developers/polling/): cache for the
`max-age`, send `If-None-Match`, and ask only for the area you display.

## Units and timestamps

**Timestamps are ISO 8601.** Most fields are UTC and end in `Z`, with up to
microseconds: `"server_time": "2026-11-09T19:07:14Z"`. The exceptions are
deliberate:

| Where | Form |
| --- | --- |
| Forecast `hourly[].time` on `/weather`, and `local_time` on `/forecast` steps | local time at the forecast point with its offset, `2026-11-09T13:00:00-06:00`. `valid_time` beside it is the same instant in UTC with `Z` |
| `daily[].date` and the sky outlook's `local_date` and `today` | a calendar date, `YYYY-MM-DD`, in the place's own zone |
| `/health/deep` timestamps, and `server_time` on `/stations` with `detail=minimal` | UTC written with a `+00:00` offset instead of `Z`: `2026-11-09T19:12:01.123456+00:00` |
| Request parameters such as `valid_from` | ISO 8601; a time with no offset is read as UTC |

Parse both `Z` and `+00:00`; any ISO 8601 parser does.

**Units.** Routes that take a `units` parameter accept `si`, `metric`, `us`,
`uk` or `auto` (the default). `auto` picks a system from the caller's country,
read at the edge, and a caller it cannot place gets `us`. The response carries
a `units` block that names the unit and label of every field, and says whether
the system was `explicit`, came from the caller's country (`geo`) or was the
`default`. Read it rather than assuming. Routes with no `units` parameter use
fixed units, stated on their page: geometry is longitude and latitude in
degrees, and raw model data and soundings are SI (K, m, m/s, with pressures
in hPa). Directions are degrees true, and wind directions are the direction
the wind blows **from**. Coordinates are `lat` then `lon` in query parameters
and `[lon, lat]` in GeoJSON.

## Pagination

There is almost none. Collection routes are bounded by a `limit` parameter with
a default and a maximum, or by a bounding box or a time window, and the page
for each route says which. Only `/alerts/active` pages, with `limit` (1 to 2000,
default 500) and `offset` over a stable order, and no total count. Where a
response can be cut short it says so with a `truncated` flag (stations, and the alert list from `/alerts/focus`) or by returning `count` equal to the `limit` (station history), and the
fix is a smaller box or a larger `limit`, not a next link. There are no cursors
or `Link` headers.

## Versioning

`/v1` is the keyed mount of the API, not a schema version: the bare and `/v1`
paths return the same bodies. There is no date or version header, and the
response does not report a version. Fields can be added to a response at any
time, so ignore keys you do not recognise. A renamed field can be kept as a
deprecated alias beside the new name: `staleness_seconds` beside
`alert_staleness_seconds` on [Status](/docs/api/status/) is an example.

## Caching and conditional requests

Every cacheable route sets `Cache-Control` with a `max-age` matched to how
often the data changes; the figure is on the route's page. Public paths are
`public` and `/v1` paths are `private`. A response that depends on your
country (`units=auto`) is `private` with `Vary: CF-IPCountry`.

`ETag` and `304 Not Modified` are offered on only two routes,
`/alerts/in-bounds` and `/alerts/active/geojson`: send the tag back as
`If-None-Match` and an unchanged set gets an empty `304`. Every other route
returns no `ETag`; cache for the `max-age` and ask again after it. Errors
from the gate (`401`, `403`, `429`) are `no-store`.

## Cross-origin requests

CORS allows `https://wxalerts.org` and `https://www.wxalerts.org` only, with
credentials, for `GET`, `POST`, `PUT`, `PATCH` and `DELETE`. Browsers on other
sites cannot call the API, so call it from a server, script or app. The
response headers `ETag`, `Retry-After`, `RateLimit-Limit`,
`RateLimit-Remaining` and `RateLimit-Reset` are exposed to the allowed origins.
