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.

WeatherKit Documentation

Posts under WeatherKit tag

37 Posts
Sort by:
Post not yet marked as solved
1 Replies
99 Views
Hi all, WeatherKit is working fine within my contentView. I am trying to use the WeatherKit within SiriKit Intent Definition files. I am trying to call let weather = try! await weatherService.weather(for: location) How can I handle my SiriKit intent with the async/await function? Latitude and longitude (location) will be provided as input values from Shortcuts App. Thanks
Posted Last updated
.
Post not yet marked as solved
0 Replies
136 Views
My guess the issue is that the iOS app is com.example.MyApp and the bundle id for the watchOS app is com.example.MyApp.watchkitapp, so WeatherKit works perfectly on the iOS app after registering bundleID and request WeatherKit service. But it does not work on watchOS, giving me 401 errors. I assume it is because of the bundleID, but maybe something else. 2022-06-25 08:58:58.999485-0500 JumpLog Watch App[72341:1201484] [WK_Geocode] failed to reverse geocode. location=CLLocationCoordinate2D(latitude: 37.62471885, longitude: -122.42857813), error=reverseGeocodeFailed(Error Domain=NMDeviceConnectionErrorDomain Code=2 "Timed out." UserInfo={NSDescription=Timed out.}) 2022-06-25 08:58:59.019561-0500 JumpLog Watch App[72341:1201484] [Database] Attempting to invalidate an assertion that is no longer valid 2022-06-25 08:58:59.724802-0500 JumpLog Watch App[72341:1198856] [WeatherService] Encountered an error when fetching weather data subset; location=<+37.62471885,-122.42857813> +/- 5.00m (speed 34.21 mps / course 332.23) @ 6/25/22, 8:56:58 AM Central Daylight Time, error=invalidJWTResponse(Optional(<NSHTTPURLResponse: 0x60000394bf20> { URL: https://weather-data.apple.com/v2/token } { Status Code: 401, Headers { Connection = ( close ); "Content-Length" = ( 0 ); Date = ( "Sat, 25 Jun 2022 13:58:59 GMT" ); Server = ( Apple ); "Strict-Transport-Security" = ( "max-age=31536000; includeSubdomains" ); "X-Apple-Origin" = ( "8961098f-b238-3714-ba44-5b569c861456" ); "X-Cache" = ( "TCP_MISS from a23-33-47-144.deploy.akamaitechnologies.com (AkamaiGHost/10.8.2-41841244) (-)" ); "X-Content-Type-Options" = ( nosniff ); "X-Frame-Options" = ( SAMEORIGIN ); "X-REQUEST-ID" = ( "2076edab-2346-4a50-83c1-e62f46aab9eb" ); "X-XSS-Protection" = ( "1; mode=block" ); } }))
Posted Last updated
.
Post not yet marked as solved
1 Replies
124 Views
Hi, I'm in the process of developing a weather app using WeatherKit. Everything seems to be working fine in the Simulator, but when I put it on the device (iPhone 13 Pro Max) the temperature displays wrong. Example: On Simulator: 34 F On Device: 34.98 F Anyone else have this problem? Dan Uff
Posted Last updated
.
Post not yet marked as solved
2 Replies
135 Views
We are currently using the DarkSky API for energy forecasting, and one important piece of data is the solar DNI. With DarkSky we could set the solar parameter to true and we would get this data: "solar": { "azimuth": 275, "altitude": 30, "dni": 677.1, "ghi": 369.1, "dhi": 33.6, "etr": 1318.8 } The WeatherKit API does not appear to have this parameter. Does anyone know if it will have this solar data eventually? It will impact whether we can use the API or not.
Posted Last updated
.
Post not yet marked as solved
2 Replies
321 Views
I have upgraded from macOS 12.5.4 to macOS 13 Beta 1. Haven't done anything odd. I am attempting to use WeatherKit but I am getting a lot of (odd) errors: The sample can't access the ~/Library/Weather/ folder despite it being set to read for users, others and group. (I've since switched to read and write for all, but no dice). Lots of other odd errors. 2022-06-11 22:52:26.720487+0100 PlayWithWeatherKit[16282:277975] [WeatherService] Couldn't get access to the /Library/Weather directory for the geocode Store. error=Error Domain=NSCocoaErrorDomain Code=257 "The file “Weather” couldn’t be opened because you don’t have permission to view it." UserInfo={NSUserStringVariant=(     Folder ), NSURL=file:///Users/tarasis/Library/Weather, NSFilePath=/Users/tarasis/Library/Weather, NSUnderlyingError=0x6000013d4b70 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}} PlayWithWeatherKit[16282:277975] [] networkd_settings_read_from_file Sandbox is preventing this process from reading networkd settings file at "/Library/Preferences/com.apple.networkd.plist", please add an exception. PlayWithWeatherKit[16282:277975] [] networkd_settings_read_from_file Sandbox is preventing this process from reading networkd settings file at "/Library/Preferences/com.apple.networkd.plist", please add an exception. PlayWithWeatherKit[16282:277975] [WeatherDataService] Failed to create the weather data store, error=cantOpen(message: "authorization denied", location: TeaDB.Database.Location.path("/Users/tarasis/Library/Weather/weather-data.db")) PlayWithWeatherKit[16282:277991] [Metadata] unable to get a dev_t for store 1795162192. PlayWithWeatherKit[16282:277991] [] nehelper sent invalid response: <dictionary: 0x1ffa87480> { count = 1, transaction: 0, voucher = 0x0, contents = "XPCErrorDescription" => <string: 0x1ffa87618> { length = 18, contents = "Connection invalid" } } PlayWithWeatherKit[16282:277991] [] nw_parameters_set_source_application_by_bundle_id_internal Failed to convert from bundle ID (net.tarasis.test.wwdc.Playground) to UUID. This could lead to wrong data usage accounting. PlayWithWeatherKit[16282:277991] [connection] nw_endpoint_flow_validate_delegation [C1 weather-data.apple.com:443 in_progress parent-flow (satisfied (Path is satisfied), interface: en0, ipv4, ipv6, dns)] Network Delegation Failure: Invalid Bundle ID "net.tarasis.test.wwdc.Playground" [M] PlayWithWeatherKit[16282:277991] [] nw_resolver_can_use_dns_xpc_block_invoke Sandbox does not allow access to com.apple.dnssd.service PlayWithWeatherKit[16282:277991] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:14 Err:-1 Errno:1 Operation not permitted PlayWithWeatherKit[16282:277991] [connection] nw_resolver_create_dns_service_locked [C1.1] DNSServiceCreateDelegateConnection failed: ServiceNotRunning(-65563) PlayWithWeatherKit[16282:277991] Connection 1: received failure notification PlayWithWeatherKit[16282:277991] Connection 1: failed to connect 10:-72000, reason -1 PlayWithWeatherKit[16282:277991] Connection 1: encountered error(10:-72000) PlayWithWeatherKit[16282:277975] Task <0D654665-D88F-4C81-ABDA-FBFAAC0B01E5>.<1> HTTP load failed, 0/0 bytes (error code: -1003 [10:-72000]) PlayWithWeatherKit[16282:277975] Task <0D654665-D88F-4C81-ABDA-FBFAAC0B01E5>.<1> finished with error [-1003] Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={_kCFStreamErrorCodeKey=-72000, NSUnderlyingError=0x6000013b0060 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_NSURLErrorNWPathKey=satisfied (Path is satisfied), interface: en0, ipv4, ipv6, dns, _kCFStreamErrorCodeKey=-72000, _kCFStreamErrorDomainKey=10}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <0D654665-D88F-4C81-ABDA-FBFAAC0B01E5>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(     "LocalDataTask <0D654665-D88F-4C81-ABDA-FBFAAC0B01E5>.<1>" ), NSLocalizedDescription=A server with the specified hostname could not be found., NSErrorFailingURLStringKey=https://weather-data.apple.com/v2/token, NSErrorFailingURLKey=https://weather-data.apple.com/v2/token, _kCFStreamErrorDomainKey=10} PlayWithWeatherKit[16282:277975] [WeatherService] Encountered an error when fetching weather data subset; location=<+37.32299800,-122.03218100> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2022/06/11, 22:52:26 British Summer Time,  error=Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={_kCFStreamErrorCodeKey=-72000, NSUnderlyingError=0x6000013b0060 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_NSURLErrorNWPathKey=satisfied (Path is satisfied), interface: en0, ipv4, ipv6, dns, _kCFStreamErrorCodeKey=-72000, _kCFStreamErrorDomainKey=10}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <0D654665-D88F-4C81-ABDA-FBFAAC0B01E5>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(     "LocalDataTask <0D654665-D88F-4C81-ABDA-FBFAAC0B01E5>.<1>" ), NSLocalizedDescription=A server with the specified hostname could not be found., NSErrorFailingURLStringKey=https://weather-data.apple.com/v2/token, NSErrorFailingURLKey=https://weather-data.apple.com/v2/token, _kCFStreamErrorDomainKey=10}
Posted
by tarasis.
Last updated
.
Post marked as Apple Recommended
231 Views
When I fetch weather for my location and print the raw Weather response to the console, airQualityAvailability is set to available in availability. And alongside currentWeather, dailyForecast, hourlyForecast, and minuteForecast, there is also an airQuality object that contains a lot of information. I cannot figure out how to access this data through dot notation on the Weather response, and I cannot find any mention of air quality data in the documentation. How can I access this AQI information? Or is it planned but not yet officially accessible? Best, Michael
Posted
by medlund.
Last updated
.
Post not yet marked as solved
0 Replies
72 Views
I guess this is more of a public question for Apple: can/will tide data be packaged into WeatherKit? (FB10383248)
Posted
by wingover.
Last updated
.
Post marked as solved
1 Replies
180 Views
I'm trying out weather kit and I'm using swiftUI I have a view that accepts a CurrentWeather type value in initailizer I cannot find a way to initialize a CurrentWeather How can I preview It? This won't work: // forecaster and forecast is defined by me struct WeatherView_Previews: PreviewProvider {     static var previews: some View { // <- static WeatherView(weather: await forecaster.forcast(latitude: 0, longtitude: 0)) // <- concurrency     } }
Posted Last updated
.
Post not yet marked as solved
13 Replies
1.4k Views
Hi there! Please could you publish some of the specifics for authentication for the new WeatherKit REST API? I am attempting to use something cobbled together from MapKit, and unfortunately WeatherKit returns a 500 error in response. Broken code sample below. If you find a working solution or can identify an error, please comment with the solution. Thank you! require 'http' require 'jwt' require 'openssl' require 'logger' p8 = OpenSSL::PKey::EC.new(File.read("/PATH/TO/DOWNLOADED/P8/FILE")) token = JWT.encode({ iss: 'KEY_NAME_FROM_CIP', iat: Time.now.to_i, exp: Time.now.to_i + 3600, aud: 'weatherkit', }, p8, 'ES256', { kid: 'KEY_ID_FROM_CIP', typ: 'JWT' }) res = HTTP.use(logging: { logger: Logger.new(STDOUT) }).headers( "Authorization" => "Bearer #{token}" ).get "https://weatherkit.apple.com/api/v1/weather/en/LONG/LAT?dataSets=currentWeather&timezone=Europe/London" puts "code: #{res.code}" puts res.body
Posted
by rubynerd.
Last updated
.
Post not yet marked as solved
4 Replies
228 Views
Hi, I am getting and invalidJWTResponse when using WeatherKit Swift API, I have setup everything correctly including enabling WeatherKit in both Capabilities and App Services, Added WeatherKit" to Xcode Capabilities, and waited for more than one day! But still it's not working! invalidJWTResponse(Optional(<NSHTTPURLResponse: 0x6000008d8300> { URL: https://weather-data.apple.com/v2/token } { Status Code: 401, Headers {     Connection =     (         close     );     "Content-Length" =     (         0     );     Date =     (         "Thu, 09 Jun 2022 18:24:24 GMT"     );     Server =     (         "AppleHttpServer/5712591c84160e0cbbf19c8f434c32ab02f2a7f4"     );     "Strict-Transport-Security" =     (         "max-age=31536000"     );     "X-Apple-Origin" =     (         "01ca7adc-14e8-31f5-9654-4375b40868e2"     );     "X-B3-TraceId" =     (         795fbfea426330d9     );     "X-Cache" =     (         "TCP_MISS from a88-221-161-85.deploy.akamaitechnologies.com (AkamaiGHost/10.8.2-41841244) (-)"     );     "X-REQUEST-ID" =     (         "3e6d21c8-ffa0-4c56-aa91-8466619a4993"     ); } }))
Posted
by FarouKz.
Last updated
.
Post not yet marked as solved
1 Replies
266 Views
Hi all, I am trying to use the WeatherKit REST API but when I try to register an app, I don't see WeatherKit as an available services that I can select under the App Services Tab. How do I get access to the WeatherKit service? Thanks,
Posted
by cxcxcxcx.
Last updated
.
Post marked as solved
1 Replies
189 Views
Hello Everyone, In the example code, I'm trying to convert from Fahrenheit to Celsius, but I'm not succeeding. Output is always in Fahrenheit. My code is this:   func formattedTemperature(_ temp: Measurement<UnitTemperature>) -> String {         let tempC = temp.converted(to: .celsius)         return tempC.formatted(.measurement(width: .abbreviated, usage: .weather))     } In the simulator I also went into the settings and switched in General->Language/Region from F to C. But this also had not effect. Would anyone have an idea how to correct this? Thanks and best regards, Patrick
Posted
by PatDelft.
Last updated
.
Post not yet marked as solved
1 Replies
182 Views
If you use the iOS16 Swift WeatherKit API you can get the weather data attribution logo doing something like: // Skipping full syntax for example let attribution = WeatherService.shared.attribution // A URL to an image you can show along with the weather data attribution.combinedMarkLightURL What about if you are not using the iOS16 WeatherKit wrappers e.g. you are using the REST API on your own server to return data. The API docs show a providerLogo/providerName parameter in the metadata returned from the service, but they don't seem to be populated right now. Is it ok just to use a unicode Apple logo to make a string instead like:  Weather Also in the API there is a metadata object returned in each dataset e.g. current, daily, hourly which each has an attributionURL field, will all those values always be the same or we might have to display multiple URLs for data sources, the Swift example seems to just have one attribution object.
Posted
by markdaws.
Last updated
.
Post not yet marked as solved
0 Replies
146 Views
The documentation lists the number of calls per month you can make for the different pricing tiers here: https://developer.apple.com/weatherkit/get-started/ but are there going to be any per second/minute/hour rate limits on calls to the API like with other weather service APIs. For example maybe you get 1,000,000 calls per month but there is some limit like 5 calls per second or 10,000 calls per hour imposed by the APIs? Also what happens if you go over your allowed call limit for the month, will the API just return an error like HTTP 402 or you will get a warning for a period of time? Would you be able to buy extra calls for the month without having to upgrade to a new tier, assuming maybe you are experiencing a temporary increase in traffic.
Posted
by markdaws.
Last updated
.
Post not yet marked as solved
1 Replies
243 Views
Hi - I don't see anything in the documentation about which regions of the world the API will support e.g. US, Europe. I see there is an /api/v1/availability you can call but is there some rough guidelines around what areas are supported and which aren't. Thanks Mark.
Posted
by markdaws.
Last updated
.
Post not yet marked as solved
0 Replies
239 Views
To anyone it may help, I've put together an OpenAPI spec of the WeatherKit REST API, which you may find useful for client generation using one of the OpenAPI generators. https://github.com/vanshg/WeatherKit-OpenAPI
Posted
by vanshg.
Last updated
.