Skip to main content
Tutorial

weather.gov API in Python: Forecasts and Alerts for Agents

Get National Weather Service forecasts and active alerts in Python: point lookup, grid forecast, hourly data and alerts, all through one API key.

fastcrw
By RecepNovember 17, 20265 min read

By the fastCRW team · Catalogue figures checked 2026-11-05 against GET /v1/data · Verify independently before relying on any figure.

The National Weather Service (NWS) forecast API works in two steps. First you call the point capability with a latitude and longitude. It returns the forecast office and grid cell for that spot. Then you call the grid forecast for that office and cell. Pergamon exposes both as weathergov, along with hourly data and active alerts, behind one API key.

Which capability answers which question

QuestionCapabilityMain options
Which forecast office and grid cell cover this point?pointpoint as "lat,lon"
What is the forecast for this grid cell?gridpoint-forecastoffice, gridX, gridY
What are the hourly values for this grid cell?gridpoint-forecast-hourlyoffice, gridX, gridY
What alerts are active for this state or area?alerts-areaarea
What is the forecast for one NWS forecast zone?zone-forecastzoneId
What did one station observe most recently?station-observation-lateststationId, from stations

The two-step pattern

The point argument is latitude,longitude, in that order. The response contains gridId, gridX and gridY, which are the three values the forecast call needs. The example below was run live with the Python SDK (crw 0.41.0) for a point in Kansas.

# pip install crw
from crw import CrwClient

client = CrwClient()  # reads CRW_API_KEY
point = client.get_data("weathergov", "point", {"point": "39.7456,-97.0892"})
props = point["data"]["properties"]
print(props["gridId"], props["gridX"], props["gridY"])

fc = client.get_data("weathergov", "gridpoint-forecast", {
    "office": props["gridId"], "gridX": props["gridX"], "gridY": props["gridY"],
})
periods = fc["data"]["properties"]["periods"]
print(fc["provenance"]["attributionText"], len(periods), "periods")
print(periods[0]["name"], periods[0]["temperature"], periods[0]["temperatureUnit"], periods[0]["shortForecast"])

Real output:

TOP 32 81
Source: NOAA/National Weather Service 14 periods
Overnight 37 F Mostly Clear

Store the office and grid cell for each location, so later requests for that location can skip the point call. The point response also names the nearest place in relativeLocation (Linn, KS for this point).

Reading the forecast periods

The grid forecast returns a periods array. At the Kansas point it held 14 periods, and the names alternate between daytime and night, as in Overnight, Thursday and Thursday Night. Each period has name, temperature with its temperatureUnit, a shortForecast label, and a detailedForecast sentence for the full wording.

The helper below wraps both calls into one function that returns the first few periods for any latitude and longitude. It was run live with the Python SDK.

# pip install crw
from crw import CrwClient

client = CrwClient()  # reads CRW_API_KEY

def forecast_summary(lat: float, lon: float, count: int = 3) -> list[tuple[str, int, str]]:
    point = client.get_data("weathergov", "point", {"point": f"{lat},{lon}"})["data"]["properties"]
    fc = client.get_data("weathergov", "gridpoint-forecast", {
        "office": point["gridId"], "gridX": point["gridX"], "gridY": point["gridY"],
    })
    periods = fc["data"]["properties"]["periods"][:count]
    return [(p["name"], p["temperature"], p["shortForecast"]) for p in periods]

for row in forecast_summary(39.7456, -97.0892):
    print(*row)

Real output:

Overnight 37 Mostly Clear
Thursday 53 Partly Sunny
Thursday Night 34 Mostly Cloudy

Each row keeps the period name and temperature as the NWS returns them. Convert or label them only after you have checked the temperatureUnit of that period.

Hourly data

gridpoint-forecast-hourly takes the same three options. The same grid cell returned an 84 KB response at check time, so ask for hourly data only when you need it.

curl "https://api.fastcrw.com/v1/data/weathergov/gridpoint-forecast-hourly?office=TOP&gridX=32&gridY=81" \
  -H "Authorization: Bearer $CRW_API_KEY"

