currentConditions エンドポイントは、特定の場所の現在の気象状況に関する情報を提供します。API は次の値を返します。
- 現在の天気の説明と対応するアイコン
- 現在の気温
- 体感温度
- 露点温度
- 暑さ指数
- 風冷指数
- 相対湿度
- UV 指数
- 降水確率、降水量の割合、降水の種類
- 雷雨の確率
- 海面気圧
- 風の向き、風速、突風
- 視程と雲量
- 過去 24 時間の気温の変化、最高気温と最低気温、降水量などの履歴データ
API Explorer を使用すると、ライブ リクエストを行って、API と API オプションを理解できます。
現在の状況のリクエストについて
現在の状況をリクエストするには、次の URL に HTTP GET リクエストを送信します。
https://weather.googleapis.com/v1/currentConditions:lookup?key=YOUR_API_KEY&location.latitude=LATITUDE&location.longitude=LONGITUDE
リクエスト URL のパラメータに、位置情報の緯度と経度の座標を含めます。
現在の状況のリクエストの例
次の例は、カリフォルニア州マウンテンビューの現在の状況に関する情報をリクエストしています。
curl -X GET "https://weather.googleapis.com/v1/currentConditions:lookup?key=YOUR_API_KEY&location.latitude=37.4220& location.longitude=-122.0841"
レスポンスの形式は次のとおりです。
{ "currentTime": "2025-01-28T22:04:12.025273178Z", "timeZone": { "id": "America/Los_Angeles" }, "isDaytime": true, "weatherCondition": { "iconBaseUri": "https://maps.gstatic.com/weather/v1/sunny", "description": { "text": "Sunny", "languageCode": "en" }, "type": "CLEAR" }, "temperature": { "degrees": 13.7, "unit": "CELSIUS" }, "feelsLikeTemperature": { "degrees": 13.1, "unit": "CELSIUS" }, "dewPoint": { "degrees": 1.1, "unit": "CELSIUS" }, "heatIndex": { "degrees": 13.7, "unit": "CELSIUS" }, "windChill": { "degrees": 13.1, "unit": "CELSIUS" }, "relativeHumidity": 42, "uvIndex": 1, "precipitation": { "probability": { "percent": 0, "type": "RAIN" }, "qpf": { "quantity": 0, "unit": "MILLIMETERS" } }, "thunderstormProbability": 0, "airPressure": { "meanSeaLevelMillibars": 1019.16 }, "wind": { "direction": { "degrees": 335, "cardinal": "NORTH_NORTHWEST" }, "speed": { "value": 8, "unit": "KILOMETERS_PER_HOUR" }, "gust": { "value": 18, "unit": "KILOMETERS_PER_HOUR" } }, "visibility": { "distance": 16, "unit": "KILOMETERS" }, "cloudCover": 0, "currentConditionsHistory": { "temperatureChange": { "degrees": -0.6, "unit": "CELSIUS" }, "maxTemperature": { "degrees": 14.3, "unit": "CELSIUS" }, "minTemperature": { "degrees": 3.7, "unit": "CELSIUS" }, "qpf": { "quantity": 0, "unit": "MILLIMETERS" } } }
単位系を指定する
デフォルトでは、Weather API はメートル法の単位でデータを返します。ヤード・ポンド法を使用して天気データをリクエストするには、リクエストで unitsSystem
パラメータを指定します。
次の例では、カリフォルニア州マウンテンビューの天気データをヤード・ポンド法でリクエストしています。
curl -X GET "https://weather.googleapis.com/v1/currentConditions:lookup?key=YOUR_API_KEY&location.latitude=37.4220& location.longitude=-122.0841&unitsSystem=IMPERIAL"
レスポンスの形式は次のとおりです。
{ "currentTime": "2025-01-28T22:13:56.723468335Z", "timeZone": { "id": "America/Los_Angeles" }, "isDaytime": true, "weatherCondition": { "iconBaseUri": "https://maps.gstatic.com/weather/v1/sunny", "description": { "text": "Sunny", "languageCode": "en" }, "type": "CLEAR" }, "temperature": { "degrees": 56.6, "unit": "FAHRENHEIT" }, "feelsLikeTemperature": { "degrees": 55.7, "unit": "FAHRENHEIT" }, "dewPoint": { "degrees": 33.9, "unit": "FAHRENHEIT" }, "heatIndex": { "degrees": 56.6, "unit": "FAHRENHEIT" }, "windChill": { "degrees": 55.7, "unit": "FAHRENHEIT" }, "relativeHumidity": 42, "uvIndex": 1, "precipitation": { "probability": { "percent": 0, "type": "RAIN" }, "qpf": { "quantity": 0, "unit": "INCHES" } }, "thunderstormProbability": 0, "airPressure": { "meanSeaLevelMillibars": 1019.12 }, "wind": { "direction": { "degrees": 335, "cardinal": "NORTH_NORTHWEST" }, "speed": { "value": 5, "unit": "MILES_PER_HOUR" }, "gust": { "value": 11, "unit": "MILES_PER_HOUR" } }, "visibility": { "distance": 10, "unit": "MILES" }, "cloudCover": 0, "currentConditionsHistory": { "temperatureChange": { "degrees": -1.2, "unit": "FAHRENHEIT" }, "maxTemperature": { "degrees": 57.8, "unit": "FAHRENHEIT" }, "minTemperature": { "degrees": 38.6, "unit": "FAHRENHEIT" }, "qpf": { "quantity": 0, "unit": "INCHES" } } }
試してみよう:
API Explorer を使用すると、サンプル リクエストを作成して、API と API オプションを理解できます。
ページの右側にある API アイコン api を選択します。
必要に応じてリクエスト パラメータを編集します。
[Execute] ボタンを選択します。ダイアログで、リクエストに使用するアカウントを選択します。
API Explorer パネルで、全画面アイコン fullscreen を選択して API Explorer ウィンドウを拡大します。