forecast.hours 엔드포인트는 현재 시간부터 특정 위치에 대한 최대 240시간의 예측 정보를 반환합니다. API는 다음을 반환합니다.
- 현재 날씨에 관한 설명과 해당 아이콘
- 현재 기온
- 체감 온도
- 이슬점
- 열 지수
- 체감 온도
- 습구 온도
- 상대 습도
- 자외선 지수
- 강수 확률, 비율, 유형
- 뇌우 확률
- 해수면 기압
- 바람 방향, 속도, 돌풍
- 가시성 및 구름 덮음
API 탐색기를 사용하면 API 및 API 옵션을 익히기 위해 실시간으로 요청할 수 있습니다.
시간별 예측 요청 정보
시간별 예보 정보를 요청하려면 다음 주소로 HTTP GET 요청을 전송합니다.
https://weather.googleapis.com/v1/forecast/hours:lookup?key=YOUR_API_KEY&location.latitude=LATITUDE&location.longitude=LONGITUDE
요청 URL 매개변수에 위치의 위도 및 경도 좌표를 포함합니다.
시간별 예측 요청 예
기본적으로 forecast.hours 엔드포인트는 현재 시간부터 시작하여 240시간 동안의 데이터를 반환합니다. hours
매개변수를 사용하여 요청 범위를 특정 기간으로 제한할 수 있습니다.
다음 예에서는 캘리포니아 마운틴뷰의 다음 3시간 동안의 시간별 예보 정보를 요청합니다.
curl -X GET "https://weather.googleapis.com/v1/forecast/hours:lookup?key=YOUR_API_KEY&location.latitude=37.4220 &location.longitude=-122.0841 &hours=3"
응답에서 interval
객체는 각 시간의 정보를 나타냅니다.
{ "forecastHours": [ { "interval": { "startTime": "2025-02-05T23:00:00Z", "endTime": "2025-02-06T00:00:00Z" }, "displayDateTime": { "year": 2025, "month": 2, "day": 5, "hours": 15, "utcOffset": "-28800s" }, "isDaytime": true, "weatherCondition": { "iconBaseUri": "https://maps.gstatic.com/weather/v1/sunny", "description": { "text": "Sunny", "languageCode": "en" }, "type": "CLEAR" }, "temperature": { "degrees": 12.7, "unit": "CELSIUS" }, "feelsLikeTemperature": { "degrees": 12, "unit": "CELSIUS" }, "dewPoint": { "degrees": 2.7, "unit": "CELSIUS" }, "heatIndex": { "degrees": 12.7, "unit": "CELSIUS" }, "windChill": { "degrees": 12, "unit": "CELSIUS" }, "wetBulbTemperature": { "degrees": 7.7, "unit": "CELSIUS" }, "relativeHumidity": 51, "uvIndex": 1, "precipitation": { "probability": { "percent": 0, "type": "RAIN" }, "qpf": { "quantity": 0, "unit": "MILLIMETERS" } }, "thunderstormProbability": 0, "airPressure": { "meanSeaLevelMillibars": 1019.13 }, "wind": { "direction": { "degrees": 335, "cardinal": "NORTH_NORTHWEST" }, "speed": { "value": 10, "unit": "KILOMETERS_PER_HOUR" }, "gust": { "value": 19, "unit": "KILOMETERS_PER_HOUR" } }, "visibility": { "distance": 16, "unit": "KILOMETERS" }, "cloudCover": 0, "iceThickness": { "thickness": 0, "unit": "MILLIMETERS" } }, { "interval": { "startTime": "2025-02-06T00:00:00Z", "endTime": "2025-02-06T01:00:00Z" }, "displayDateTime": { "year": 2025, "month": 2, "day": 5, "hours": 16, "utcOffset": "-28800s" }, "isDaytime": true, "weatherCondition": { "iconBaseUri": "https://maps.gstatic.com/weather/v1/sunny", "description": { "text": "Sunny", "languageCode": "en" }, "type": "CLEAR" }, "temperature": { "degrees": 12.5, "unit": "CELSIUS" }, /.../ }, { "interval": { "startTime": "2025-02-06T01:00:00Z", "endTime": "2025-02-06T02:00:00Z" }, "displayDateTime": { "year": 2025, "month": 2, "day": 5, "hours": 17, "utcOffset": "-28800s" }, "isDaytime": true, "weatherCondition": { "iconBaseUri": "https://maps.gstatic.com/weather/v1/sunny", "description": { "text": "Sunny", "languageCode": "en" }, "type": "CLEAR" }, "temperature": { "degrees": 11.4, "unit": "CELSIUS" }, /.../ } ], "timeZone": { "id": "America/Los_Angeles" } }
페이지당 반환할 시간 수를 지정합니다.
pageSize
URL 매개변수를 사용하여 페이지당 반환할 데이터의 시간 수를 지정할 수 있습니다. 기본값은 페이지당 24시간의 예측 정보입니다.
정보가 여러 페이지인 응답에는 nextPageToken
가 포함됩니다. 다음 페이지의 정보를 보려면 요청의 pageToken
매개변수에 nextPageToken
값을 전달합니다.
다음 예에서는 페이지당 3시간의 데이터로 캘리포니아 마운틴뷰의 일기예보 데이터 25시간을 요청합니다.
curl -X GET "https://weather.googleapis.com/v1/forecast/hours:lookup?key=YOUR_API_KEY&location.latitude=37.4220 &location.longitude=-122.0841 &hours=25&pageSize=3"
처음 3시간의 데이터가 포함된 응답은 다음과 같은 형식입니다.
{ "forecastHours": [ { "interval": { "startTime": "2025-02-06T23:00:00Z", "endTime": "2025-02-07T00:00:00Z" }, "displayDateTime": { "year": 2025, "month": 2, "day": 6, "hours": 15, "utcOffset": "-28800s" }, "isDaytime": true, "weatherCondition": { "iconBaseUri": "https://maps.gstatic.com/weather/v1/showers", "description": { "text": "Rain showers", "languageCode": "en" }, "type": "RAIN_SHOWERS" }, "temperature": { "degrees": 14.6, "unit": "CELSIUS" }, /.../ }, { "interval": { "startTime": "2025-02-07T00:00:00Z", "endTime": "2025-02-07T01:00:00Z" }, "displayDateTime": { "year": 2025, "month": 2, "day": 6, "hours": 16, "utcOffset": "-28800s" }, "isDaytime": true, "weatherCondition": { "iconBaseUri": "https://maps.gstatic.com/weather/v1/drizzle", "description": { "text": "Light rain", "languageCode": "en" }, "type": "LIGHT_RAIN" }, "temperature": { "degrees": 14.4, "unit": "CELSIUS" }, /.../ }, { "interval": { "startTime": "2025-02-07T01:00:00Z", "endTime": "2025-02-07T02:00:00Z" }, "displayDateTime": { "year": 2025, "month": 2, "day": 6, "hours": 17, "utcOffset": "-28800s" }, "isDaytime": true, "weatherCondition": { "iconBaseUri": "https://maps.gstatic.com/weather/v1/cloudy", "description": { "text": "Cloudy", "languageCode": "en" }, "type": "CLOUDY" }, "temperature": { "degrees": 14.4, "unit": "CELSIUS" }, /.../ } ], "timeZone": { "id": "America/Los_Angeles" }, "nextPageToken": "ChYKEgm8dJMYBLZCQBH-ZffkYYVewBAZEAMYAyIMCLKClb0GEJeO18kDKhNBbWVyaWNhL0xvc19BbmdlbGVz" }
데이터의 다음 페이지에 액세스하려면 요청의 pageToken
매개변수에 nextPageToken
값을 전달합니다.
curl -X GET "https://weather.googleapis.com/v1/forecast/hours:lookup?key=YOUR_API_KEY&location.latitude=37.4220 &location.longitude=-122.0841 &hours=25 &pageSize=3 &pageToken=ChYKEgm8dJMYBLZCQBH-ZffkYYVewBAZEAMYAyIMCLKClb0GEJeO18kDKhNBbWVyaWNhL0xvc19BbmdlbGVz"
응답 형식은 다음과 같습니다.
{ "forecastHours": [ { "interval": { "startTime": "2025-02-07T02:00:00Z", "endTime": "2025-02-07T03:00:00Z" }, "displayDateTime": { "year": 2025, "month": 2, "day": 6, "hours": 18, "utcOffset": "-28800s" }, "isDaytime": false, "weatherCondition": { "iconBaseUri": "https://maps.gstatic.com/weather/v1/cloudy", "description": { "text": "Cloudy", "languageCode": "en" }, "type": "CLOUDY" }, "temperature": { "degrees": 14.3, "unit": "CELSIUS" }, /.../ }, { "interval": { "startTime": "2025-02-07T03:00:00Z", "endTime": "2025-02-07T04:00:00Z" }, "displayDateTime": { "year": 2025, "month": 2, "day": 6, "hours": 19, "utcOffset": "-28800s" }, "isDaytime": false, "weatherCondition": { "iconBaseUri": "https://maps.gstatic.com/weather/v1/showers", "description": { "text": "Rain showers", "languageCode": "en" }, "type": "RAIN_SHOWERS" }, "temperature": { "degrees": 14.2, "unit": "CELSIUS" }, /.../ }, { "interval": { "startTime": "2025-02-07T04:00:00Z", "endTime": "2025-02-07T05:00:00Z" }, "displayDateTime": { "year": 2025, "month": 2, "day": 6, "hours": 20, "utcOffset": "-28800s" }, "isDaytime": false, "weatherCondition": { "iconBaseUri": "https://maps.gstatic.com/weather/v1/showers", "description": { "text": "Rain showers", "languageCode": "en" }, "type": "RAIN_SHOWERS" }, "temperature": { "degrees": 14.1, "unit": "CELSIUS" }, /.../ } ], "timeZone": { "id": "America/Los_Angeles" }, "nextPageToken": "ChYKEgm8dJMYBLZCQBH-ZffkYYVewBAZEAYYBiILCPeDlb0GEICs5TMqE0FtZXJpY2EvTG9zX0FuZ2VsZXM=" }
사용해 보기
API 탐색기를 사용하면 샘플 요청을 실행하여 API 및 API 옵션을 익힐 수 있습니다.
페이지 오른쪽에 있는 API 아이콘 api를 선택합니다.
원하는 경우 요청 매개변수를 수정합니다.
실행 버튼을 선택합니다. 대화상자에서 요청하는 데 사용할 계정을 선택합니다.
API 탐색기 패널에서 전체 화면 아이콘 fullscreen을 선택하여 API 탐색기 창을 펼칩니다.