הצגת התחזית היומית

נקודת הקצה forecast.days מחזירה עד 10 ימים של נתוני תחזית למיקום ספציפי, החל מהיום הנוכחי. ה-API מחזיר את הנתונים הבאים:

  • תיאור של תנאי מזג האוויר בשעות היום (7:00 עד 19:00) ובשעות הלילה (19:00 עד 7:00) עם סמלים תואמים
  • טמפרטורות מקסימום ומינימום יומיות
  • הטמפרטורות המקסימליות והמינימליות היומיות המורגשות
  • מדד החום
  • לחות יחסית
  • מדד UV
  • הסתברות, אחוז, כמות וסוג המשקעים
  • סבירות לסופות רעמים
  • לחץ בגובה פני הים
  • צינת רוח
  • כיוון, מהירות ומשבי רוח
  • עובי הקרח
  • חשיפה וכיסוי עננים
  • המועדים היומיים של זריחה, שקיעה, זריחת הירח ושקיעת הירח

‫APIs Explorer מאפשר לכם לשלוח בקשות בזמן אמת כדי להכיר את ה-API ואת האפשרויות שלו:

מידע על בקשות לתחזית יומית

כדי לבקש את התנאים הנוכחיים, שולחים בקשת HTTP GET אל:

https://weather.googleapis.com/v1/forecast/days:lookup?key=YOUR_API_KEY&location.latitude=LATITUDE&location.longitude=LONGITUDE

כוללים בבקשה את קואורדינטות קו האורך וקו הרוחב של המיקום בפרמטרים של כתובת ה-URL.

דוגמאות לבקשות לתחזית יומית

כברירת מחדל, נקודת הקצה forecast.days מחזירה נתונים של 10 ימים, החל מהשעה הנוכחית. אפשר להגדיר את היקף הבקשה למספר מסוים של ימים באמצעות הפרמטר days.

בדוגמה הבאה מוצגת בקשה למידע על תחזית יומית ליומיים הבאים במאונטיין ויו, קליפורניה:

curl -X GET "https://weather.googleapis.com/v1/forecast/days:lookup?key=YOUR_API_KEY&location.latitude=37.4220&location.longitude=-122.0841&days=2"

בתגובה, אובייקט interval מציין את המידע של כל יום:

