# NWS weather alerts + forecasts by state/point (api.weather.gov) (`retrainmap/nws-weather-alerts`) Actor

Active U.S. National Weather Service alerts (warnings, watches, advisories) as one row each - event, severity, urgency, areas, states, onset/expiry, full text - filtered by state and severity; or the 7-day / hourly NWS forecast for up to 20 lat/lon points. Public api.weather.gov, no key.

- **URL**: https://apify.com/retrainmap/nws-weather-alerts.md
- **Developed by:** [RetrainMap Team](https://apify.com/retrainmap) (community)
- **Categories:**
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 records

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## NWS weather alerts + forecasts by state/point (api.weather.gov)

Every **active National Weather Service alert** in the United States as one clean row —
event (Tornado Warning, Flood Watch, Heat Advisory, …), severity, urgency, certainty,
headline, affected areas and states, onset/expiry, issuing office and the full alert text —
filtered by state, severity, urgency, certainty or event name. Or, in forecast mode, the
official **NWS forecast** (7-day half-day periods or hourly) for up to 20 latitude/longitude
points. Source: the public `api.weather.gov` API, no key required.

### Data source and status

| | |
|---|---|
| Publisher | U.S. National Weather Service (NOAA), `https://api.weather.gov` ([documentation](https://www.weather.gov/documentation/services-web-api)) |
| Alerts | `GET /alerts/active?status=actual[&area=…][&severity=…][&urgency=…][&certainty=…][&event=…]` — all matching active alerts in one response (the endpoint has no `limit` parameter; about 300 alerts on a quiet day, far more during severe-weather outbreaks). Test and exercise messages are excluded by `status=actual` |
| Forecast | `GET /points/{lat},{lon}` for the grid, then the grid's `forecast` (14 half-day periods) or `forecastHourly` (156 hourly periods) |
| Refresh cadence | Live on every run. NWS updates the alert feed continuously and forecasts several times a day; each row carries `fetched_at`, alert rows also the feed's own `source_updated` time |
| Terms and licence | NWS data are works of the U.S. Government and not subject to copyright in the U.S. (17 U.S.C. §105). NWS asks API clients to identify themselves (done, see below) and to keep request rates reasonable. **This is not a warning service** — the Actor does not deliver alerts faster than, or in place of, official channels (NOAA Weather Radio, Wireless Emergency Alerts, weather.gov) |
| Response guards | The alert/point/period keys measured on 2026-09-04 (`id`, `event`, `severity`, `urgency`, `certainty`, `headline`, `areaDesc`, `geocode.UGC`, `onset`, `expires`, `senderName`, `description`, `periods[].temperature`, …) must be present; anything else fails the run loudly instead of writing guessed values |
| Identification | `User-Agent: RetrainMap-nws-weather-alerts/0.1 (https://apify.com/retrainmap; <contact>)` plus the contact address in the standard `From:` header |

Honesty note: `states` on an alert row is derived from the alert's UGC zone/county codes
(`FLZ041` → `FL`), because the API does not carry a state field; marine zones yield NWS marine
area codes (`AM`, `GM`, `PZ`, …). `description` and `instruction` are cut at 3,000 characters
(flagged by `*_truncated`); the full text is one click away at `nws_url`.

### Input

| Field | Type | Meaning |
|---|---|---|
| `mode` | `alerts` / `forecast` | Default `alerts` |
| `states` | array of 2-letter codes | Alerts. Empty (default) = the whole country. Marine area codes accepted |
| `severity` | `Extreme` `Severe` `Moderate` `Minor` `Unknown` | Optional |
| `urgency` | `Immediate` `Expected` `Future` `Past` `Unknown` | Optional |
| `certainty` | `Observed` `Likely` `Possible` `Unlikely` `Unknown` | Optional |
| `events` | array of exact NWS event names | Optional, e.g. `Tornado Warning` |
| `points` | array of `"lat,lon"` | Forecast; up to 20 U.S. points |
| `forecast_type` | `daily` / `hourly` | Default `daily` (14 periods per point) |
| `max_records` | integer | Default 300 |
| `request_interval_ms` | integer | Default 500 (floor 250) |
| `contact_email` | string | Sent in the User-Agent and `From:` header |

Examples:

```json
{ "mode": "alerts", "states": ["TX", "OK", "KS"], "severity": ["Extreme", "Severe"], "urgency": ["Immediate", "Expected"] }
```

```json
{ "mode": "forecast", "points": ["40.7128,-74.0060", "34.0522,-118.2437"], "forecast_type": "daily" }
```

### Output (dataset row)

Alerts: `id`, `event`, `severity`, `urgency`, `certainty`, `status`, `message_type`,
`category`, `response`, `headline`, `area_desc`, `states`, `ugc_zones`, `same_codes`, `sent`,
`effective`, `onset`, `expires`, `ends`, `sender`, `sender_name`, `description` (≤ 3,000
chars), `description_truncated`, `instruction`, `instruction_truncated`, `nws_url`,
`source_updated`, `fetched_at`.

Forecast: `point`, `latitude`, `longitude`, `grid_id`, `grid_x`, `grid_y`, `forecast_office`,
`nearest_city`, `nearest_state`, `time_zone`, `forecast_type`, `period_number`, `period_name`,
`start_time`, `end_time`, `is_daytime`, `temperature`, `temperature_unit`, `temperature_trend`,
`precip_probability_pct`, `dewpoint_c` and `relative_humidity_pct` (hourly), `wind_speed`,
`wind_direction`, `short_forecast`, `detailed_forecast`, `icon`, `forecast_generated_at`,
`forecast_updated_at`, `fetched_at`.

A run summary (filters, the exact API requests made, counts, the feed's update time) is
stored as `RUN_SUMMARY` in the run's key-value store.

### Pricing (pay per event)

| Event | Price |
|---|---|
| `run-start` — once per run | $0.10 |
| `record` — per row written | $0.005 |

The default run (up to 300 alerts) costs at most $1.60; a 7-day forecast for one point (14
rows) $0.17. Rows stop when your run's maximum charge is reached; the run summary says so.

### Operator

Steelyard Ventures LLC (RetrainMap) — info@steelyardclinical.com. The Actor writes only to its
own dataset and key-value store; it stores no credentials and sends nothing but GET requests.

# Actor input Schema

## `mode` (type: `string`):

`alerts`: one row per active alert (status=actual). `forecast`: one row per forecast period for each point.

## `states` (type: `array`):

Two-letter state or territory codes (TX, FL, PR, ...) or NWS marine area codes (AM, AN, GM, LC, LE, LH, LM, LO, LS, PH, PK, PM, PS, PZ, SL). Leave empty for every active alert in the country.

## `severity` (type: `array`):

Optional. Keep only alerts with these severities.

## `urgency` (type: `array`):

Optional. Keep only alerts with these urgencies.

## `certainty` (type: `array`):

Optional. Keep only alerts with these certainties.

## `events` (type: `array`):

Optional. Exact NWS event names, e.g. "Tornado Warning", "Flood Watch", "Heat Advisory" (passed to the API's event filter).

## `points` (type: `array`):

Up to 20 entries such as "40.7128,-74.0060" (U.S. locations only; two requests per point).

## `forecast_type` (type: `string`):

`daily` = the standard 7-day forecast in 14 half-day periods; `hourly` = 156 hourly periods per point.

## `max_records` (type: `integer`):

Stop after this many rows have been written.

## `request_interval_ms` (type: `integer`):

Politeness delay towards api.weather.gov (floor 250 ms). Alerts mode makes one request; forecast mode two per point.

## `contact_email` (type: `string`):

The NWS API requires a User-Agent that names the application and a contact. Sent in the User-Agent and in the standard From: request header (RFC 9110 s10.1.2).

## Actor input object example

```json
{
  "mode": "alerts",
  "states": [],
  "points": [
    "40.7128,-74.0060"
  ],
  "forecast_type": "daily",
  "max_records": 300,
  "request_interval_ms": 500,
  "contact_email": "info@steelyardclinical.com"
}
```

# Actor output Schema

## `results` (type: `string`):

Alerts: one row per active NWS alert. Forecast: one row per forecast period per point.

## `results_csv` (type: `string`):

The same rows as a CSV file.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "mode": "alerts",
    "states": [],
    "points": [
        "40.7128,-74.0060"
    ],
    "forecast_type": "daily",
    "max_records": 300
};

// Run the Actor and wait for it to finish
const run = await client.actor("retrainmap/nws-weather-alerts").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "mode": "alerts",
    "states": [],
    "points": ["40.7128,-74.0060"],
    "forecast_type": "daily",
    "max_records": 300,
}

# Run the Actor and wait for it to finish
run = client.actor("retrainmap/nws-weather-alerts").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "mode": "alerts",
  "states": [],
  "points": [
    "40.7128,-74.0060"
  ],
  "forecast_type": "daily",
  "max_records": 300
}' |
apify call retrainmap/nws-weather-alerts --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,retrainmap/nws-weather-alerts"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/5V1wxKij4ql6UgknS/builds/oZp1edsEhwAudY8Bx/openapi.json
