Recipe: 5-Day Daily Forecast
This recipe shows how to retrieve a 5-day daily forecast — the most common weather data type for travel apps, event planners, home screens, and marketing dashboards.
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 display a 5-day forecast card showing the daily high/low temperatures and whether to expect rain for each day."
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 Daily Forecast API supports multiple durations:
| Duration param | Days of data | Notes |
|---|---|---|
1day | 1 | Today only |
5day | 5 | Most common; free-tier compatible |
10day | 10 | Medium-range planning |
15day | 15 | Extended planning |
25day | 25 | Seasonal planning |
45day | 45 | Requires Enterprise tier |
Extended details
Add details=true to receive additional fields per day: sunrise/sunset, moon phase, air quality & pollen indices, precipitation probability, wind, cloud cover, and more.
Code
Selected additional fields with details=true:
Code
AirAndPollen is perfect for building health-aware weather features — surface pollen, air quality, and UV index alongside the standard forecast data.
Key response fields
| Field | Type | Description |
|---|---|---|
Headline.Text | String | Plain-language summary of the most significant event |
Headline.Severity | Integer | Severity level (1 = extreme → 7 = minor) |
DailyForecasts[].Date | String | ISO 8601 date for the forecast day |
DailyForecasts[].Temperature.Minimum.Value | Number | Daily low temperature |
DailyForecasts[].Temperature.Maximum.Value | Number | Daily high temperature |
DailyForecasts[].Day.Icon | Integer | Daytime weather icon code |
DailyForecasts[].Day.IconPhrase | String | Daytime weather description |
DailyForecasts[].Day.HasPrecipitation | Boolean | Whether daytime precipitation is expected |
DailyForecasts[].Day.PrecipitationType | String | null | "Rain", "Snow", "Ice", or "Mixed" |
DailyForecasts[].Night.IconPhrase | String | Nighttime weather description |
DailyForecasts[].Day.ShortPhrase (details) | String | Short daytime summary phrase |
DailyForecasts[].Day.PrecipitationProbability (details) | Integer | Probability of any daytime precipitation |
DailyForecasts[].Sun (details) | Object | Sunrise and sunset times |
DailyForecasts[].AirAndPollen (details) | Array | Pollen, UV, and air quality indices |
Request metric units
Append &metric=true to receive temperatures in Celsius instead of Fahrenheit:
Code
Common pitfalls
Headline vs. per-day data — The Headline describes the single most significant event across the entire forecast period, not just today. Don't use it as a substitute for per-day data; always read DailyForecasts for day-by-day accuracy.
HasPrecipitation vs. PrecipitationProbability — HasPrecipitation (in the basic response) is a boolean threshold. For a nuanced view, use details=true to get the actual PrecipitationProbability percentage so you can tune your display (e.g., show a rain icon only above 40%).
Complete code sample
Copy a full, runnable example that fetches the 5-day forecast and prints a day-by-day summary.
Next steps
- Hourly Forecast — drill down into hour-by-hour data for any of these days
- Current Conditions — pair forecasts with a live snapshot of what's happening right now