{
  "forecastDays": [
    {
      "interval": {
        "startTime": "2025-02-10T15:00:00Z",
        "endTime": "2025-02-11T15:00:00Z"
      },
      "displayDate": {
        "year": 2025,
        "month": 2,
        "day": 10
      },
      "daytimeForecast": {
        "interval": {
          "startTime": "2025-02-10T15:00:00Z",
          "endTime": "2025-02-11T03:00:00Z"
        },
        "weatherCondition": {
          "iconBaseUri": "https://maps.gstatic.com/weather/v1/partly_cloudy",
          "description": {
            "text": "Partly sunny",
            "languageCode": "en"
          },
          "type": "PARTLY_CLOUDY"
        },
        "relativeHumidity": 54,
        "uvIndex": 3,
        "precipitation": {
          "probability": {
            "percent": 5,
            "type": "RAIN"
          },
          "qpf": {
            "quantity": 0,
            "unit": "MILLIMETERS"
          }
        },
        "thunderstormProbability": 0,
        "wind": {
          "direction": {
            "degrees": 280,
            "cardinal": "WEST"
          },
          "speed": {
            "value": 6,
            "unit": "KILOMETERS_PER_HOUR"
          },
          "gust": {
            "value": 14,
            "unit": "KILOMETERS_PER_HOUR"
          }
        },
        "cloudCover": 53
      },
      "nighttimeForecast": {
        "interval": {
          "startTime": "2025-02-11T03:00:00Z",
          "endTime": "2025-02-11T15:00:00Z"
        },
        "weatherCondition": {
          "iconBaseUri": "https://maps.gstatic.com/weather/v1/partly_clear",
          "description": {
            "text": "Partly cloudy",
            "languageCode": "en"
          },
          "type": "PARTLY_CLOUDY"
        },
        "relativeHumidity": 85,
        "uvIndex": 0,
        "precipitation": {
          "probability": {
            "percent": 10,
            "type": "RAIN_AND_SNOW"
          },
          "qpf": {
            "quantity": 0,
            "unit": "MILLIMETERS"
          }
        },
        "thunderstormProbability": 0,
        "wind": {
          "direction": {
            "degrees": 201,
            "cardinal": "SOUTH_SOUTHWEST"
          },
          "speed": {
            "value": 6,
            "unit": "KILOMETERS_PER_HOUR"
          },
          "gust": {
            "value": 14,
            "unit": "KILOMETERS_PER_HOUR"
          }
        },
        "cloudCover": 70
      },
      "maxTemperature": {
        "degrees": 13.3,
        "unit": "CELSIUS"
      },
      "minTemperature": {
        "degrees": 1.5,
        "unit": "CELSIUS"
      },
      "feelsLikeMaxTemperature": {
        "degrees": 13.3,
        "unit": "CELSIUS"
      },
      "feelsLikeMinTemperature": {
        "degrees": 1.5,
        "unit": "CELSIUS"
      },
      "sunEvents": {
        "sunriseTime": "2025-02-10T15:02:35.703929582Z",
        "sunsetTime": "2025-02-11T01:43:00.762932858Z"
      },
      "moonEvents": {
        "moonPhase": "WAXING_GIBBOUS",
        "moonriseTimes": [
          "2025-02-10T23:54:17.713157984Z"
        ],
        "moonsetTimes": [
          "2025-02-10T14:13:58.625181191Z"
        ]
      },
      "maxHeatIndex": {
        "degrees": 13.3,
        "unit": "CELSIUS"
      },
      "iceThickness": {
        "thickness": 0,
        "unit": "MILLIMETERS"
      }
    },
    {
      "interval": {
        "startTime": "2025-02-11T15:00:00Z",
        "endTime": "2025-02-12T15:00:00Z"
      },
      "displayDate": {
        "year": 2025,
        "month": 2,
        "day": 11
      },
      "daytimeForecast": {
        "interval": {
          "startTime": "2025-02-11T15:00:00Z",
          "endTime": "2025-02-12T03:00:00Z"
        },
        "weatherCondition": {
          "iconBaseUri": "https://maps.gstatic.com/weather/v1/scattered_showers",
          "description": {
            "text": "Scattered showers",
            "languageCode": "en"
          },
          "type": "SCATTERED_SHOWERS"
        },
      /.../
      }
    }
  ],
  "timeZone": {
    "id": "America/Los_Angeles"
  }
}

מציינים את מספר הימים להחזרה בכל דף

אפשר לציין את מספר הימים של הנתונים שיוחזרו בכל דף באמצעות הפרמטר pageSize של כתובת ה-URL. ערך ברירת המחדל הוא חמישה ימים של נתוני תחזית בכל דף.

תשובות עם כמה דפים של מידע כוללות את הסמל nextPageToken. כדי לראות את הדף הבא של המידע, צריך להעביר את הערך nextPageToken לפרמטר pageToken בבקשה.

בדוגמה הבאה מוצגת בקשה לנתוני תחזית מזג האוויר לשישה ימים במאונטן וויו, קליפורניה, עם שלושה ימים של נתונים בכל דף:

curl -X GET "https://weather.googleapis.com/v1/forecast/days:lookup?key=YOUR_API_KEY&location.latitude=37.4220&location.longitude=-122.0841&days=6&pageSize=3"

התשובה, שכוללת את הנתונים של 3 הימים הראשונים, היא בפורמט הבא:

