予測

予測エンドポイントは、特定の場所について最大 96 時間(4 日間)の 1 時間ごとの大気質予測情報を提供します。各予測には、1 時間ごとの大気質指数と追加情報が含まれます。

  • 予測を行う特定の日時または期間
  • 翻訳されたフィールドの言語コード
  • ローカルまたはカスタムの大気質指数(AQI)
  • 健康に関する推奨事項
  • 主な汚染物質
  • 汚染物質濃度
  • 汚染物質に関する追加情報
  • レスポンス ページのサイズ
  • カラーパレット

予測リクエストについて

予測エンドポイントを使用して、次の宛先に HTTP POST リクエストを送信することで、1 時間ごとの大気質予測情報をリクエストできます。

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

リクエストの本文にパラメータを含めます。リクエストの本文には、大気質の 1 時間ごとの予報情報を取得する場所と、レスポンスに含める追加情報を制御するためのさまざまなオプションが含まれています。

予測レスポンスについて

レスポンスの本文では、大気質予測情報、大気質指数、その他のカスタマイズされた情報を表示する UTC の日付と時刻を指定します。レスポンスの本文には、リクエストされたページサイズに情報が収まらない場合に次のページを取得するためのトークンも含まれています。

基本的なリクエストの例

次のコードは、予測リクエストの作成方法を示しています。この例では、1 時間ごとの大気質予測情報を表示する場所、日時(次の 1 時間から最大 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"
}