תחזית

נקודת הקצה של התחזית מספקת עד 96 שעות (4 ימים) מידע על תחזית איכות האוויר בכל שעה במיקום נתון. כל תחזית כוללת מדדים שעתיים של איכות האוויר, וגם מידע נוסף:

  • תאריך, תאריך או תקופה ספציפיים לתחזית
  • קוד שפה לשדות מתורגמים
  • מדד איכות האוויר (AQI) מקומי או מותאם אישית
  • המלצות בתחום הבריאות
  • מזהמים דומיננטיים
  • ריכוז המזהמים
  • מידע נוסף על מזהמים
  • גודל דף התגובה
  • לוח צבעים

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

אפשר לבקש מידע שעתי על תחזית איכות האוויר באמצעות נקודת הקצה לחיזוי. לשם כך, שולחים בקשת HTTP POST אל:

https://airquality.googleapis.com/v1/forecast:lookup?key=YOUR_API_KEY

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

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

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

דוגמה לבקשה בסיסית

הקוד הבא מראה איך ליצור בקשה לתחזית. בדוגמה הזו מציינים את המיקום, התאריך והשעה (מהשעה הבאה ועד 96 שעות) שעבורם יוצג מידע שעתי על התחזית של איכות האוויר.

curl -X POST -d '{
  "location": {
    "latitude": 37.4125333,
    "longitude": -122.0840937
  },
  "dateTime": "2024-02-09T08:00:00Z"
}' \
-H "Content-Type: application/json" \
-H "Accept-Language: *" \
"https://airquality.googleapis.com/v1/forecast:lookup?key=YOUR_API_KEY"

הקריאה יוצרת את תגובת ה-JSON הבאה.

{
  "hourlyForecasts": [
    {
      "dateTime": "2024-02-09T08:00:00Z",
      "indexes": [
        {
          "code": "uaqi",
          "displayName": "Universal AQI",
          "aqi": 80,
          "aqiDisplay": "80",
          "color": {
            "red": 0.34509805,
            "green": 0.74509805,
            "blue": 0.20784314
          },
          "category": "Excellent air quality",
          "dominantPollutant": "pm25"
        }
      ]
    }
  ],
  "regionCode": "us"
}

דוגמה לבקשה עם מספר פרמטרים

הקוד הבא מראה איך ליצור גוף בקשה עם מספר פרמטרים. בדוגמה הזו מציינים את הפרטים הבאים:

  • מיקום
  • תקופת הזמן שעבורה יוצג מידע על תחזית איכות האוויר
  • קוד שפה
  • חישובים נוספים (למשל המלצות בריאות, ריכוז המזהמים הדומיננטיים ומידע נוסף על מזהמים)
  • לוח צבעים
curl -X POST -d '{
    "pageSize": "10",
    "universalAqi": "true",
    "location": {
        "latitude": "40.741895",
        "longitude": "-73.989308"
    },
    "period": {
        "startTime": "2024-02-27T13:58:14+02:00",
        "endTime": "2024-02-28T16:58:14+02:00"
    },
    "languageCode": "en",
    "extraComputations": [
        "HEALTH_RECOMMENDATIONS",
        "DOMINANT_POLLUTANT_CONCENTRATION",
        "POLLUTANT_ADDITIONAL_INFO"
    ],
    "uaqiColorPalette": "RED_GREEN"
}' \
-H "Content-Type: application/json" \
-H "Accept-Language: *" \
"https://airquality.googleapis.com/v1/forecast:lookup?key=YOUR_API_KEY"

הקריאה יוצרת את תגובת ה-JSON הבאה.

