WeatherKit - one "request" or two?

I have a Swift app that fetches current conditions and daily forecasts. It is in production and working without issues.

My question is whether the fetch I am using counts as a single “request” for usage thresholds, or two (one for current conditions, one for daily forecast)?

I need current conditions more often than daily forecast, so if this is counting as two requests, I could refactor the logic to get each separately as needed. But separating the requests would use more quota if the combined fetch counts as a single request.

let service = WeatherService()

let location = CLLocation(latitude: weatherData.lat, longitude: weatherData.lon)
                
let startOfToday = Calendar.current.startOfDay(for: Date())
let endDate = Calendar.current.date(byAdding: DateComponents(day: 2), to: startOfToday)!
let current: CurrentWeather
let daily: Forecast<DayWeather>
                
(current, daily) = try await service.weather(for: location, including: .current, .daily(startDate: startOfToday, endDate: endDate))

Accepted Reply

That is a single request that returns two different data sets. Each call to WeatherService.weather counts as a single request. If you split that into two different calls each call would count separately against your usage quota.

  • Thank you.

Add a Comment

Replies

That is a single request that returns two different data sets. Each call to WeatherService.weather counts as a single request. If you split that into two different calls each call would count separately against your usage quota.

  • Thank you.

Add a Comment