Streaming is available in most browsers,
and in the Developer app.
-
Bring context to today’s weather
Harness the power of WeatherKit to get detailed weather forecast data such as precipitation amounts by type, cloud cover by altitude, or maximum wind speed. Find out how you can summarize weather by different parts of the day and highlight significant upcoming changes to temperature or precipitation. Understand how you can compare current weather to the past through our Historical Comparisons dataset and dive into historical weather statistics for any location in the world. We'll also explore how you can do all of this faster with our Swift and REST APIs.
Chapters
- 0:00 - Introduction
- 1:10 - Richer forecast details
- 10:03 - Highlight weather changes
- 14:10 - Faster data transfer
Resources
- Forum: Maps & Location
- Request authentication for WeatherKit REST API
- WeatherKit
- WeatherKit REST API
Related Videos
WWDC22
-
DownloadArray
-
-
2:40 - Fetch Precipitation Amount
import CoreLocation import Foundation import WeatherKit extension CLLocation { static var newYork: CLLocation { CLLocation(latitude: 50.710, longitude: -74.006) } } let hourlyPrecipitation = try await WeatherService() .weather(for: .newYork, including: .hourly) .map(\.precipitationAmount)
-
3:25 - Fetch Precipitation Amount (REST)
https://weatherkit.apple.com/api/v2/weather/en-US/40.710/-74.006?dataSets=forecastHourly&relativeHourlyStart=0&relativeHourlyEnd=1&hourlyRelativeTo=now&timezone=America/New_York
-
6:05 - Weather Changes
import CoreLocation import Foundation import WeatherKit extension Date { var isTomorrow: Bool { return Calendar.current.isDateInTomorrow(self) } } let changes = try await WeatherService() .weather(for: .newYork, including: .changes) let lowTemperatureChanges = changes? .filter(\.date.isTomorrow) .map(\.lowTemperature) if let lowTemperatureChanges, lowTemperatureChanges.contains(.decrease) { // Lower temperatures expected tomorrow }
-
6:43 - Weather Changes (REST)
https://weatherkit.apple.com/api/v2/weather/en-US/40.710/-74.006?dataSets=weatherChanges
-
8:17 - Historical Comparisons
import CoreLocation import Foundation import WeatherKit let mostSignificant = try await WeatherService() .weather(for: .newYork, including: .historicalComparisons)? .first switch mostSignificant { case .highTemperature(let trend), .lowTemperature(let trend): // Display temperature trend break case .some, .none: break }
-
8:36 - Historical Comparisons (REST)
https://weatherkit.apple.com/api/v2/weather/en-US/40.710/-74.006?dataSets=historicalComparisons
-
11:11 - Monthly Statistics
import CoreLocation import Foundation import WeatherKit let averagePrecipitation = try await WeatherService() .monthlyStatistics( for: .newYork, startMonth: 1, endMonth: 12, including: .precipitation ) let averagePrecipitationAmountsPerMonth = Dictionary( grouping: averagePrecipitation, by: \.month )
-
11:41 - Monthly Statistics (REST)
https://weatherkit.apple.com/api/v2/statistics/monthly/40.710/-74.006?dataSets=precipitation&start=1&end=12
-
12:52 - Daily Summary
import CoreLocation import Foundation import WeatherKit extension Date { static var thirtyDaysAgo: Date { return Calendar.current.date(byAdding: .day, value: -30, to: .now)! } } let pastThirtyDaysSummary = try await WeatherService() .dailySummary( for: .newYork, forDaysIn: DateInterval(start: .thirtyDaysAgo, end: .now), including: .precipitation ) .first if let pastThirtyDaysSummary { // We have a daily weather summary for each day in the past 30 days }
-
13:22 - Daily Summary (REST)
https://weatherkit.apple.com/api/v2/summary/daily/40.710/-74.006?dataSets=precipitation&start=2024-05-12&end=2024-06-10
-
-
Looking for something specific? Enter a topic above and jump straight to the good stuff.
An error occurred when submitting your query. Please check your Internet connection and try again.