{
  "forecastDays": [
    {
      "interval": {
        "startTime": "2025-02-10T15:00:00Z",
        "endTime": "2025-02-11T15:00:00Z"
      },
      "displayDate": {
        "year": 2025,
        "month": 2,
        "day": 10
      },
      "daytimeForecast": {
        "interval": {
          "startTime": "2025-02-10T15:00:00Z",
          "endTime": "2025-02-11T03:00:00Z"
        },
        "weatherCondition": {
          "iconBaseUri": "https://maps.gstatic.com/weather/v1/party_cloudy",
          "description": {
            "text": "Partly sunny",
            "languageCode": "en"
          },
          "type": "PARTLY_CLOUDY"
        },
        "relativeHumidity": 52,
        "uvIndex": 3,
        "precipitation": {
          "probability": {
            "percent": 5,
            "type": "RAIN"
          },
          "qpf": {
            "quantity": 0,
            "unit": "MILLIMETERS"
          }
        },
        "thunderstormProbability": 0,
        "wind": {
          "direction": {
            "degrees": 280,
            "cardinal": "WEST"
          },
          "speed": {
            "value": 6,
            "unit": "KILOMETERS_PER_HOUR"
          },
          "gust": {
            "value": 14,
            "unit": "KILOMETERS_PER_HOUR"
          }
        },
        "cloudCover": 53
      },
      "nighttimeForecast": {
        "interval": {
          "startTime": "2025-02-11T03:00:00Z",
          "endTime": "2025-02-11T15:00:00Z"
        },
        "weatherCondition": {
          "iconBaseUri": "https://maps.gstatic.com/weather/v1/partly_clear",
          "description": {
            "text": "Partly cloudy",
            "languageCode": "en"
          },
          "type": "PARTLY_CLOUDY"
        },
        "relativeHumidity": 85,
        "uvIndex": 0,
        "precipitation": {
          "probability": {
            "percent": 10,
            "type": "RAIN_AND_SNOW"
          },
          "qpf": {
            "quantity": 0,
            "unit": "MILLIMETERS"
          }
        },
        "thunderstormProbability": 0,
        "wind": {
          "direction": {
            "degrees": 201,
            "cardinal": "SOUTH_SOUTHWEST"
          },
          "speed": {
            "value": 6,
            "unit": "KILOMETERS_PER_HOUR"
          },
          "gust": {
            "value": 14,
            "unit": "KILOMETERS_PER_HOUR"
          }
        },
        "cloudCover": 69
      },
      "maxTemperature": {
        "degrees": 13.5,
        "unit": "CELSIUS"
      },
      "minTemperature": {
        "degrees": 1.5,
        "unit": "CELSIUS"
      },
      "feelsLikeMaxTemperature": {
        "degrees": 13.5,
        "unit": "CELSIUS"
      },
      "feelsLikeMinTemperature": {
        "degrees": 1.5,
        "unit": "CELSIUS"
      },
      "sunEvents": {
        "sunriseTime": "2025-02-10T15:02:35.703929582Z",
        "sunsetTime": "2025-02-11T01:43:00.762932858Z"
      },
      "moonEvents": {
        "moonPhase": "WAXING_GIBBOUS",
        "moonriseTimes": [
          "2025-02-10T23:54:17.713157984Z"
        ],
        "moonsetTimes": [
          "2025-02-10T14:13:58.625181191Z"
        ]
      },
      "maxHeatIndex": {
        "degrees": 13.5,
        "unit": "CELSIUS"
      },
      "iceThickness": {
        "thickness": 0,
        "unit": "MILLIMETERS"
      }
    },
    {
      "interval": {
        "startTime": "2025-02-11T15:00:00Z",
        "endTime": "2025-02-12T15:00:00Z"
      },
      "displayDate": {
        "year": 2025,
        "month": 2,
        "day": 11
      },
      /.../
    },
    {
      "interval": {
        "startTime": "2025-02-12T15:00:00Z",
        "endTime": "2025-02-13T15:00:00Z"
      },
      "displayDate": {
        "year": 2025,
        "month": 2,
        "day": 12
      },
      /.../
    }
  ],
  "timeZone": {
    "id": "America/Los_Angeles"
  },
  "nextPageToken": "ChYKEgm8dJMYBLZCQBH-ZffkYYVewBAGEAMYAyILCKyAqr0GEKOR6lUqE0FtZXJpY2EvTG9zX0FuZ2VsZXM="
}

כדי לגשת לדף הנתונים הבא, מעבירים את הערך nextPageToken לפרמטר pageToken בבקשה:

curl -X GET "https://weather.googleapis.com/v1/forecast/days:lookup?key=YOUR_API_KEY&location.latitude=37.4220&location.longitude=-122.0841&days=6&pageSize=3&pageToken=ChYKEgm8dJMYBLZCQBH-ZffkYYVewBAGEAMYAyILCKyAqr0GEKOR6lUqE0FtZXJpY2EvTG9zX0FuZ2VsZXM="

התשובה היא בפורמט:

