I want to use weather alert for my weather app but I don't understand how URL should look like. Can anyone help me?
Weather Alert (empty JSON)
To get weather alerts from WeatherKit you need to include weatherAlerts
in the dataSets
query parameter and the correct ISO Alpha-2 country code in the country
query parameter:
https://weatherkit.apple.com/api/v1/weather/{language}/{latitude}/{longitude}?dataSets=weatherAlerts&country={countryCode}&timezone={timezone}
For example, to get weather alerts for Apple Park in Cupertino, you would use:
https://weatherkit.apple.com/api/v1/weather/en-US/37.3346/-122.0090?dataSets=weatherAlerts&country=US&timezone=America/Los_Angeles
Note that you can request weather alerts along with other weather information for the specified location in a single WeatherKit request. Just include the other data set names along with weatherAlerts
in the dataSets
parameter as a comma delimited list. For example, to get the current weather conditions as well as weather alerts at Apple Park, you would use:
https://weatherkit.apple.com/api/v1/weather/en-US/37.3346/-122.0090?dataSets=currentWeather,weatherAlerts&country=US&timezone=America/Los_Angeles
Hello. The documentation at https://developer.apple.com/documentation/weatherkitrestapi/get_api_v1_weather_language_latitude_longitude could use updating.
- "
countryCode
" is listed as the parameter name but seems it should be "country
" - The country code itself apparently must be uppercase; clarifying this in the documentation would be helpful
Trying to develop without these changes, one is led to believe that the data is not available, or that they are forming the request incorrectly (which is technically true, but there is no indication of an error or warning, so it becomes a head-scratcher when nothing is coming back as expected).
Thank you, and hope this helps some folk out!