香港天文台 (HKO) 開放數據 API 查詢技能。用於獲取香港天氣數據,包括:(1) 全港即時天氣,(2) 分區天氣 (港島/九龍/新界/離島),(3) 天氣預報 (每小時/九天),(4) 天氣警告 (暴雨/颱風/高溫等)。當用戶查詢香港天氣、請求天氣預報、或需要了解生效中天氣警告時使用此技能。
本技能提供調用香港天文台 (HKO) 開放數據 API 的完整指導,無需 API Key,完全免費。
https://data.weather.gov.hk/weatherAPI/opendata/weather.phplang=en (英文) 或 lang=tc (繁體中文)references/api-docs.md| 需求 | dataType | 說明 | 更新頻率 |
|---|---|---|---|
| 全港即時天氣 | rhrread | 當前天氣報告 (含分區數據) | 每小時 |
| 分區天氣 | rhrread | 指定地區氣溫 (例如:沙田、銅鑼灣) | 每小時 |
| 本地天氣預報 |
flw| 本地天氣預報 |
| 每小時 |
| 九天預報 | fnd | 九天天氣預報 | 每日 2 次 |
| 天氣警告摘要 | warnsum | 天氣警告摘要 | 即時 |
| 天氣警告詳情 | warningInfo | 詳細天氣警告資訊 | 即時 |
| 特別天氣提示 | swt | 特別天氣提示 | 即時 |
⚠️ 注意: 分區天氣數據包含在 rhrread 回應中,為臨時數據,僅經有限度驗證。
詢問或確認用戶需要:
優先使用腳本,而非直接調用 API。腳本已處理 API 請求、JSON parsing 同錯誤處理。
標準命令:
# 全港即時天氣 (含分區氣溫)
python3 {baseDir}/scripts/fetch_weather.py --type current
# 指定地區天氣 (例如:沙田)
python3 {baseDir}/scripts/fetch_weather.py --type regional --location 沙田
# 九天預報
python3 {baseDir}/scripts/fetch_weather.py --type forecast --days 9
# 3 天預報
python3 {baseDir}/scripts/fetch_weather.py --type forecast --days 3
# 本地天氣預報 (概況)
python3 {baseDir}/scripts/fetch_weather.py --type hourly
# 檢查天氣警告
python3 {baseDir}/scripts/check_warnings.py
# 僅檢查關鍵警告 (暴雨/颱風等)
python3 {baseDir}/scripts/check_warnings.py --critical
以清晰格式向用戶展示天氣資訊,包括:
註: 除非腳本 unavailable,否則避免直接用 web_fetch 調用 API。
本技能提供以下腳本:
| 腳本 | 用途 |
|---|---|
scripts/fetch_weather.py | 獲取並解析天氣數據 |
scripts/check_warnings.py | 檢查生效中天氣警告 |
使用示例:
# 全港即時天氣 (含分區氣溫)
python3 {baseDir}/scripts/fetch_weather.py --type current
# 指定地區天氣 (例如:沙田)
python3 {baseDir}/scripts/fetch_weather.py --type regional --location 沙田
# 指定地區天氣 (例如:香港天文台)
python3 {baseDir}/scripts/fetch_weather.py --type regional --location 香港天文台
# 顯示所有分區氣溫
python3 {baseDir}/scripts/fetch_weather.py --type regional
# 九天預報
python3 {baseDir}/scripts/fetch_weather.py --type forecast --days 9
# 3 天預報
python3 {baseDir}/scripts/fetch_weather.py --type forecast --days 3
# 本地天氣預報 (概況)
python3 {baseDir}/scripts/fetch_weather.py --type hourly
# 降雨資訊 (過去一小時分區降雨量)
python3 {baseDir}/scripts/fetch_weather.py --type rainfall
# 降雨預報 (未來幾日會唔會落雨)
python3 {baseDir}/scripts/fetch_weather.py --type rainfall-forecast --days 9
# 降雨預報 (未來 3 日)
python3 {baseDir}/scripts/fetch_weather.py --type rainfall-forecast --days 3
# 檢查天氣警告
python3 {baseDir}/scripts/check_warnings.py
# 僅檢查關鍵警告 (暴雨/颱風等)
python3 {baseDir}/scripts/check_warnings.py --critical
# 輸出原始 JSON
python3 {baseDir}/scripts/fetch_weather.py --type current --json
詳細腳本文檔見 references/scripts.md。
references/api-docs.mdreferences/scripts.mdreferences/regions.mdreferences/warnings.md使用條款:
錯誤處理:
數據限制:
當用戶提出以下類型的請求時,應使用本技能: