Weather API 總覽

Weather API 可讓您要求全球各地的即時超地方天氣資料,用於即時天氣資訊主頁、天氣更新應用程式、路線天氣疊加層,以及根據天氣提供建議的健康或活動追蹤器。天氣資訊包括目前溫度、降雨量、相對濕度、風速、紫外線指數等。

針對指定經緯度的位置,API 會為下表中的資料提供端點 (https://weather.googleapis.com/v1/...)。

REST 端點一覽

API 端點 網址 說明 記錄的參數
目前氣象 https://weather.googleapis.com/v1/currentConditions:lookup 即時天氣狀況 location.latitude、location.longitude
每小時天氣預報 https://weather.googleapis.com/v1/forecast/hours:lookup 最多 240 小時的天氣預報 location.latitude、location.longitude
每日預報 https://weather.googleapis.com/v1/forecast/days:lookup 最多 10 天的天氣預報 location.latitude、location.longitude
每小時記錄 https://weather.googleapis.com/v1/history/hours:lookup 最多可快取過去 24 小時的條件 location.latitude、location.longitude
惡劣天氣警示 https://weather.googleapis.com/v1/publicAlerts:lookup 惡劣天氣警示 key、location.latitude、location.longitude

常見用途

Weather API 的功能

Weather API 資料包含:

如何使用 Weather API

1 做好準備 請先設定 Google Cloud 專案,然後按照後續操作說明完成設定。
2 取得目前天氣資訊 請參閱「取得目前狀況」。
3 取得每小時天氣預報 請參閱「取得每小時天氣預報」。
4 取得每日天氣預報 請參閱「取得每日預測」。
5 取得每小時記錄 請參閱「取得每小時記錄」。
6 接收天氣警示 請參閱「接收天氣快訊」。

如需空氣品質指數 (AQI) 和懸浮微粒汙染物 (PM2.5、PM10),請使用 Air Quality API (https://airquality.googleapis.com/v1/currentConditions:lookup)。Weather API 不會傳回這些值。

其他相關環境 API 包括:

  • 花粉計數:Pollen API (https://pollen.googleapis.com/v1/forecast:lookup)
  • 日射量和屋頂潛力:Solar API (https://solar.googleapis.com/v1/buildingInsights:findClosest)

後續步驟