WeatherKit

RSS for tag

Bring weather information to your apps and services through a wide range of data that can help people stay up to date, safe, and prepared.

Posts under WeatherKit tag

67 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Hourly history with WeatherKit REST API
Has anyone figured out the correct incantation of request parameters to get historic hourly weather conditions from WeatherKit? I've tried every combo of hourlyStart, dailyStart, currentAsOf, etc with past dates and it seems like the oldest it will go back to is midnight for today. I would like to get the last 24 hours of conditions.
11
4
4.9k
Aug ’23
Weather Kit is not returning historical data
I'm trying to get historical data using the following syntax: try await service.weather(for: location, including: .daily(startDate: past1, endDate: past2)) Where past1 and past2 are two dates in the past (I checked their format and they are correct). I always get the same result, namely the 10 days default forecast you usually get calling service.weather(for: location) Am I missing something?
4
3
1.5k
Oct ’23
WeatherKit Apple Weather trademark and legal link.
I have read the WeatherKit docs and watched the "Meet WeatherKit" WWDC video but it is not clear where the trademark and legal link need to be displayed. Can someone at Apple please clarify this. The docs state: "If your apps, web apps, or websites display any Apple weather data, you must clearly display the Apple Weather trademark, as well as the legal link to other data sources." I have a calendar style app on the App Store and want to incorporate weather data as simple icons into the day, week, month views with in the app. Is it ok to just display the trademark and legal link in the app's Settings view where a user would first turn on this weather feature? Or does it have to be displayed on every single view where weather data is displayed? Even if that data is just displaying a simple Sun or Cloud or Rain symbol to the user. Thanks.
3
3
1.8k
Oct ’23
Consistently getting JWT errors
I have added the WeatherKit capability and enabled it in the developer account for the respective app id. I continually get this error. Any ideas on how to fix this? Failed to generate jwt token for: com.apple.weatherkit.authservice with error: Error Domain=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors
4
3
1.4k
Mar ’24
WeatherKit localization options
I am working on an app that pulls data from weatherKit, including the conditionCode property, the content of which is displayed to the user. I wish to localize the data pulled from weatherKit but when pulling data from: weatherkit.apple.com/api/v1/weather/de/{latitude}/{longitude} The conditionCode and other strings is in english. Same is true if the language parameter is set to es, ja or something else. Am I doing something wrong or is localization yet to be supported in weatherKit? I can't find any documentation on this.
4
0
2.7k
Jan ’24
WeatherKit Historical Data Request Limited to 10 Days
Until recently, I was unable to use WeatherKit to obtain historical Daily data. Now, it appears that I can retrieve Daily and Hourly historical data, but the returned data is limited to a ten day period. No matter what start and end dates are included, I get data from start date to 10 days later (assuming the end date was more than 10 days after the start). Is this a permanent restriction? Example: let historicalData = try await weatherService.weather(for: location, including: .daily(startDate: startDate, endDate: endDate))
2
1
1.4k
Nov ’23
WeatherKit Swift / REST mismatch? daytimeForecast and overnightForecast not available via Swift?
I am able to obtain daily forecasts via the REST API which include the daytimeForecast and overnightForecast records with their respective properties like cloudCover. So far I have failed to access them via the Swift API: forecast.daytimeForecast.cloudCover results in: "Value of type 'DayWeather' has no member 'daytimeForecast'". But if I print() the DayWeather objects, these members are actually printed with all their properties. Is there a way to get them I am overlooking?
2
0
1.6k
Jul ’23
Hourly precipitation amounts seem drastically low
Hello. I took a closer look at the data I'm getting back for hourly forecasts and I'm baffled by results I'm seeing. For example, it's Dec 19, 2022 8:00am PT and I'm asking for the weather for Orchard Park NY (lat 42.766437 long -78.743855) for Dec 23, 2022. The daily forecast tells me they're expected to have 5.9" of snow. However, the hourly forecast with the most snow that day is reported as 0.071" (1.8mm). The Apple Weather app on iOS shows that hour as having 0.6". I wrote a 'for' loop to print the results of my call to WeatherService.shared.weather.         print(oneHour.precipitationAmount.formatted())         print(oneHour.precipitationAmount.description)         print(oneHour.precipitationAmount.unit)         print(oneHour.precipitationAmount.value) 0.071 in 1.8 mm <_NSStatic_NSUnitLength: 0x2010b0178> mm 1.8
7
0
1.7k
2w
WeatherKit Gives 404
When I'm using the following code into the simulator it gives the wanted result: Button {                 Task {                     localWeather = try await WeatherService.shared.weather(for: CLLocation(latitude: 52.5153, longitude: 6.08565), including:  .daily(startDate: Date(), endDate: Calendar.current.date(byAdding: .day, value: 1, to: Date())!)).first.debugDescription                 }             } label: {                 Text("Get the test weather")             }             Text(localWeather) When I'm using this exact code on a real device I get the following 404 error: [WeatherDataService] Received invalid http response code 404 for request: C7AEC7CC-E5F7-425D-8491-25B9302E2A0F:0 [WeatherService] Encountered an error when fetching weather data subset; location=<+52.51530000,+6.08565000> +/- 0.00m (speed -1.00 mps / course -1.00) @ 05/01/2023, 13:55:53 Central European Standard Time,  error=responseFailed(<NSHTTPURLResponse: 0x282ce0260> { URL: https://weather-data.apple.com/v3/weather/en/52.515/6.086?timezone=Europe/Amsterdam&dataSets=forecastHourly,forecastDaily&dailyStart=2023-01-10T12:00:00Z&dailyEnd=2023-01-10T12:00:00Z&hourlyStart=2023-01-10T11:00:00Z&hourlyEnd=2023-01-10T16:00:00Z&country=NL } { Status Code: 404, Headers {     "Access-Control-Allow-Origin" =     (         "*"     );     "Cache-Control" =     (         "max-age=0, no-cache, no-store"     );     Connection =     (         "keep-alive"     );     "Content-Length" =     (         0     );     "Content-Security-Policy" =     (         "default-src 'self';"     );     Date =     (         "Thu, 05 Jan 2023 12:59:27 GMT"     );     Expires =     (         "Thu, 05 Jan 2023 12:59:27 GMT"     );     Pragma =     (         "no-cache"     );     Server =     (         "AppleHttpServer/21be5247c6351682d1d9aa22fe98c8f0d4902838"     );     "Strict-Transport-Security" =     (         "max-age=31536000; includeSubDomains",         "max-age=31536000"     );     "X-Apple-Origin" =     (         "bcd49c7f-c567-3921-a041-3d4ef58e5423"     );     "X-B3-TraceId" =     (         c8c6547722afc53f     );     "X-Cache" =     (         "TCP_MISS from a104-110-190-91.deploy.akamaitechnologies.com (AkamaiGHost/10.10.3-45298580) (-)"     );     "X-Content-Type-Options" =     (         nosniff     );     "X-Frame-Options" =     (         DENY     );     "X-REQUEST-ID" =     (         "407e37bc-ddf6-45fd-84d0-1d3d3b8651b0"     );     "X-XSS-Protection" =     (         "1; mode=block"     ); } }, Optional("")) I fixed it once by deleting Xcode and the app from my iPhone, but that doesn't work anymore. Any suggestions?
3
3
1.4k
Dec ’23
WeatherKit REST API new columns for CurrentWeather
My pipeline broke today as new fields were added for the current weather dataset: cloudCoverLowAltPct cloudCoverMidAltPct cloudCoverHighAltPct I presumed new fields would only be released in a new version of the API? Is there any way to use a specific version of the API that will not be subject to change? The current weather REST API docs are here, which don't include these fields: https://developer.apple.com/documentation/weatherkitrestapi/currentweather/currentweatherdata
6
1
967
3w
WeatherKit: Couldn't lookup symbols
I'm not able to inspect WeatherKit objects like HourWeather and CurrentWeather using the Xcode debugger and breakpoints. When I pause on a breakpoint and try something like po hours where hours is a [HourWeather] I get a debugger error like Couldn't lookup symbols: type metadata accessor for WeatherKit.HourWeather. Is there something about WeatherKit that prevents the debugger from printing out its objects?
1
1
668
Nov ’23
WeatherKit error on iOS 17 - macOS 14
Hi I upgraded my Mac to test the new os and iOS 17. But I have problems with the weather kit on the app. WeatherKit enabled as app service and capability there was no issue with the iOS 16. What could be the problem? import Foundation import WeatherKit class WeatherKitManager: ObservableObject { @Published var weather: Weather? @Published var isFetchingWeather = false func getWeather(latitude: Double, longitude: Double) async { do { let receivedWeather = try await WeatherService.shared.weather(for: .init(latitude: latitude, longitude: longitude)) DispatchQueue.main.async { self.weather = receivedWeather } } catch { fatalError("\(error)") } } var symbol: String { weather?.currentWeather.symbolName ?? "xmark.app" } var temp: String { if let temp = weather?.currentWeather.temperature.converted(to: .celsius) { let formattedTemp = String(format: "%.1f", temp.value) return "\(formattedTemp)°C" } else { return "Yükleniyor..." } } } Errors here Ceyehat/WeatherKitManager.swift:22: Fatal error: Error Domain=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors Code=2 "(null)" Failed to generate jwt token for: com.apple.weatherkit.authservice with error: Error Domain=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors Code=2 "(null)" Encountered an error when fetching weather data subset; location=<+37.78583400,-122.40641700> +/- 0.00m (speed -1.00 mps / course -1.00) @ 06/06/2023, 5:32:55 PM GMT+03:00, error=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors 2 Error Domain=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors Code=2 "(null)"
23
7
4.6k
Oct ’23
WeatherKit REST API 401 Unauthorized {reason:NOT_ENABLED}
Hello - migrated from darksky to WeatherKit in April of this year. With some difficulty finally got the REST API to work via the following resources: https://developer.apple.com/weatherkit/get-started/ which is horribly inadequate for JWT instructions. So i also used: https://dev.iachieved.it/iachievedit/weatherkit-rest-api/ which was quite helpful. As stated, in April i managed to get this working. About a week ago it stopped working. The response from my calls are 401 Unauthorized in the header and { "reason": "NOT_ENABLED" } in the body. I believe the key i created expired and thus WeatherKit stopped responding. So i tried to re-enable access using the same Apple key and a new JWT signature. That did not seem to work, so i removed the old key and created a new one. Downloaded the p8 file and used openssl on my ubuntu server to create pem and pub files for the jwt token. Still nothing. I have tried almost all combinations of keys and ID #s in the JWT.io console that i can think of. Importantly, nowhere in the official Apple documentation does it say what parameters the key creation and expiry dates can be. Does the key creation date have to match the date the key was created in Apple Developer Console??? What expiry dates are valid???? No idea. I have submitted a code level request, but they punted me to feedback which apparently does nothing. Still no resolution, nor have i been contacted once by an Apple representative. This is what my $200 developer fee gets me?! Unacceptable. If anyone has any idea on how to resolve this issue and/or create valid jwt tokens easier (via PHP preferably), i'm all ears. Thanks, airyt
1
1
959
Aug ’23
clarification on precipitationItensity/precipitationChance
I've received a forecast with non-zero precipitationChance and zero precipitationIntensity. Is this expected? How should I interpret the data? { "forecastStart": "2023-09-02T02:00:00Z", "cloudCover": 0.55, "conditionCode": "PartlyCloudy", "daylight": false, "humidity": 0.92, "precipitationAmount": 0, "precipitationIntensity": 0, "precipitationChance": 0.31, "precipitationType": "clear", "pressure": 1017.56, "pressureTrend": "steady", "snowfallIntensity": 0, "snowfallAmount": 0, "temperature": 12.56, "temperatureApparent": 12.22, "temperatureDewPoint": 11.26, "uvIndex": 0, "visibility": 23505.2, "windDirection": 233, "windGust": 6.17, "windSpeed": 2.82 }
0
0
416
Aug ’23