נקודת הקצה forecast.hours מחזירה עד 240 שעות של נתוני תחזית למיקום ספציפי, החל מהשעה הנוכחית. ה-API מחזיר את הערכים הבאים:
- תיאור של תנאי מזג האוויר הנוכחיים עם סמל תואם
- הטמפרטורה הנוכחית
- הטמפרטורה המורגשת
- נקודת הטל
- מדד החום
- צינת רוח
- טמפרטורת גולה לחה
- לחות יחסית
- מדד קרינת UV
- הסבירות, האחוז וסוג המשקעים
- סבירות לסופות רעמים
- לחץ בגובה פני הים
- רוח: כיוון, מהירות ומשבי רוח
- סטטוס החשיפה וכיסוי העננים
APIs Explorer מאפשר לכם לשלוח בקשות בזמן אמת כדי להכיר את ה-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.
בדוגמה הבאה נשלחת בקשה למידע על תחזית שעתית לשלוש השעות הבאות ב-Mountain View, קליפורניה:
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. כדי לראות את הדף הבא של המידע, מעבירים את הערך nextPageToken לפרמטר pageToken בבקשה.
בדוגמה הבאה נשלחת בקשה לנתוני תחזית מזג אוויר ל-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"
התשובה, שכוללת את הנתונים של שלוש השעות הראשונות, היא בפורמט הבא:
{ "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" }
כדי לגשת לדף הנתונים הבא, מעבירים את הערך nextPageToken לפרמטר pageToken בבקשה:
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=" }
רוצה לנסות?
APIs Explorer מאפשר לכם לשלוח בקשות לדוגמה כדי להכיר את ה-API ואת האפשרויות שלו.
בצד שמאל של הדף, לוחצים על סמל ה-API api.
אפשר לערוך את פרמטרים הבקשה.
לוחצים על הכפתור Execute (הפעלה). בתיבת הדו-שיח, בוחרים את החשבון שבו רוצים להשתמש כדי לשלוח את הבקשה.
בחלונית APIs Explorer, לוחצים על סמל המסך המלא מסך מלא כדי להרחיב את החלון של APIs Explorer.