One Logo Pool Ball
WeatherKit · IOS API REFERENCE

WeatherService

class · iOS 16.0+ · SDK 27.1

final class WeatherService

Provides an interface for obtaining weather data.

Members (10)

get · iOS 16.0+

attribution

TypeScript
get attribution(): Promise<WeatherAttribution>
Swift declaration
final var attribution: WeatherAttribution { get async throws }

The required attribution which includes a legal attribution page and Apple Weather mark.

get · iOS 16.0+

shared

TypeScript
static get shared(): WeatherService
Swift declaration
static let shared: WeatherService

A single, shared weather service object. Use this object to interface to weather services in your application. If you need to prioritize weather information, create separate instances with `init`.

method · iOS 16.0+

weather

TypeScript
weatherForIncluding(location: __LocationEssentials_CLLocation, dataSet1: WeatherQuery<number>, dataSet2: WeatherQuery<number>, dataSet3: WeatherQuery<number>, dataSet4: WeatherQuery<number>, dataSet5: WeatherQuery<number>, dataSet6: WeatherQuery<number>): Promise<[number, number, number, number, number, number]>
Swift declaration
@preconcurrency final func weather<T1, T2, T3, T4, T5, T6>(for location: CLLocation, including dataSet1: WeatherQuery<T1>, _ dataSet2: WeatherQuery<T2>, _ dataSet3: WeatherQuery<T3>, _ dataSet4: WeatherQuery<T4>, _ dataSet5: WeatherQuery<T5>, _ dataSet6: WeatherQuery<T6>) async throws -> (T1, T2, T3, T4, T5, T6) where T1 : Sendable, T2 : Sendable, T3 : Sendable, T4 : Sendable, T5 : Sendable, T6 : Sendable

Returns the weather forecast for the requested location. - Parameter location: The requested location. - Throws: Weather data error `WeatherError` - Returns: The requested weather data set. This is a variadic API in which any combination of data sets can be requested and returned as a tuple. Here's an example: ``` `let (current, minute, hourly, daily, alerts) = try await service.weather(for: newYork, including: .current, .minute, .hourly, .daily, .alerts)` ```

method · iOS 16.0+

weather

TypeScript
weatherForIncluding11867(location: __LocationEssentials_CLLocation, dataSet1: WeatherQuery<number>, dataSet2: WeatherQuery<number>, dataSet3: WeatherQuery<number>, dataSet4: WeatherQuery<number>, dataSet5: WeatherQuery<number>): Promise<[number, number, number, number, number]>
Swift declaration
@preconcurrency final func weather<T1, T2, T3, T4, T5>(for location: CLLocation, including dataSet1: WeatherQuery<T1>, _ dataSet2: WeatherQuery<T2>, _ dataSet3: WeatherQuery<T3>, _ dataSet4: WeatherQuery<T4>, _ dataSet5: WeatherQuery<T5>) async throws -> (T1, T2, T3, T4, T5) where T1 : Sendable, T2 : Sendable, T3 : Sendable, T4 : Sendable, T5 : Sendable

Returns the weather forecast for the requested location. - Parameter location: The requested location. - Throws: Weather data error `WeatherError` - Returns: The requested weather data set. This is a variadic API in which any combination of data sets can be requested and returned as a tuple. Here's an example: ``` let (current, minute, hourly, daily, alerts) = try await service.weather(for: newYork, including: .current, .minute, .hourly, .daily, .alerts) ```

method · iOS 16.0+

weather

TypeScript
weatherForIncluding48270(location: __LocationEssentials_CLLocation, dataSet1: WeatherQuery<number>, dataSet2: WeatherQuery<number>, dataSet3: WeatherQuery<number>, dataSet4: WeatherQuery<number>): Promise<[number, number, number, number]>
Swift declaration
@preconcurrency final func weather<T1, T2, T3, T4>(for location: CLLocation, including dataSet1: WeatherQuery<T1>, _ dataSet2: WeatherQuery<T2>, _ dataSet3: WeatherQuery<T3>, _ dataSet4: WeatherQuery<T4>) async throws -> (T1, T2, T3, T4) where T1 : Sendable, T2 : Sendable, T3 : Sendable, T4 : Sendable

Returns the weather forecast for the requested location. - Parameter location: The requested location. - Throws: Weather data error `WeatherError` - Returns: The requested weather data set. This is a variadic API in which any combination of data sets can be requested and returned as a tuple. Here's an example: ``` let (current, minute, hourly, daily) = try await service.weather(for: newYork, including: .current, .minute, .hourly, .daily) ```

