# US Weather (NWS): forecasts, alerts and METAR observations (`examsens.ai/weather-nws`) Actor

Forecasts, hourly forecasts and active alerts for US latitudes and longitudes, and station observations with raw METAR reports, from the National Weather Service API.

- **URL**: https://apify.com/examsens.ai/weather-nws.md
- **Developed by:** [Ed Rayyis](https://apify.com/examsens.ai) (community)
- **Categories:** Travel, Other
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.45 / 1,000 weather 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?

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

## US Weather (NWS): forecasts, alerts and METAR observations

Give it coordinates, station ids or state codes, many at once, and it pulls what you ask for from the National Weather Service API.

What you can get:

- Forecast for a point: day and night periods about 7 days ahead, with temperature, chance of precipitation, wind and the forecast text
- Hourly forecast for a point, as many hours as you want up to 156
- Active alerts at a point, or across a whole state or marine area: event, severity, urgency, certainty, headline, area, issue, start and expiry times, description and instructions
- Latest observation at the nearest station to a point
- Station observations by station id (such as KJFK): the latest report, or every report over the last hours, with the raw METAR text and decoded values in both metric and US units

### Input

- Locations, written as `latitude,longitude`, such as `38.8977,-77.0365`
- Forecast (default on), hourly forecast (default off) and hours of hourly forecast (default 48)
- Active alerts at each location (default on)
- Latest observation nearby (default off)
- Forecast units: US (default) or metric
- Stations, such as `KJFK` or `KORD`
- Hours of observations: 0 (default) returns the latest report; a number up to 168 returns every report in that window
- Only observations with a METAR (default on). Turn it off to also get the station reports that carry no METAR text.
- Alert areas: two letter state or marine area codes, such as `TX` or `GM`
- Your contact for the NWS (optional): text such as your site or email address, added to the User-Agent the run sends

### Output

Dataset records, told apart by `recordType`:

- `forecast` and `hourly`: the location, nearest place, forecast office and grid, time zone, forecast zone, county, generation time, units and `periods`
- `alert`: `event`, `headline`, `severity`, `urgency`, `certainty`, `status`, `messageType`, `areaDescription`, `sent`, `effective`, `onset`, `expires`, `ends`, `issuedBy`, `description`, `instruction`, `response`
- `observation`: `stationId`, `stationName`, `latitude`, `longitude`, `observedAt`, `rawMetar`, `description`, temperature and dewpoint in C and F, `relativeHumidity`, wind direction, wind speed and gust in km/h and knots, visibility in meters and miles, pressure, heat index, wind chill, precipitation in the last hour, cloud layers and present weather codes
- `error`: the input and the reason, for example a point outside NWS coverage or a station with no recent METAR. The rest of the run carries on.

Export as JSON, CSV or Excel, or read it over the API.

### Pricing

Pay per event: one event per forecast, hourly forecast, alert or observation returned. Error records and the notice for an area with no active alerts are not charged. The run stops when it reaches the maximum charge you set.

### Coverage

A point outside NWS coverage returns an error record that says the NWS cannot provide data for it.

### Scope and conduct

Only api.weather.gov is called. The NWS intends the API's data as open data, free to use for any purpose \[1]. Requests go out a few at a time, and when the NWS answers that the limit is reached, the actor waits and tries again.

### Support

Questions and problems: the Issues tab on this page.

### References

1. API Web Service | National Weather Service | weather.gov. https://www.weather.gov/documentation/services-web-api

# Actor input Schema

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

US points written as latitude,longitude, such as 38.8977,-77.0365. The NWS covers the United States and its territories only.

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

The forecast in day and night periods, about 7 days ahead.

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

The forecast hour by hour.

## `maxHourlyPeriods` (type: `integer`):

How many hours of the hourly forecast to keep.

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

Watches, warnings and advisories in force at the point, one record each.

## `includeNearestObservation` (type: `boolean`):

The latest observation from the first station the NWS lists for the point.

## `units` (type: `string`):

Units for forecasts. Observations always carry both metric and US values.

## `stations` (type: `array`):

Observation station ids, such as KJFK or KORD.

## `hoursBack` (type: `integer`):

0 returns only the latest observation. A number returns every observation from that many hours back.

## `metarOnly` (type: `boolean`):

Many stations also report every few minutes without a METAR. Keep this on to return only the reports that carry the raw METAR text.

## `alertAreas` (type: `array`):

Two letter state or marine area codes, such as TX or GM. Returns every active alert there.

## `contact` (type: `string`):

Optional. The NWS asks each application to identify itself, and shows a contact address in its example. Text you enter here, such as your site or email address, is added to the User-Agent the run sends.

## Actor input object example

```json
{
  "locations": [
    "38.8977,-77.0365"
  ],
  "includeForecast": true,
  "includeHourly": false,
  "maxHourlyPeriods": 48,
  "includeAlerts": true,
  "includeNearestObservation": false,
  "units": "us",
  "hoursBack": 0,
  "metarOnly": true
}
```

# Actor output Schema

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

No description

# 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 = {
    "locations": [
        "38.8977,-77.0365"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("examsens.ai/weather-nws").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 = { "locations": ["38.8977,-77.0365"] }

# Run the Actor and wait for it to finish
run = client.actor("examsens.ai/weather-nws").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 '{
  "locations": [
    "38.8977,-77.0365"
  ]
}' |
apify call examsens.ai/weather-nws --silent --output-dataset

```

## MCP server setup

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

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/jzmqAVP5Jpep9MKhb/builds/cggy6udaIhbeKJTgP/openapi.json
