Guide / Weather, sports and events
Add a 48-hour forecast to an AI agent with the free NWS API
Two calls get an hourly US forecast with no key: /points for the grid, then forecastHourly. Keep generatedAt so the agent can say how old it is.
Your agent is planning a delivery route, an outdoor shoot or a field crew's day for tomorrow or the day after, and it needs the weather at one place, hour by hour. For anywhere in the US, the National Weather Service provides that through its free web API, with no key and no account, in two calls. There are two catches. The first call returns addresses, not a forecast. And the forecast that comes back has an age that the agent should read and pass on.
The age is the part worth building around. Every hourly answer carries two timestamps, generatedAt and updateTime, and most agents drop them on the way to a one-line summary. By the end of this guide your agent will have 48 hourly periods for a US point, the times that date them, and any active alerts for that spot. You need the place's coordinates and an HTTP client that can set a header.
How to add a 48-hour forecast to an agent
Each National Weather Service forecast office draws its forecasts on its own grid of squares about 2.5 km on a side. The work is finding the grid square for your point and then reading its hourly forecast.
- Name your agent in the User-Agent header. The documentation requires this header, a line in each request that identifies your software. It can be any string, and adding a website or email lets the service contact you, as in
User-Agent: (myweatherapp.com, contact@myweatherapp.com). - Send the coordinates to /points. Request
https://api.weather.gov/points/{latitude},{longitude}. The answer names the forecast office and grid square, not the weather. - Follow the forecastHourly address from that answer. Read the URL from the
forecastHourlyproperty instead of building it yourself, because the grid, and even the office, for a coordinate can occasionally change. - Fetch the hourly forecast and keep the first 48 periods. The
periodslist runs over the next seven days and leaves out hours that have already passed. In our call the first period began at the start of the current hour. - Store generatedAt and updateTime with the forecast. Keep both, plus the moment your agent fetched the forecast, and have the agent state the forecast's age whenever it reports the weather.
- Check active alerts for the same point. Request
https://api.weather.gov/alerts/active?point={latitude},{longitude}and pass on any watch, warning or advisory as it was issued.
Example calls
We made these calls on 6 November 2026, at about 20:46 UTC, for a point in Chicago and one in Paris. The responses below are trimmed, and an ellipsis marks each cut.
The first call returned a grid square and a set of addresses, with no weather in it: office LOT, square 66,77, and the URL of the hourly forecast.
GET https://api.weather.gov/points/41.98,-87.90
"properties": {
"gridId": "LOT",
"gridX": 66,
"gridY": 77,
"forecast": "https://api.weather.gov/gridpoints/LOT/66,77/forecast",
"forecastHourly": "https://api.weather.gov/gridpoints/LOT/66,77/forecast/hourly",
...
"timeZone": "America/Chicago",
...
}
Following that address returned the forecast itself, with its two timestamps above the periods.
GET https://api.weather.gov/gridpoints/LOT/66,77/forecast/hourly
"properties": {
"units": "us",
"forecastGenerator": "HourlyForecastGenerator",
"generatedAt": "2026-11-06T20:07:27+00:00",
"updateTime": "2026-11-06T18:21:15+00:00",
...
"periods": [
{
"number": 1,
...
"temperature": 46,
"temperatureUnit": "F",
"probabilityOfPrecipitation": {
"unitCode": "wmoUnit:percent",
"value": 7
},
"dewpoint": {
"unitCode": "wmoUnit:degC",
"value": -0.5555555555555556
},
"windSpeed": "10 mph",
"windDirection": "NNW",
"shortForecast": "Partly Sunny",
...
},
...
Our request went out at 20:46 UTC, so the answer was 39 minutes old by generatedAt and about two hours and 25 minutes old by updateTime. A forecast is a document with a date on it, not a live reading. Our piece on what real-time means makes the case for reporting the timestamp beside the fact, and a forecast is where that habit pays off.
Two details in that answer are easy to get wrong. Each startTime carries its own offset: the first period began at 14:00 at -06:00, which is 20:00 UTC, the hour of our request. The answer also declared "units": "us" and gave temperature in Fahrenheit, but the dewpoint came back in degrees Celsius, so the agent has to read the unit on each field.
For the coordinates 41.98,-87.90, the alerts call returned an empty list of features, which is what a point with no active watches, warnings or advisories looks like.
{
"type": "FeatureCollection",
"features": [],
"title": "Current watches, warnings, and advisories for 41.98 N, 87.9 W",
"updated": "2026-11-06T20:45:05+00:00"
}
The same /points call for a point in Paris was refused with a 404.
{
"correlationId": "20b6d0be",
"title": "Data Unavailable For Requested Point",
"type": "https://api.weather.gov/problems/InvalidPoint",
"status": 404,
"detail": "Unable to provide data for requested point 48.85,2.35"
}
A refused point is a fact about coverage, not a transient failure. Sending the request again will not produce a grid, so the agent should route that point to another source or report that no NWS forecast exists for it. A rate-limit error is the transient kind. The documentation says the limit is not published, that an over-limit request returns an error, and that it can be retried once the limit clears, typically within 5 seconds. It also says traffic through proxies is more likely to hit the limit.
Caching works with the API rather than against it. The documentation allows caching the grid lookup, provided you check /points again periodically. The API's general questions page says its responses carry a Cache-Control header advising how long to hold them and a Last-Modified header for checking whether the data has changed, and that a query parameter the API doesn't recognise gets a 400, so random parameters added to dodge the cache fail.
What it costs
Each call costs nothing, and our four NWS calls were free. The documentation describes the data as open and free for any purpose, with no fees, though "there are reasonable rate limits in place to prevent abuse and help ensure that everyone has access." What you give in return is an identifying header and a limit you cannot see. The documentation says the User-Agent requirement will give way to an API key in the future.
When this is the wrong tool
Outside the US. The NWS has no grid there, as the Paris 404 shows. One route is Open-Meteo's forecast API. For the same Paris coordinates, it returned 48 hourly times, temperatures and precipitation probabilities, with the time zone set to Europe/Paris.
GET https://api.open-meteo.com/v1/forecast?latitude=48.85&longitude=2.35&hourly=temperature_2m,precipitation_probability&forecast_days=2&timezone=auto
{
"timezone": "Europe/Paris",
"utc_offset_seconds": 3600,
"hourly_units": { "time": "iso8601", "temperature_2m": "°C", "precipitation_probability": "%" },
"hourly": {
"time": ["2026-11-06T00:00", ...],
"temperature_2m": [9.7, ...],
"precipitation_probability": [5, ...]
}
}
Its timestamps work differently. The offset sits once in utc_offset_seconds, not in each time string. The documentation says the hourly series always begins at midnight of the current day, and the first time in our call was 2026-11-06T00:00. The documentation's forecast_hours parameter counts from the current hour instead. The free API's terms limit it to non-commercial use, at fewer than 10,000 calls a day, 5,000 an hour and 600 a minute, with CC BY 4.0 attribution. Commercial use needs one of its paid plans, which come with an API key.
Minute-by-minute needs. The smallest step in the hourly forecast is an hour, and NWS station observations can arrive up to 20 minutes late after quality control. Open-Meteo's 15-minute data is native only in Central Europe and North America. Elsewhere it is interpolated from hourly values.
Anything about safety. Decisions about safety belong with official alerts as the National Weather Service issues them, not with an agent's summary of a forecast. Have the agent pass the alert through as issued.
Frequently asked questions
Do I need an API key for the National Weather Service API?
No. All it requires is a User-Agent header naming your application, ideally with a website or email, and the NWS says a key will take that header's place in the future.
Does api.weather.gov work outside the US?
No. A /points request we made for Paris coordinates on 6 November 2026 returned a 404 saying data was unavailable for the requested point.
How old is an NWS hourly forecast?
Each answer says so in generatedAt and updateTime. In the hourly forecast we fetched on 6 November 2026, those stamps were 39 minutes and about two hours and 25 minutes older than the request.
What is the NWS API rate limit?
The NWS does not publish it. The documentation says an over-limit request returns an error that can be retried once the limit clears, typically within 5 seconds.
Is Open-Meteo's free API allowed for commercial use?
No. Its terms limit the free API to non-commercial use, and commercial use needs a paid plan with an API key.
Read this article as Markdown Open in ChatGPT Open in Claude