method · iOS 16.0+

weather

TypeScript
weatherForIncluding66675(location: __LocationEssentials_CLLocation, dataSet1: WeatherQuery<number>, dataSet2: WeatherQuery<number>, dataSet3: WeatherQuery<number>): Promise<[number, number, number]>
Swift declaration
@preconcurrency final func weather<T1, T2, T3>(for location: CLLocation, including dataSet1: WeatherQuery<T1>, _ dataSet2: WeatherQuery<T2>, _ dataSet3: WeatherQuery<T3>) async throws -> (T1, T2, T3) where T1 : Sendable, T2 : Sendable, T3 : Sendable

Returns the weather forecast for the requested location. - Parameter location: The requested location. - Throws: Weather data error `WeatherError` - Returns: The requested weather data set. This is a variadic API in which any combination of data sets can be requested and returned as a tuple. Here's an example: ``` let (current, minute, hourly) = try await service.weather(for: newYork, including: .current, .minute, .hourly) ```

method · iOS 16.0+

weather

TypeScript
weatherForIncluding90072(location: __LocationEssentials_CLLocation, dataSet1: WeatherQuery<number>, dataSet2: WeatherQuery<number>): Promise<[number, number]>
Swift declaration
@preconcurrency final func weather<T1, T2>(for location: CLLocation, including dataSet1: WeatherQuery<T1>, _ dataSet2: WeatherQuery<T2>) async throws -> (T1, T2) where T1 : Sendable, T2 : Sendable

Returns the weather forecast for the requested location. - Parameter location: The requested location. - Throws: Weather data error `WeatherError` - Returns: The requested weather data set. This is a variadic API in which any combination of data sets can be requested and returned as a tuple. Here's an example: ``` let (current, minute) = try await service.weather(for: newYork, including: .current, .minute) ```

method · iOS 16.0+

weather

TypeScript
weatherForIncluding80774(location: __LocationEssentials_CLLocation, dataSet: WeatherQuery<number>): Promise<number>
Swift declaration
@preconcurrency final func weather<T>(for location: CLLocation, including dataSet: WeatherQuery<T>) async throws -> T where T : Sendable

Returns the weather forecast for the requested location. - Parameter location: The requested location. - Throws: Weather data error `WeatherError` - Returns: The requested weather data set. This is a variadic API in which any combination of data sets can be requested and returned as a tuple. Here's an example: ``` let current = try await service.weather(for: newYork, including: .current) ```

method · iOS 16.0+

weather

TypeScript
weatherFor(location: __LocationEssentials_CLLocation): Promise<Weather>
Swift declaration
final func weather(for location: CLLocation) async throws -> Weather

Returns the weather forecast for the requested location. - Parameter location: The requested location. - Throws: Weather data error `WeatherError` - Returns: The aggregate weather.

init · iOS 16.0+

init

TypeScript
static init(): WeatherService
Swift declaration
convenience init()

Creates a weather service object. Use this method to create different `WeatherService` instances, for example, to separate out high-priority and low-priority requests for performance. If you only need one instance of `WeatherService`, use `shared`.

Skipped declarations

12 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

WeatherService.weather(for:including:)

Swift parameter packs cannot cross the bridge.

WeatherService.dailyStatistics(for:forDaysIn:including:)

Swift parameter packs cannot cross the bridge.

WeatherService.dailyStatistics(for:including:)

Swift parameter packs cannot cross the bridge.

WeatherService.dailyStatistics(for:startDay:endDay:including:)

Swift parameter packs cannot cross the bridge.

WeatherService.dailySummary(for:forDaysIn:including:)

Swift parameter packs cannot cross the bridge.

WeatherService.dailySummary(for:including:)

Swift parameter packs cannot cross the bridge.

WeatherService.hourlyStatistics(for:forHoursIn:including:)

Swift parameter packs cannot cross the bridge.

WeatherService.hourlyStatistics(for:including:)

Swift parameter packs cannot cross the bridge.

WeatherService.hourlyStatistics(for:startHour:endHour:including:)

Swift parameter packs cannot cross the bridge.

WeatherService.monthlyStatistics(for:including:)

Swift parameter packs cannot cross the bridge.

WeatherService.monthlyStatistics(for:forMonthsIn:including:)

Swift parameter packs cannot cross the bridge.

WeatherService.monthlyStatistics(for:startMonth:endMonth:including:)

Swift parameter packs cannot cross the bridge.

All WeatherKit types →