Overview
Breeze uses the Open-Meteo Archive API to fetch historical climate data, enabling the app to display temperature trends over multiple decades. This powers the climate visualization feature that shows how temperatures have changed at a specific location.Base URL
Endpoints Used
Get Historical Climate Data
Fetches historical temperature data for specific dates and locations. Query Parameters:| Parameter | Type | Description |
|---|---|---|
latitude | Double | Geographic latitude of the location |
longitude | Double | Geographic longitude of the location |
start_date | String | Start date in YYYY-MM-DD format |
end_date | String | End date in YYYY-MM-DD format |
daily | String | Daily weather variables to include |
timezone | String | Timezone for the response (set to "auto") |
temperature_2m_max- Maximum daily temperature at 2 meters above ground
Response Format
The API returns historical weather data in the following structure:Response Model
Breeze decodes the response into these Swift models:Usage Example
Breeze queries historical data for the same date across multiple years to show long-term trends:Historical Data Strategy
Sampled Years
Breeze queries data for six specific years to show climate trends:- 1980 - Baseline from 40+ years ago
- 1990 - 30-year mark
- 2000 - Turn of the century
- 2010 - Recent decade
- 2020 - Very recent
- Current Year - Today’s context
Same Date Across Years
The service queries the same month and day across all years to provide meaningful comparisons. For example, if today is March 15, 2026, it fetches data for:- March 15, 1980
- March 15, 1990
- March 15, 2000
- March 15, 2010
- March 15, 2020
- March 15, 2026
Example Request
For San Francisco on March 15, 2026:Temperature Units
The API returns temperatures in Celsius by default. Temperature values represent:- temperature_2m_max: Maximum temperature at 2 meters above ground level
- Measured in degrees Celsius
- Breeze can convert to Fahrenheit for display based on user preferences
Visualization
The climate data is displayed in a chart showing:- X-axis: Years (1980 to present)
- Y-axis: Temperature (°C or °F)
- Line graph connecting data points
- Trend visualization to show warming or cooling patterns
Data Availability
Historical Coverage
The Open-Meteo Archive API provides:- Global coverage for most locations
- Historical data dating back to 1940 or earlier
- Daily resolution for temperature measurements
- Reliable data from weather stations and reanalysis models
Data Quality
Some considerations:- Historical data availability varies by location
- Remote areas may have sparser historical records
- The service gracefully handles missing data by skipping failed requests
Error Handling
The service implements robust error handling:- Network issues: Logged and skipped, doesn’t prevent other years from loading
- Missing data: Gracefully handled by checking for
nilvalues - Invalid dates: Skipped with
guard let urlcheck - Decode errors: Caught and logged without crashing
Performance Considerations
Sequential Requests
Breeze makes sequential requests for each year rather than parallel requests to:- Respect API rate limits
- Provide progressive loading feedback
- Handle errors for individual years independently
Caching
Historical climate data rarely changes, making it ideal for caching:- Data for past years can be cached indefinitely
- Only the current year needs frequent updates
- Reduces API calls on subsequent app launches
Rate Limits
Open-Meteo APIs are free and do not require an API key. They have generous rate limits, but consider:- Making 6 sequential requests per location query
- Implementing caching to reduce repeated requests
- Respecting the free tier limitations
Reference
- Open-Meteo Archive API Documentation
- Service Implementation:
BreezeApp/Services/ClimateService.swift - Data Models:
BreezeApp/Models/ClimateData.swift - Visualization:
BreezeApp/Views/Environmental/ClimateChartView.swift