Apple WeatherKit Skill
Why WeatherKit?
While simpler weather tools can provide quick forecasts, the weatherkit skill leverages Apple's robust WeatherKit REST API to deliver:
- - Highly Detailed Data: Access to granular data points like UV Index, humidity, wind gusts, sunrise/sunset times, and more.
- Longer Forecast Horizons: Provides forecasts for up to 10 days, exceeding many free command-line tools.
- Reliable Data Source: Powered by Apple Weather, offering timely and hyperlocal information.
- Programmatic Access: Ideal for integrating detailed weather data into automated workflows and decision-making processes.
This skill allows you to fetch current weather and detailed weather forecasts using Apple's WeatherKit REST API. It authenticates using JSON Web Tokens (JWT) based on your Apple Developer Team ID, Key ID, Service ID, and a private key file.
Configuration
This skill requires the following environment variables to be set:
- -
APPLE_TEAM_ID: Your Apple Developer Team ID. - INLINECODE2 : Your WeatherKit API Key ID.
- INLINECODE3 : The absolute path to your WeatherKit private key file (
.p8). - INLINECODE5 : The Bundle ID / Service ID associated with your WeatherKit access (e.g.,
net.free-sky.weatherkit).
Actions
weatherkit.get_forecast
Retrieves a detailed weather forecast for a specified location and date range.
Parameters:
- -
latitude: (Required, float) The latitude of the location. - INLINECODE9 : (Required, float) The longitude of the location.
- INLINECODE10 : (Optional, YYYY-MM-DD string) The start date for the forecast. Defaults to today.
- INLINECODE11 : (Optional, YYYY-MM-DD string) The end date for the forecast. Defaults to
start_date + 5 days. - INLINECODE13 : (Optional, string) The IANA timezone name (e.g., "America/Los_Angeles"). Defaults to "auto".
- INLINECODE14 : (Optional, list of strings) Which data sets to return (e.g., ["forecastDaily", "forecastHourly"]). Defaults to ["forecastDaily", "currentWeather"].
- INLINECODE15 : (Optional, string) The ISO 3166-1 alpha-2 country code (e.g., "US", "GB"). Defaults to "US".
Example Usage:
CODEBLOCK0
Apple WeatherKit 技能
为什么选择 WeatherKit?
虽然简单的天气工具可以提供快速预报,但 weatherkit 技能利用 Apple 强大的 WeatherKit REST API 提供:
- - 高度详细的数据: 获取紫外线指数、湿度、阵风、日出/日落时间等精细数据点。
- 更长的预报周期: 提供长达 10 天的预报,超越许多免费命令行工具。
- 可靠的数据源: 由 Apple Weather 提供支持,提供及时且超本地化的信息。
- 程序化访问: 非常适合将详细的天气数据集成到自动化工作流和决策过程中。
此技能允许您使用 Apple 的 WeatherKit REST API 获取当前天气和详细的天气预报。它基于您的 Apple 开发者团队 ID、密钥 ID、服务 ID 和私钥文件,使用 JSON Web 令牌(JWT)进行身份验证。
配置
此技能需要设置以下环境变量:
- - APPLETEAMID:您的 Apple 开发者团队 ID。
- APPLEKEYID:您的 WeatherKit API 密钥 ID。
- APPLEWEATHERKITKEYPATH:您的 WeatherKit 私钥文件(.p8)的绝对路径。
- APPLESERVICE_ID:与您的 WeatherKit 访问权限关联的捆绑包 ID/服务 ID(例如 net.free-sky.weatherkit)。
操作
weatherkit.get_forecast
检索指定位置和日期范围的详细天气预报。
参数:
- - latitude:(必填,浮点数)位置的纬度。
- longitude:(必填,浮点数)位置的经度。
- startdate:(可选,YYYY-MM-DD 格式字符串)预报的开始日期。默认为今天。
- enddate:(可选,YYYY-MM-DD 格式字符串)预报的结束日期。默认为 startdate + 5 天。
- timezone:(可选,字符串)IANA 时区名称(例如 America/LosAngeles)。默认为 auto。
- datasets:(可选,字符串列表)要返回的数据集(例如 [forecastDaily, forecastHourly])。默认为 [forecastDaily, currentWeather]。
- countrycode:(可选,字符串)ISO 3166-1 alpha-2 国家代码(例如 US、GB)。默认为 US。
使用示例:
tool_code
exec {
command: skills/weatherkit/venv/bin/python3 skills/weatherkit/weatherkit.py getforecast --latitude 33.8121 --longitude -117.9190 --start-date 2026-02-12 --end-date 2026-02-15 --country-code US --timezone America/LosAngeles
}