A WeatherKit API client in Go. WeatherKit is powered by the Apple Weather service.
Notice: The WeatherKit REST API is currently in beta and is subject to change. This client was created from documentation available here: https://developer.apple.com/documentation/weatherkitrestapi
go-weatherkit is an open source project not affiliated with Apple Inc.
This assumes you already have a working Go environment, if not please see this page first.
go get github.com/shawntoffel/go-weatherkit
import "github.com/shawntoffel/go-weatherkit"
// See Authentication documentation below.
privateKeyBytes, _ := os.ReadFile("/path/to/AuthKey_ABCDE12345.p8")
client := weatherkit.NewCredentialedClient(weatherkit.Credentials{
KeyID: "key ID",
TeamID: "team ID",
ServiceID: "service ID",
PrivateKey: privateKeyBytes,
})
Locating your identifiers:
- Key ID (kid): An identifier associated with your private key. It can be found on the Certificates, Identifiers & Profiles page under Keys. Click on the appropriate key to view the ID.
- Team ID (tid): Found on the account page under Membership details.
- Service ID (sid): Found on the Certificates, Identifiers & Profiles page under Identifiers. Make sure "Services IDs" is selected from the dropdown.
request := weatherkit.WeatherRequest{
Latitude: 38.960,
Longitude: -104.506,
Language: "en",
DataSets: weatherkit.DataSets{
weatherkit.DataSetCurrentWeather,
},
}
ctx := context.Background()
response, err := client.Weather(ctx, request)
See Apple's documentation for Apple Weather and third-party attribution requirements.
Please use the GitHub Discussions tab for questions regarding this client library. The Apple Developer forums are available for questions regarding the underlying API: https://developer.apple.com/forums/tags/weatherkit