{
  {
  "hourlyForecasts": [
    {
      "dateTime": "2024-02-27T11:00:00Z",
      "indexes": [
        {
          "code": "uaqi",
          "displayName": "Universal AQI",
          "aqi": 75,
          "aqiDisplay": "75",
          "color": {
            "red": 0.43137255,
            "green": 0.7764706,
            "blue": 0.20392157
          },
          "category": "Good air quality",
          "dominantPollutant": "pm25"
        }
      ],
      "pollutants": [
        {
          "code": "pm25",
          "displayName": "PM2.5",
          "fullName": "Fine particulate matter (\u003c2.5µm)",
          "concentration": {
            "value": 15.1,
            "units": "MICROGRAMS_PER_CUBIC_METER"
          },
          "additionalInfo": {
            "sources": "...",
            "effects": "..."
          }
        }
      ],
      "healthRecommendations": {
        "generalPopulation": "...",
        "lungDiseasePopulation": "...",
        "heartDiseasePopulation": "...",
        "athletes": "...",
        "pregnantWomen": "..."
      }
    },
    {
      "dateTime": "2024-02-27T12:00:00Z",
      "indexes": [
        {
          "code": "uaqi",
          "displayName": "Universal AQI",
          "aqi": 67,
          "aqiDisplay": "67",
          "color": {
            "red": 0.5882353,
            "green": 0.8392157,
            "blue": 0.16862746
          },
          "category": "Good air quality",
          "dominantPollutant": "pm25"
        }
      ],
      "pollutants": [
        {
          "code": "pm25",
          "displayName": "PM2.5",
          "fullName": "Fine particulate matter (\u003c2.5µm)",
          "concentration": {
            "value": 19.96,
            "units": "MICROGRAMS_PER_CUBIC_METER"
          },
          "additionalInfo": {
            "sources": "...",
            "effects": "..."
          }
        }
      ],
      "healthRecommendations": {
        "generalPopulation": "...",
        "lungDiseasePopulation": "...",
        "heartDiseasePopulation": "...",
        "athletes": "...",
        "pregnantWomen": "...",
        "children": "..."
      }
    },
    /.../
  ]
  }
  "regionCode": "us",
  "nextPageToken": "CjMKEglwCFVq9l5EQBH0aoDSUH9SwBoQCgYI1pDirgYSBgiGiOiuBiABKgMCBAMyAmVuOAEQGA=="
}

כדי לצפות בדף הבא של מידע על התחזית, מעבירים את הערך nextPageToken שמוחזר בסוף גוף התשובה:

curl -X POST -d '{
    "universalAqi": "true",
    "location": {
        "latitude": "40.741895",
        "longitude": "-73.989308"
    },
    "period": {
        "startTime": "2024-02-27T13:58:14+02:00",
        "endTime": "2024-02-28T16:58:14+02:00"
    },
    "languageCode": "en",
    "extraComputations": [
        "HEALTH_RECOMMENDATIONS",
        "DOMINANT_POLLUTANT_CONCENTRATION",
        "POLLUTANT_ADDITIONAL_INFO"
    ],
    "uaqiColorPalette": "RED_GREEN",
    "pageToken": "CjMKEglwCFVq9l5EQBH0aoDSUH9SwBoQCgYI1pDirgYSBgiGiOiuBiABKgMCBAMyAmVuOAEQGA=="
}' \
-H "Content-Type: application/json" \
-H "Accept-Language: *" \
"https://airquality.googleapis.com/v1/forecast:lookup?key=YOUR_API_KEY"

הפעולה הזו מחזירה את הדף הבא עם פרטי התחזית:

{
  "hourlyForecasts": [
    {
      "dateTime": "2024-02-27T21:00:00Z",
      "indexes": [
        {
          "code": "uaqi",
          "displayName": "Universal AQI",
          "aqi": 74,
          "aqiDisplay": "74",
          "color": {
            "red": 0.44705883,
            "green": 0.78431374,
            "blue": 0.2
          },
          "category": "Good air quality",
          "dominantPollutant": "o3"
        }
      ],
      "pollutants": [
        {
          "code": "o3",
          "displayName": "O3",
          "fullName": "Ozone",
          "concentration": {
            "value": 32.07,
            "units": "PARTS_PER_BILLION"
          },
          "additionalInfo": {
            "sources": "...",
            "effects": "..."
          }
        }
      ],
      "healthRecommendations": {
        "generalPopulation": "...",
        "elderly": "...",
        "lungDiseasePopulation": "...",
        "heartDiseasePopulation": "...",
        "athletes": "...",
        "pregnantWomen": "...",
        "children": "..."
      }
    },
    {
      "dateTime": "2024-02-27T22:00:00Z",
      "indexes": [
        {
          "code": "uaqi",
          "displayName": "Universal AQI",
          "aqi": 75,
          "aqiDisplay": "75",
          "color": {
            "red": 0.43137255,
            "green": 0.7764706,
            "blue": 0.20392157
          },
          "category": "Good air quality",
          "dominantPollutant": "o3"
        }
      ],
      "pollutants": [
        {
          "code": "o3",
          "displayName": "O3",
          "fullName": "Ozone",
          "concentration": {
            "value": 30.94,
            "units": "PARTS_PER_BILLION"
          },
          "additionalInfo": {
            "sources": "...",
            "effects": "..."
          }
        }
      ],
      "healthRecommendations": {
        "generalPopulation": "...",
        "lungDiseasePopulation": "...",
        "heartDiseasePopulation": "...",
        "athletes": "...",
        "pregnantWomen": "...",
        "children": "..."
      }
    },
    /.../
  ]
  "regionCode": "us"
}