# NWS US Weather — official forecasts, alerts & observations (`tec5uport/nws-us-weather`) Actor

U.S. National Weather Service forecasts, active alerts, and latest station observation for a ZIP, city, or coordinates. Compact JSON plus markdown briefing. Official NWS APIs, no key. Not affiliated with NWS/NOAA. Built for AI agents.

- **URL**: https://apify.com/tec5uport/nws-us-weather.md
- **Developed by:** [Tec5uport Data Tools](https://apify.com/tec5uport) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$10.00 / 1,000 location forecasts

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?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## NWS US Weather — official forecasts, alerts & observations

Get official U.S. National Weather Service forecasts, active alerts, and the latest station observation for a ZIP code, city, or coordinates. Returns compact JSON plus a markdown weather briefing. No API key. Built so an AI agent can answer “what’s the weather in …?” with one tool call.

**Store / MCP search keywords:** weather.gov, NWS, National Weather Service, NOAA forecast, US weather alerts, weather warning, hourly forecast, ZIP code weather, Vicksburg weather, official weather API, weather briefing, no API key.

### What it does

- Forecasts, hourly forecasts, alerts, and observations from `https://api.weather.gov` ([NWS API docs](https://www.weather.gov/documentation/services-web-api)). The NWS requires a User-Agent and does not require an API key. Data is free official U.S. government weather information.
- ZIP / city geocoding uses the public postal gazetteer at `https://api.zippopotam.us` (U.S. ZIP and place centroids). Street addresses use the U.S. Census Bureau geocoder (`geocoding.geo.census.gov`).
- This Actor does not scrape weather.com, AccuWeather, or other commercial forecast sites.

### Agent / MCP notes

Apify MCP at `https://mcp.apify.com` discovers Actors with `search-actors` and `fetch-actor-details`, runs them with `call-actor` (default 30s wait), then reads `get-dataset-items` ([docs](https://docs.apify.com/platform/integrations/mcp)). This Actor is shaped for that path:

- Limited permissions only.
- Official JSON APIs so a ZIP lookup finishes quickly.
- Agent-friendly defaults: `zipCodes: ["39180"]`, 6 forecast periods, hourly **off**, alerts and current observation **on**, `compact=true`, `outputFormat=both`.
- Each dataset item includes a `markdown` briefing; a combined briefing is stored as `OUTPUT.md`.
- Pay-per-event charge is **one `location-forecast` per location**, not per forecast period.

Suggested PPE when publishing (do not enable “pay per event + usage”):

| Event | Suggested price | When it fires |
| --- | --- | --- |
| `location-forecast` | **$0.01** | Once per location briefing with `status: "ok"` |

That is about 1¢ per agent weather question and qualifies for per-request agentic payments (PPE + limited permissions + no Standby + developer KYC) ([Monetize Actors](https://docs.apify.com/actors/monetize)).

### Input

| Field | Default | Notes |
| --- | --- | --- |
| `zipCodes` | `["39180"]` | Easiest agent input; max 10 per run |
| `coordinates` | — | `"lat,lon"` strings; max 10 per run |
| `locations` | — | Objects with zipCode / city+state / address / lat+lon; max 10 locations per run across all inputs |
| `stateAlerts` | — | Extra statewide alert list, e.g. `MS` |
| `includeForecast` | `true` | 12-hour periods |
| `includeHourly` | `false` | Token-heavy; opt in |
| `includeAlerts` | `true` | Point alerts |
| `includeObservation` | `true` | Latest station reading |
| `forecastPeriods` | `6` | About two days |
| `hourlyHours` | `12` | Only used when `includeHourly` is true |
| `compact` | `true` | Truncates long forecast and alert text to ~220 characters |
| `outputFormat` | `both` | Adds `markdown` + `OUTPUT.md` |

### Output

One dataset item per location, including forecast, alerts, observation, and `markdown` when requested.

Each item has `status` (`ok`, `not_found`, `invalid_input`, `error`). You are charged one `location-forecast` only for `status: "ok"`. Max 10 locations per run. ZIP and city lookups use api.zippopotam.us (third-party) and return an approximate centroid; addresses use the U.S. Census geocoder. Not affiliated with NWS/NOAA. For life-safety decisions, follow official NWS warnings.

### Local run (no publish)

```bash
cd nws-us-weather
npm install
APIFY_LOCAL_STORAGE_DIR=./storage node src/main.js
```

### Legal

NWS data is open for any purpose, with reasonable rate limits. Identify this application via User-Agent as the NWS asks. Do not hammer the API; this Actor spaces requests. Not affiliated with or endorsed by the National Weather Service (NWS) or NOAA. ZIP and city lookups go through api.zippopotam.us (a free third-party gazetteer, not an official NWS service) and return an approximate centroid; street addresses are sent to the U.S. Census Bureau geocoder. For life-safety decisions, follow official NWS warnings and local emergency management.

# Actor input Schema

## `zipCodes` (type: `array`):

U.S. 5-digit ZIP codes (max 10 per run). Example: 39180 (Vicksburg, MS).

## `coordinates` (type: `array`):

Latitude,longitude pairs, e.g. 32.3526,-90.8779. Use when the agent already has a point.

## `locations` (type: `array`):

Optional objects with zipCode, city + 2-letter state, address, and/or latitude+longitude. Max 10 locations per run across all inputs.

## `stateAlerts` (type: `string`):

Optional two-letter state code (e.g. MS) to also list active alerts for the whole state.

## `includeForecast` (type: `boolean`):

Official NWS 7-day forecast, truncated by forecastPeriods.

## `includeHourly` (type: `boolean`):

Off by default because hourly rows are large for LLM context. Turn on only when needed.

## `includeAlerts` (type: `boolean`):

Watches, warnings, and advisories for the point (and statewide if stateAlerts is set).

## `includeObservation` (type: `boolean`):

Most recent reading from the nearest NWS observation station.

## `forecastPeriods` (type: `integer`):

Each period is about 12 hours (Today, Tonight, tomorrow, …). 6 is usually two days.

## `hourlyHours` (type: `integer`):

Only used when includeHourly is true.

## `compact` (type: `boolean`):

Truncate long forecast and alert text to keep the payload small for LLM context.

## `outputFormat` (type: `string`):

json writes dataset items only. markdown also writes OUTPUT.md. both (default) does both.

## Actor input object example

```json
{
  "zipCodes": [
    "39180"
  ],
  "stateAlerts": "MS",
  "includeForecast": true,
  "includeHourly": false,
  "includeAlerts": true,
  "includeObservation": true,
  "forecastPeriods": 6,
  "hourlyHours": 12,
  "compact": true,
  "outputFormat": "both"
}
```

# Actor output Schema

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

Dataset items (JSON) for each location.

## `briefing` (type: `string`):

OUTPUT.md summary (when markdown output is enabled).

# 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 = {
    "zipCodes": [
        "39180"
    ],
    "forecastPeriods": 6,
    "hourlyHours": 12,
    "outputFormat": "both"
};

// Run the Actor and wait for it to finish
const run = await client.actor("tec5uport/nws-us-weather").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 = {
    "zipCodes": ["39180"],
    "forecastPeriods": 6,
    "hourlyHours": 12,
    "outputFormat": "both",
}

# Run the Actor and wait for it to finish
run = client.actor("tec5uport/nws-us-weather").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 '{
  "zipCodes": [
    "39180"
  ],
  "forecastPeriods": 6,
  "hourlyHours": 12,
  "outputFormat": "both"
}' |
apify call tec5uport/nws-us-weather --silent --output-dataset

```

## MCP server setup

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

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/GwGSlV4YzKdKUKg73/builds/ZsZa5XZMEDIIWRcwC/openapi.json