Active alerts

alerts-area takes an area code, here CA for California. Each feature in the response is one alert, and its event property names it. At 10:15 UTC on 2026-11-05 the call returned 13 alerts, and that number changes as the NWS updates its feed.

curl "https://api.fastcrw.com/v1/data/weathergov/alerts-area?area=CA" \
  -H "Authorization: Bearer $CRW_API_KEY"

To summarise the feed, count the event values. The script below was run live with the Python SDK.

# pip install crw
from collections import Counter

from crw import CrwClient

client = CrwClient()  # reads CRW_API_KEY
alerts = client.get_data("weathergov", "alerts-area", {"area": "CA"})
features = alerts["data"]["features"]
print(len(features), "active alerts for CA")
for event, count in Counter(f["properties"]["event"] for f in features).most_common(3):
    print(count, event)

Real output:

13 active alerts for CA
5 Coastal Flood Advisory
4 Beach Hazards Statement
1 Lake Wind Advisory

An empty features array means no alert is in force for that area at the time of the call. It does not mean the weather is safe, so read the alert text and the time window before you act on it.

Outside the US: NASA POWER daily data

The NWS covers US locations. For a point outside the US, nasapower/daily returns daily climate values. All six options are required: parameters, community, latitude, longitude, start and end. Dates use the YYYYMMDD form. The call below is for Berlin, and it returned data.

curl "https://api.fastcrw.com/v1/data/nasapower/daily?parameters=T2M,PRECTOTCORR&community=AG&latitude=52.52&longitude=13.40&start=20261001&end=20261007" \
  -H "Authorization: Bearer $CRW_API_KEY"

The values sit under data.properties.parameter, keyed by parameter name and then by date. At check time T2M for 2026-10-01 was 17.48, and PRECTOTCORR for 2026-10-02 was 1.05.

Aviation weather: METAR

The aviationweather provider covers aviation products from the same NOAA family, such as metar, taf and sigmet. A METAR call takes station IDs in ids. The call for KJFK returned a list with one observation: temperature 16.1, wind speed 5, flight category VFR, and the raw report text.

curl "https://api.fastcrw.com/v1/data/aviationweather/metar?ids=KJFK" \
  -H "Authorization: Bearer $CRW_API_KEY"

Open-Meteo runs on your machine

Open-Meteo is a client source. Its forecast capability runs in the local crw-mcp on your machine, at 0 credits, and the data does not pass through fastCRW. Open-Meteo's free API terms say "You may only use the free API services for non-commercial purposes" (Open-Meteo terms). Read those terms before you ship a product on it.

Limits

  • The NWS endpoints cover US locations. For other places use NASA POWER or another source from the catalogue.
  • Forecasts change. Store the time you fetched each forecast next to the values.
  • Budget the calls. Each call costs 1 credit. Once you have stored the grid cell, refreshing the forecast for 20 locations every hour is 480 calls, or 480 credits, a day.
  • This is not emergency advice. For warnings that affect life or property, use the official NWS products and alert channels directly.

Sources

Related: Public data API for AI agents · Free public APIs for AI agents · Pergamon catalogue

Try the National Weather Service on Pergamon

FAQ

Frequently asked questions

Why does the NWS forecast need two calls?
The forecast endpoint is keyed by forecast office and grid cell, not by coordinates. The point call maps your latitude and longitude to those three values, and you can store them for each location.
What does an empty alerts list mean?
No alert is in force for that area at the time of the call. Check the time of the call and the area you asked for, and use the official NWS products for anything that affects safety.
Does this cover locations outside the US?
The NWS endpoints cover US locations only. NASA POWER returns daily climate values for points outside the US, such as the Berlin example above, with the dates in YYYYMMDD form.

Get Started

Try fastCRW free

Run a live request in the playground — no signup required. Or grab a free API key with 500 credits, earn up to 500 more, no credit card.

Continue exploring

More tutorial posts

View category archive