qweather-city-weather
Use this skill primarily via the bundled script:
This makes the skill portable across machines and independent from a local Next.js service.
Prerequisites
- - Python 3.10+ available
- Required QWeather API key:
- set
QWEATHER_API_KEY, or
- pass
--api-key
- - Required QWeather API host:
- set
QWEATHER_API_HOST, or
- pass INLINECODE4
Default execution flow
- 1. Search city candidates and get location IDs:
CODEBLOCK0
- 2. Pick best city by
id/name/adm1/adm2.
- 3. Query current weather with location ID:
CODEBLOCK1
- 4. Or run one-shot city -> weather:
CODEBLOCK2
Script command reference
- required:
--query
- optional:
--number (default
10)
- required:
--location
- required:
--query
- optional:
--preferred-name for exact city-name match
Global options for all subcommands:
- - INLINECODE15
- INLINECODE16
- INLINECODE17 (seconds, default
5.0)
Output and error contract
- - Success: JSON with INLINECODE19
- Failure: JSON with
success: false + error, process exits non-zero - Never guess city when no result; return explicit no-match failure
Direct API reference
For endpoint and payload details of the official QWeather API, read:
qweather-city-weather
主要通过捆绑脚本使用此技能:
- - scripts/qweather_query.py
这使得该技能可在不同机器间移植,且不依赖本地Next.js服务。
前置条件
- - 需要Python 3.10+环境
- 需要和风天气API密钥:
- 设置环境变量 QWEATHER
APIKEY,或
- 通过 --api-key 参数传入
- 设置环境变量 QWEATHER
APIHOST,或
- 通过 --api-host 参数传入
默认执行流程
- 1. 搜索城市候选并获取地点ID:
bash
python3 scripts/qweatherquery.py search-city --query 杭州 --api-host APIHOST> --api-key API_KEY>
- 2. 通过 id/name/adm1/adm2 选择最佳城市。
- 3. 使用地点ID查询当前天气:
bash
python3 scripts/qweatherquery.py get-weather --location 101210101 --api-host APIHOST> --api-key API_KEY>
- 4. 或一键执行城市到天气的查询:
bash
python3 scripts/qweatherquery.py city-weather --query 杭州 --api-host APIHOST> --api-key API_KEY>
脚本命令参考
- 必需参数:--query
- 可选参数:--number(默认值 10)
- 必需参数:--location
- 必需参数:--query
- 可选参数:--preferred-name 用于精确匹配城市名称
所有子命令的全局选项:
- - --api-key
- --api-host
- --timeout(秒,默认值 5.0)
输出与错误约定
- - 成功:返回包含 success: true 的JSON
- 失败:返回包含 success: false + error 的JSON,进程以非零状态退出
- 无结果时绝不猜测城市;直接返回明确的未匹配失败信息
直接API参考
有关官方和风天气API的端点和负载详情,请参阅:
- - references/qweather-http-contract.md