I wanted snow accumulation forecasts from OpenClaw, but the wttr.in skill only returned “Heavy snow” text. I needed: how much snow, when it starts. I discovered the National Weather Service API—free, no API key, US-only—and built a unified skill with AirNow AQI and global fallback.
Discovery: NWS API
The National Weather Service API returns structured data:
|
|
No API key required. Requests against api.weather.gov just work. But it’s US-only—international locations need wttr.in fallback.
Gridpoint API (/gridpoints/{wfo}/{x},{y}) has structured snow/ice/rain values. Zone forecast API is less detailed. Grid lookup requires geocoding first via /points/{lat},{lon}.
Later I discovered AirNow AQI—also no API key. Useful when deciding if post-storm shoveling is safe.
API Hierarchy
The skill auto-detects source based on location:
|
|
Temporal Query Detection
wttr.in returns day summaries. I wanted hourly breakdowns for “What time does the rain stop?”
The skill detects time qualifiers:
|
|
When detected, it queries /gridpoints/{wfo}/{x},{y}/forecast/hourly instead—156 hourly periods (~7 days).
Phase Implementation
Phase 1: Core with Grid Data
get_weather.py orchestrates the unified call:
|
|
Script flow:
- Geocode via NWS
/pointsendpoint for grid ID and forecast URLs - Fetch structured forecast or hourly if temporal detected
- If
--aqiflag, fetch AirNow current + forecast - For non-US locations, hit wttr.in
Phase 2: Station Observations
NWS has observed conditions at weather stations. Added --current flag to compare forecast vs reality:
|
|
Phase 3: Edge Cases
- Aviation TAFs: Terminal forecasts via
/stations/{stationId}/tafs. Most civilian stations lack TAF—use--tafexplicitly - Astronomical: Sunrise/sunset via
skyfieldlibrary with--astro - Fire weather: Red flag warnings from NWS alerts API with
--fire
Declaring Environment Variables
Clawdhub.ai validates skills before listing. Skills using environment variables must declare them in SKILL.md metadata or get flagged as suspicious.
Added the clawdis block to register AIRNOW_API_KEY:
|
|
This tells the validation system:
- The skill accepts an optional
AIRNOW_API_KEYenvironment variable - It’s not required—AirNow works unauthenticated with stricter rate limits
- OpenClaw injects the variable if configured in
clawdbot.json
Usage
|
|
Available on clawdhub.ai/patelhiren/weather-nws.