{
  "forecastDays": [
    {
      "interval": {
        "startTime": "2025-02-13T15:00:00Z",
        "endTime": "2025-02-14T15:00:00Z"
      },
      "displayDate": {
        "year": 2025,
        "month": 2,
        "day": 13
      },
      "daytimeForecast": {
        "interval": {
          "startTime": "2025-02-13T15:00:00Z",
          "endTime": "2025-02-14T03:00:00Z"
        },
        "weatherCondition": {
          "iconBaseUri": "https://maps.gstatic.com/weather/v1/drizzle",
          "description": {
            "text": "Light rain",
            "languageCode": "en"
          },
          "type": "LIGHT_RAIN"
        },
        "relativeHumidity": 81,
        "uvIndex": 2,
        "precipitation": {
          "probability": {
            "percent": 75,
            "type": "RAIN"
          },
          "qpf": {
            "quantity": 15.588,
            "unit": "MILLIMETERS"
          }
        },
        "thunderstormProbability": 20,
        "wind": {
          "direction": {
            "degrees": 181,
            "cardinal": "SOUTH"
          },
          "speed": {
            "value": 14,
            "unit": "KILOMETERS_PER_HOUR"
          },
          "gust": {
            "value": 32,
            "unit": "KILOMETERS_PER_HOUR"
          }
        },
        "cloudCover": 100
      },
      "nighttimeForecast": {
        "interval": {
          "startTime": "2025-02-14T03:00:00Z",
          "endTime": "2025-02-14T15:00:00Z"
        },
        "weatherCondition": {
          "iconBaseUri": "https://maps.gstatic.com/weather/v1/showers",
          "description": {
            "text": "Rain showers",
            "languageCode": "en"
          },
          "type": "RAIN_SHOWERS"
        },
        "relativeHumidity": 87,
        "uvIndex": 0,
        "precipitation": {
          "probability": {
            "percent": 75,
            "type": "RAIN"
          },
          "qpf": {
            "quantity": 11.3513,
            "unit": "MILLIMETERS"
          }
        },
        "thunderstormProbability": 10,
        "wind": {
          "direction": {
            "degrees": 222,
            "cardinal": "SOUTHWEST"
          },
          "speed": {
            "value": 14,
            "unit": "KILOMETERS_PER_HOUR"
          },
          "gust": {
            "value": 31,
            "unit": "KILOMETERS_PER_HOUR"
          }
        },
        "cloudCover": 95
      },
      "maxTemperature": {
        "degrees": 15.9,
        "unit": "CELSIUS"
      },
      "minTemperature": {
        "degrees": 11.2,
        "unit": "CELSIUS"
      },
      "feelsLikeMaxTemperature": {
        "degrees": 15.9,
        "unit": "CELSIUS"
      },
      "feelsLikeMinTemperature": {
        "degrees": 11,
        "unit": "CELSIUS"
      },
      "sunEvents": {
        "sunriseTime": "2025-02-13T14:59:17.439839464Z",
        "sunsetTime": "2025-02-14T01:46:14.345904643Z"
      },
      "moonEvents": {
        "moonPhase": "WANING_GIBBOUS",
        "moonriseTimes": [
          "2025-02-14T03:08:04.049988754Z"
        ],
        "moonsetTimes": [
          "2025-02-13T15:44:40.326916694Z"
        ]
      },
      "maxHeatIndex": {
        "degrees": 15.9,
        "unit": "CELSIUS"
      },
      "iceThickness": {
        "thickness": 0,
        "unit": "MILLIMETERS"
      }
    },
    {
      "interval": {
        "startTime": "2025-02-14T15:00:00Z",
        "endTime": "2025-02-15T15:00:00Z"
      },
      "displayDate": {
        "year": 2025,
        "month": 2,
        "day": 14
      },
      /.../
    },
    {
      "interval": {
        "startTime": "2025-02-15T15:00:00Z",
        "endTime": "2025-02-16T15:00:00Z"
      },
      "displayDate": {
        "year": 2025,
        "month": 2,
        "day": 15
      },
      /.../
    }
  ],
  "timeZone": {
    "id": "America/Los_Angeles"
  }
}

נסה בעצמך!

באמצעות APIs Explorer אפשר לשלוח בקשות לדוגמה כדי להכיר את ה-API ואת האפשרויות שלו.

  1. לוחצים על סמל ה-API api בצד שמאל של הדף.

  2. אפשר לערוך את פרמטרים הבקשה.

  3. לוחצים על הלחצן Execute (הפעלה). בתיבת הדו-שיח, בוחרים את החשבון שרוצים להשתמש בו כדי לשלוח את הבקשה.

  4. בחלונית APIs Explorer, בוחרים בסמל המסך המלא מסך מלא כדי להרחיב את החלון של APIs Explorer.