I have been struggling with getting accurate data from the weatherkit api. It tends to be just different enough from the weather app on the phone.
While debugging this I randomly added forecastNextHour to my dataset string and it suddenly made everything match the app and the data looked good.
For example there is at this moment a snow storm in Billings. This url:
https://weatherkit.apple.com/api/v1/weather/en-US/45.79/-108.50?dataSets=currentWeather,forecastHourly,forecastNextHour&timezone=America/Denver&country=US
says that there is heavy snow, and there is a 100% chance for the next few hours. This matches the iOS app.
This url without forecastNextHour:
https://weatherkit.apple.com/api/v1/weather/en-US/45.79/-108.50?dataSets=currentWeather,forecastHourly&timezone=America/Denver&country=US
Says it is hazy and there is a small chance of snow of snow for the next few hours. Like 20-30 percent. This does not match any weather data I can find.
I have even checked the forecastStart times and the current weather asOf time. They all match up and are accurate.
Is there some unknown reason that without forecastNextHour the API becomes inaccurate?
Thanks!
WeatherKit
RSS for tagBring 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
62 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I just noticed something really odd with WeatherKit.
If the temperate at midnight of the FOLLOWING day is colder than all temps in the day you want weather for then WeatherKit will report that as the low temperature for the day even though it's a different day.
Here it's reporting the lowest temp for Feb 6 is 22F. But that's a temp from Feb 7. I'm displaying lowTemperature and lowTemperatureTime from DayWeather as well as the HourWeather in these examples.
I wasn't sure if this was working as designed or a bug. I can provide raw data from this example.
----daily formatted start
weather for Feb 6
High 41°
high at Feb 6 at 2 PM
Low 22°
low at Feb 7 at 12 AM
----daily formatted end
Feb 6 at 12 AM 34°
Feb 6 at 1 AM 35°
Feb 6 at 2 AM 36°
Feb 6 at 3 AM 36°
Feb 6 at 4 AM 36°
Feb 6 at 5 AM 34°
Feb 6 at 6 AM 33°
Feb 6 at 7 AM 33°
Feb 6 at 8 AM 33°
Feb 6 at 9 AM 33°
Feb 6 at 10 AM 35°
Feb 6 at 11 AM 36°
Feb 6 at 12 PM 38°
Feb 6 at 1 PM 40°
Feb 6 at 2 PM 41°
Feb 6 at 3 PM 40°
Feb 6 at 4 PM 39°
Feb 6 at 5 PM 37°
Feb 6 at 6 PM 36°
Feb 6 at 7 PM 33°
Feb 6 at 8 PM 31°
Feb 6 at 9 PM 29°
Feb 6 at 10 PM 27°
Feb 6 at 11 PM 24°
Feb 7 at 12 AM 22°
I've noticed that very consistently the Weatherkit API times out when I make a large(-ish) number of calls at 7am east coast time.
If I make x calls between 7:00:00 and 7:01:00 about half of them time out (as do retries.)
If I make 2x the calls between 7:15:00 and 7:16:00 there are close to zero time outs.
I've looked at the logs, at the calls per second, etc., and there is no difference between 7 and 7:15.
So, I'm not hitting a rate limit. It seems like Weatherkit itself just can't handle the traffic at peak times.
Is there any other explanation? Does Apple intend to make sure the API can handle all the traffic they are getting paid to handle?
I have been using the hourly weather forecast API, for some reason sometimes the API fails with 400 Bad Request, but on retrying just a minute later the call successfully returns data. The start and end time are 2 days apart so I don't think it's an issue with the time frame.
The failed calls also don't return any reason so not sure what is the exact failure.
Has anyone encountered this issue or knows why this might be happening??
Thanks!!
Background:
We are using Apple WeatherKit for an app to fetch future weather data specialty cloudCover and condition and pretipitationChance from the Overnightforecast data from weatherResponse.dailyForecast.forecast array object.
Code Sample:
On xcode on Swift and Swift UI using Apple WeatherKit
task{
do{
let weatherResponse= try await self.weatherService.forecast(for: latLong)
let cloudCover = weatherResponse.dailyForecast.forecast[0].overnightforecast.cloudCover
Issue:
While we are on debug mode, we can literally see overnightforecast.cloudCover data (as well as condition and pretipitationChance) is available under from index 0 to index 10 of weatherResponse.dailyForecast.forecast array object but when we are trying to assign this property, its throwing error as
"overnightforecast object not present under weatherResponse.dailyForecast.forecast array object"
Attachment:
Hello,
I have an app on the App Store built around WeatherKit and it was working fine, up until this morning when I started seeing errors when using the app.
When debugging using Xcode I see the familiar error
Failed to generate jwt token for: com.apple.weatherkit.authservice with error: Error Domain=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors Code=2 "(null)"
which, according to what I've read on the forums looks like an authentication error.
Attaching a network debugger to the Simulator, I saw this error:
This I have tried:
Verify that WeatherKit is enabled on both Capabilities and App Services tabs on the Dev Portal.
Toggle on/off this value and regenerate Provisioning Profiles
Uninstall/reinstall
Checking that I have API available calls.
Nothing. If I create a new Bundle ID and sign with that, it works correctly. But this is not an option since that will force all my customers to download everything from scratch.
I am getting emails from customers demanding money back and I can't figure out what has happened.
The only thing I can think of, is that I started developing an Apple Watch app to complement the iOS app, but that was last week and everything was working fine.
After changing the bundle identifier of my app, I’ve encountered several issues that I can’t seem to resolve, even though I’ve followed all the necessary steps. The app with the previous identifier was live on Testflight, and working perfectly fine, but now I’m facing the following problems:
WeatherKit Authentication Issue
WeatherKit has stopped working, and I’m getting authentication errors. I’ve updated the app in the Developer Portal to reflect the new bundle ID, but it still doesn’t authenticate properly.
Xcode Cloud Configuration Issue:
Xcode is asking me to set up Xcode Cloud again, which I understand is expected after a bundle ID change. However, during the setup process, it fails to recognize my remote repository, even though the repository is correctly added and visible under the Source Control tab.
TestFlight Internal Testing Issue:
I manually uploaded a build to TestFlight, but internal testers cannot use it because the invitation appears as invalid. This wasn’t an issue with the app’s previous identifier.
It seems like the bundle ID change has caused some fundamental issues that I can’t resolve despite following all the usual instructions. Has anyone experienced this before or knows how to resolve these problems?
I'm using the latest Xcode 16.2 on Mac OS Sequoia 15.2
Hi there,
I am using WeatherKit to display weather forecast information in an app.
I would like to include some information about when the weather forecast was issued for my users to see.
This information is included in the response Metadata as documented in the WeatherKit REST API docs:
https://developer.apple.com/documentation/weatherkitrestapi/metadata
Specifically there is a “reportedTime” property which I would like to use here.
However I am consuming WeatherKit via the Swift API, I don’t see this property available via the Swift APIs.
How can I access the reportedTime property via the WeatherKit Swift APIs? Or is it not exposed via the Swift APIs?
I filed FB16332997 about the VERY high snowfall estimates I'm seeing in WeatherKit and iOS Weather. I initially thought something was wrong with my weather app but I verified the numbers with the iOS Weather app and another third party weather app.
For Atlanta last week it was saying 7.5" when it ended up being 2" (which I can live with).
Two days ago it reported there could be 16" of snow in northern Florida. That's impossible!
This morning it was reporting that Niceville could have 6-7" of snow, which would be significantly more than highest amount in recorded history for Florida (where snow is extremely rare).
It almost makes me wonder if the liquid precipitation value is actually the snowfall amount in reality. And then that is incorrectly being converted to the snowfall amount.
Hey,
I'm trying to update my old app that used DarkSky to WeatherKit, and struggling. I always get:
ailed to generate jwt token for: com.apple.weatherkit.authservice with error: Error Domain=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors Code=2 "(null)"
This is regardless if I do it on my iPad, or in the simulator. I have done the following:
Selected WeatherKit on the Capabilities and App Services tabs of the Identifier section on developer.
Put it under signing and capabilities in XCode
I've tried making a new provisioning profile, cleaning build folder, etc. Not sure what to do here. I suspect part of this problem is that I developed this app in 2018 and now I'm trying to update it.
I am able to run the app on TestFlight, but not as an internal tester. Apple won't let me, so I have to add myself as an external tester.
Thanks for any help you can provide!
Hi There,
My app displays both daily and hourly forecast information, as consumed from the Weatherkit API.
I would also like to let my users know when the forecast was generated/issued. The reason being, if a forecast was issued 1-2 hours in the past for example, then the user(s) will know to refresh the weather forecast for the latest information soon.
Looking through the docs, I don't see any way of accessing this information. I would expect it to be available on the hourlyForecast.metadata property.
Does anyone know if it's possible to obtain the 'issued time' of the forecast? (both hourly and daily).
Thanks
Hi,
I'm trying to implement WeatherKit for the first time and I am seeing this error when calling for the weather:
Failed to generate jwt token for: com.apple.weatherkit.authservice with error: Error Domain=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors Code=2 "(null)"
and
Encountered an error when fetching weather data subset; location=<+51.57750785,-2.08241362> +/- 6.55m (speed -1.00 mps / course -1.00) @ 11/01/2025, 11:50:45 Greenwich Mean Time, error=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors 2 Error Domain=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors Code=2 "(null)"
I have:
Enabled the WeatherKit capability in my iOS app in XCode
Added Weatherkit to the AppID in the developer portal
Any suggestions what else I can check?
I'm running iOS 18.2.1 on 15 ProMax with XCode 16.2
Hello,
We are a happy user of WeatherKit REST API.
When can I expect weatherAlerts to work in Japan?
The availability endpoint doesn't return weatherAlerts and I hope it's coming soon.
I am really confused by some of the new data returned in WeatherKit for iOS 18.
The visibility (of an object) was already being returned in HourWeather as a Measurement.
iOS 18 added max/min visibility (of terrain) in DayWeather. BUT instead of a Measurement it's just a Double.
HourWeather:
/// The distance at which an object can be clearly seen.
///
/// The amount of light and weather conditions like fog, mist, and smog affect visibility.
public var visibility: Measurement<UnitLength>
DayWeather's comment:
/// The maximum distance at which terrain is visible for the day.
///
/// The amount of light, and weather conditions like fog, mist, and smog affect visibility.
@available(iOS 18.0, macOS 15.0, tvOS 18.0, watchOS 11.0, visionOS 2.0, *)
public var maximumVisibility: Double
This makes it sound like the new items are also a distance and not a percentage.
Why wasn't Measurement used so the unit would be clear? Documentation doesn't explain this either. I'm hoping that this isn't being returned in the unit used by the current locale because my app lets you specify what unit to use for temperature, length, etc regardless of locale. Since all the temperature, length, etc data returned had used Measurement that was possible.
The iOS weather app refers to the lowest/highest visibility in my preferred unit, which is miles.
I'm doing a weather app, users can search locations for getting weather, but the problem is, the results only shows locations in my country, not in global. For example, I'm in China, I can't search New York, it just shows nothing. Here's my code:
@Observable
class SearchPlaceManager: NSObject {
var searchText: String = ""
let searchCompleter = MKLocalSearchCompleter()
var searchResults: [MKLocalSearchCompletion] = []
override init() {
super.init()
searchCompleter.resultTypes = .address
searchCompleter.delegate = self
}
@MainActor
func seachLocation() {
if !searchText.isEmpty {
searchCompleter.queryFragment = searchText
}
}
}
extension SearchPlaceManager: MKLocalSearchCompleterDelegate {
func completerDidUpdateResults(_ completer: MKLocalSearchCompleter) {
withAnimation {
self.searchResults = completer.results
}
}
}
Also, I've tried to set searchCompleter.region = MKCoordinateRegion( center: CLLocationCoordinate2D(latitude: 0, longitude: 0), span: MKCoordinateSpan(latitudeDelta: 180, longitudeDelta: 360) ), but it doesn't work.
I am trying to add WeatherKit support to a commandline app to fetch historical data. I've configured an app ID with the WeatherKit entitlement, but WeatherKit does not appear in the Capabilities list to add. When I try to access weather data, it fails with Code=4097 "connection to service named com.apple.weatherkit.authservice" suggesting it's not authorized.
How do I add the WeatherKit entitlement to a commandline Swift app?
I've been using the weather kit API for months now without issue, but all of a sudden API queries return the response {"reason": "EXPIRED"}. The code around this area hasn't changed since June and the credentials haven't changed. The JWT is refreshed frequently (well within expiration). Have looked at the generated JWT in jwt.io and Payload and Header details correct and jwt.io reports JWT as "signature verified".
Is the JWT a red herring and its something else?
Here's an example URL:
https://weatherkit.apple.com/api/v1/weather/en_AU/-37.37834963844341/144.76238003519637?dailyStart=2024-12-12T13:00:00Z&dailyEnd=2024-12-13T13:00:00Z&timeZone=Australia/Melbourne&dataSets=forecastDaily
Would appreciate any insights you may have.
We have a service that was accessing the WeatherKit Api. We had the service up and running, using JWT authorisation and a registered service. Some time ago it stopped working, returning a 401 response. We need the service to be up again now.
We created a new JWS token following this instruction: https://dev.iachieved.it/iachievedit/weatherkit-rest-api/ which already workedfor us in 2022. However, we keep receiving a 401 error and the "reason": "NOT_ENABLED" message. We found that several other uses seem to be experiencing similar problems. We also created a new key and service identifier, but no luck.
大家好,
我目前正在开发一个需要使用WeatherKit的iOS应用程序。我已在我的aioutfit3.entitlements文件中添加了必要的权限,如下所示:
<?xml版本="1.0"编码="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist版本="1.0">
<字典>
<键>com.apple.developer.weatherkit</键>
<真实/>
</字典>
尽管如此,当我试图获取天气数据时,该应用程序报告说它找不到授权文件,并特别提到WeatherKit授权缺失。以下是日志输出的一部分:
❌未找到权利文件
📱捆绑ID:com.superhuang.aioutfit3
❌未找到WeatherKit权利
我已确认授权文件在Xcode项目中配置正确,并已尝试清理和重建该项目。然而,这个问题仍然存在。
有人遇到过类似的问题吗?或者有人有可能有助于解决这个问题的建议吗?非常感谢您的帮助!
我希望这个帖子的内容能帮助你在论坛上找到解决方案。如果您需要更多信息或修改,请告诉我!
一些图片
I'm using WeatherKit for my weather app built with SwiftUI. Even though the location is set in an area where the NWS is issuing weather alerts, WeatherKit randomly returns availability.alertAvailability as temporarilyUnavailable or unsupported, and the weatherAlerts is always nil.