# Make your first API call

> Ask the REST API for the alerts in effect at a point, then for the current weather there, with no key.

Developers · Tutorial · https://wxalerts.org/docs/developers/quickstart/

You will ask the WxAlerts REST API which weather alerts are in effect at one
point, then for the current weather at the same point. You need no account and
no key. You need curl, or Python, or Node 18 or newer.

Browsers block calls from other websites (CORS allows only wxalerts.org), so
run this from a script or a server, not from a web page.

## 1. Get the active alerts at a point

The point is South Lake Tahoe, California: latitude `38.94`, longitude
`-119.98`. `/alerts/at` takes those two parameters and nothing else.

```bash
curl "https://api.wxalerts.org/alerts/at?lat=38.94&lon=-119.98"
```

```python
import json
import requests

r = requests.get(
    "https://api.wxalerts.org/alerts/at",
    params={"lat": 38.94, "lon": -119.98},
    timeout=10,
)
r.raise_for_status()
print(json.dumps(r.json(), indent=2))
```

```js
const params = new URLSearchParams({ lat: "38.94", lon: "-119.98" });
const res = await fetch(`https://api.wxalerts.org/alerts/at?${params}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
console.log(JSON.stringify(await res.json(), null, 2));
```

The Python sample uses [requests](https://pypi.org/project/requests/), so
install it first with `pip install requests`. Save the JavaScript as
`first-call.mjs` and run it with `node first-call.mjs`.

You get a JSON list with one object per alert. This is the first object, with
the long text fields cut short:

```json
[
  {
    "id": 29872029,
    "vtec_key": "KREV.WS.W.0004.2026",
    "event": "Winter Storm Warning",
    "office": "KREV",
    "phenomena": "WS",
    "significance": "W",
    "etn": 4,
    "status": "active",
    "severity": "Severe",
    "urgency": "Expected",
    "certainty": "Likely",
    "issued_at": "2026-11-12T08:33:00Z",
    "onset": "2026-11-13T18:00:00Z",
    "expires": "2026-11-13T08:45:00Z",
    "ends": "2026-11-14T18:00:00Z",
    "headline": "Winter Storm Warning issued November 12 at 12:33AM PST until November 14 at 10:00AM PST by NWS Reno NV",
    "description": "* WHAT...Heavy wet snow. Snow accumulations near 12 inches above 7000 feet...",
    "geom_source": "ugc",
    "short_id": "FfPsk4OT"
  }
]
```

If you get `[]`, nothing is in effect at that point right now. That is a
normal answer. Change `lat` and `lon` to a place with weather on it and run it
again.

## 2. Read the response

Four fields tell you most of what you need:

- `event` is the NWS name for the hazard, here `Winter Storm Warning`.
- `significance` is `W` for a warning, `A` for a watch, `Y` for an advisory
  and `S` for a statement. Sort and color by this, not by `severity`.
- `ends` is when the hazard actually ends. `expires` is only the time an
  update is due, so it can be earlier than `ends`, as it is here.
- `headline` and `description` are the product text, unedited.

## 3. Get the current weather at the same point

`/weather` takes the same two parameters. The `current` object is what the
nearest stations measured. The sample below prints a few of its fields.

```bash
curl "https://api.wxalerts.org/weather?lat=38.94&lon=-119.98"
```

```python
import requests

r = requests.get(
    "https://api.wxalerts.org/weather",
    params={"lat": 38.94, "lon": -119.98},
    timeout=10,
)
r.raise_for_status()
current = r.json()["current"]
print(current["sky"], current["temperature"], "F, wind",
      current["wind_speed"], "mph from", current["wind_direction_cardinal"])
```

```js
const params = new URLSearchParams({ lat: "38.94", lon: "-119.98" });
const res = await fetch(`https://api.wxalerts.org/weather?${params}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const { current } = await res.json();
console.log(current.sky, current.temperature, "F, wind",
  current.wind_speed, "mph from", current.wind_direction_cardinal);
```

The curl command prints the whole response. The Python and JavaScript samples
print one line:

```text
Clear 25.0 F, wind 0.0 mph from N
```

JavaScript prints the same numbers without the trailing `.0`.

You have now made a public REST call, read an alert and read a measurement.
Next, [subscribe to live alerts over MQTT](/docs/developers/mqtt-quickstart/)
so you never have to poll for them.
