Recipe: Hourly Forecast
This recipe shows how to fetch a sequence of hourly forecasts — ideal for weather apps, commute planners, event scheduling tools, or any feature that needs short-range weather data with per-hour precision.
These recipes are teaching examples — not production code.
- Host: examples use the development host apidev.accuweather.com. Switch to api.accuweather.com for production.
- Production hardening: GZIP compression, caching, retries with exponential backoff, and error handling are not included. See the Best Practices guide.
Scenario
"I want to show users whether it will rain in the next 12 hours, and what the temperature will be each hour."
You'll need a LocationKey before starting. If you don't have one, follow the Location Search recipe first.
For this example we use LocationKey 349727 (New York City).
The Hourly Forecast API supports six durations:
| Duration param | Hours of data | Use case |
|---|---|---|
1hour | 1 | Next single hour |
12hour | 12 | Half-day planning |
24hour | 24 | Full-day planning |
72hour | 72 | 3-day hour-by-hour |
120hour | 120 | 5-day hour-by-hour |
240hour | 240 | 10-day hour-by-hour |
Extended details
Add details=true to unlock additional fields: RealFeel® temperature, wind, humidity, UV index, cloud cover, and more.
Code
Selected additional fields in the detailed response:
Code
Key response fields
| Field | Type | Description |
|---|---|---|
DateTime | String | ISO 8601 timestamp for this forecast hour |
WeatherIcon | Integer | Icon code (1–44) |
IconPhrase | String | Human-readable weather description |
HasPrecipitation | Boolean | Whether precipitation is forecast for this hour |
PrecipitationType | String | null | "Rain", "Snow", "Ice", "Mixed", or null |
PrecipitationIntensity | String | null | "Light", "Moderate", or "Heavy" |
IsDaylight | Boolean | Whether this hour is during daylight |
Temperature.Value | Number | Forecast temperature (°F by default) |
PrecipitationProbability | Integer | Percentage chance of any precipitation (0–100) |
RealFeelTemperature (details) | Object | Perceived temperature with a comfort phrase |
Wind (details) | Object | Wind speed and direction |
ThunderstormProbability (details) | Integer | Percentage chance of thunderstorm |
CloudCover (details) | Integer | Cloud coverage percentage (0–100) |
Common pitfalls
Units — The Temperature object has a single Value field (unlike Current Conditions which has both Metric and Imperial sub-objects). Control the unit with the metric query parameter (true = Celsius, false/omitted = Fahrenheit).
Complete code sample
Copy a full, runnable example that fetches a 12-hour forecast and lists hours with a high chance of rain.
Next steps
- 5-Day Daily Forecast — high/low temperatures and day/night summaries for longer-range planning
- Current Conditions — complement forecasts with a real-time snapshot