Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Punkt końcowy forecast udostępnia prognozę jakości powietrza w określonej lokalizacji na maksymalnie 96 godzin (4 dni). Każda prognoza zawiera godzinowe indeksy jakości powietrza oraz dodatkowe informacje:
Konkretna data i godzina lub okres prognozy
Kod języka przetłumaczonych pól
Lokalny lub niestandardowy indeks jakości powietrza (AQI)
Rekomendacje dotyczące zdrowia
Główne zanieczyszczenia
Stężenie zanieczyszczeń
Dodatkowe informacje o zanieczyszczeniach
Rozmiar strony odpowiedzi
Paleta kolorów
Narzędzie API Explorer umożliwia wysyłanie żądań w czasie rzeczywistym, dzięki czemu możesz zapoznać się z interfejsem API i jego opcjami:
W treści żądania umieść parametry. Treść żądania zawiera lokalizację, dla której chcesz uzyskać godzinową prognozę jakości powietrza, oraz różne opcje, które pozwalają określić, jakie dodatkowe informacje mają być uwzględnione w odpowiedzi.
Informacje o odpowiedziach prognozy
W treści odpowiedzi podawana jest data i godzina w UTC, dla których mają być wyświetlane informacje o prognozie jakości powietrza, indeksy jakości powietrza i dodatkowe informacje dostosowane do potrzeb użytkownika. Treść odpowiedzi zawiera też token umożliwiający pobranie następnej strony, jeśli informacje nie mieszczą się na stronie o rozmiarze określonym w żądaniu.
Przykład podstawowego żądania
Poniższy kod pokazuje, jak utworzyć żądanie prognozy. W tym przykładzie określasz lokalizację, datę i godzinę (od następnej godziny do 96 godzin), dla których mają być wyświetlane godzinowe prognozy jakości powietrza.
{"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"}
Przykład żądania z wieloma parametrami
Poniższy kod pokazuje, jak utworzyć treść żądania z wieloma parametrami. W tym przykładzie podajesz te informacje:
Lokalizacja
Przedział czasu, dla którego mają być wyświetlane informacje o prognozie jakości powietrza
Kod języka
Dodatkowe obliczenia (np. rekomendacje dotyczące zdrowia, stężenie dominującego zanieczyszczenia i dodatkowe informacje o zanieczyszczeniach)
Spowoduje to wyświetlenie następnej strony informacji o prognozie:
{"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"}
Wypróbuj
Eksplorator interfejsów API umożliwia wysyłanie przykładowych żądań, dzięki czemu możesz zapoznać się z interfejsem API i jego opcjami.
Po prawej stronie strony kliknij ikonę interfejsu API api.
Opcjonalnie możesz edytować parametry żądania.
Kliknij przycisk Wykonaj. W oknie dialogowym wybierz konto, z którego chcesz wysłać prośbę.
W panelu APIs Explorer kliknij ikonę pełnego ekranu fullscreen, aby rozwinąć okno narzędzia.
[null,null,["Ostatnia aktualizacja: 2025-08-31 UTC."],[[["\u003cp\u003eThe Air Quality API's forecast endpoint provides hourly air quality forecasts for up to 96 hours (4 days) for a specified location.\u003c/p\u003e\n"],["\u003cp\u003eForecast data includes air quality indexes, dominant pollutants, health recommendations, pollutant concentrations, and more.\u003c/p\u003e\n"],["\u003cp\u003eRequests are made via HTTP POST to the endpoint with parameters specifying location, time, and optional data inclusions.\u003c/p\u003e\n"],["\u003cp\u003eResponses contain hourly forecast data, potentially paginated, with a token for retrieving subsequent pages if necessary.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can customize requests to include specific language codes, color palettes, and additional computations for a tailored response.\u003c/p\u003e\n"]]],[],null,["The [`forecast`](/maps/documentation/air-quality/reference/rest/v1/forecast/lookup) endpoint\nprovides up to 96 hours (4 days) of hourly air\nquality forecast information for a given location. Each forecast includes hourly\nair quality indexes as well as additional information:\n\n- Specific time and date or time period for forecast\n- Language code for translated fields\n- Local or custom air quality index (AQI)\n- Health recommendations\n- Dominant pollutants\n- Pollutant concentration\n- Additional information about pollutants\n- Response page size\n- Color palette\n\nThe APIs Explorer lets you make live requests so that you can get familiar with\nthe API and the API options: \n[Try it!](#try_it)\n| To get air quality forecasts, set the `dateTime` parameter to a future date and time, as shown in the [basic\n| request example](/maps/documentation/air-quality/forecast#example_of_basic_request) below.\n\nAbout forecast requests\n\nYou can request hourly air quality forecast information using the\nforecast endpoint by sending an HTTP POST request to: \n\n```html\nhttps://airquality.googleapis.com/v1/forecast:lookup?key=YOUR_API_KEY\n```\n\nInclude your\n[parameters](/maps/documentation/air-quality/reference/rest/v1/forecast/lookup#request-body)\nin the request body. The request body contains the location for which you would\nlike to get air quality hourly forecast information and various options to\ncontrol what additional information to include in the response.\n\nAbout forecast responses\n\nThe response body provides the UTC date and time for which to display air\nquality forecast information, air quality indexes, and additional customized\ninformation. The response body also includes a token to retrieve the next page\nif the information does not fit within the requested page size.\n\nExample of basic request\n\nThe following code shows how to construct a forecast request. In this example,\nyou specify the location, date and time (beginning from the next hour up to 96\nhours) for which to show hourly air quality forecast information. \n\n```bash\ncurl -X POST -d '{\n \"location\": {\n \"latitude\": 37.4125333,\n \"longitude\": -122.0840937\n },\n \"dateTime\": \"2024-02-09T08:00:00Z\"\n}' \\\n-H \"Content-Type: application/json\" \\\n-H \"Accept-Language: *\" \\\n\"https://airquality.googleapis.com/v1/forecast:lookup?key=YOUR_API_KEY\"\n```\n\nThe call generates the following JSON response. \n\n```json\n{\n \"hourlyForecasts\": [\n {\n \"dateTime\": \"2024-02-09T08:00:00Z\",\n \"indexes\": [\n {\n \"code\": \"uaqi\",\n \"displayName\": \"Universal AQI\",\n \"aqi\": 80,\n \"aqiDisplay\": \"80\",\n \"color\": {\n \"red\": 0.34509805,\n \"green\": 0.74509805,\n \"blue\": 0.20784314\n },\n \"category\": \"Excellent air quality\",\n \"dominantPollutant\": \"pm25\"\n }\n ]\n }\n ],\n \"regionCode\": \"us\"\n}\n```\n| **Note:** If a `color` field value is `0`, that field is omitted from the response.\n\nExample of request with multiple parameters\n\nThe following code shows how to construct a request body with multiple\nparameters. In this example, you specify the following:\n\n- Location\n- Time period for which to display air quality forecast information\n- Language code\n- Extra computations (such as health recommendations, the dominant pollutant concentration, and additional pollutant information)\n- Color palette\n\n```bash\ncurl -X POST -d '{\n \"pageSize\": \"10\",\n \"universalAqi\": \"true\",\n \"location\": {\n \"latitude\": \"40.741895\",\n \"longitude\": \"-73.989308\"\n },\n \"period\": {\n \"startTime\": \"2024-02-27T13:58:14+02:00\",\n \"endTime\": \"2024-02-28T16:58:14+02:00\"\n },\n \"languageCode\": \"en\",\n \"extraComputations\": [\n \"HEALTH_RECOMMENDATIONS\",\n \"DOMINANT_POLLUTANT_CONCENTRATION\",\n \"POLLUTANT_ADDITIONAL_INFO\"\n ],\n \"uaqiColorPalette\": \"RED_GREEN\"\n}' \\\n-H \"Content-Type: application/json\" \\\n-H \"Accept-Language: *\" \\\n\"https://airquality.googleapis.com/v1/forecast:lookup?key=YOUR_API_KEY\"\n```\n\nThe call generates the following JSON response. \n\n```json\n{\n {\n \"hourlyForecasts\": [\n {\n \"dateTime\": \"2024-02-27T11:00:00Z\",\n \"indexes\": [\n {\n \"code\": \"uaqi\",\n \"displayName\": \"Universal AQI\",\n \"aqi\": 75,\n \"aqiDisplay\": \"75\",\n \"color\": {\n \"red\": 0.43137255,\n \"green\": 0.7764706,\n \"blue\": 0.20392157\n },\n \"category\": \"Good air quality\",\n \"dominantPollutant\": \"pm25\"\n }\n ],\n \"pollutants\": [\n {\n \"code\": \"pm25\",\n \"displayName\": \"PM2.5\",\n \"fullName\": \"Fine particulate matter (\\u003c2.5µm)\",\n \"concentration\": {\n \"value\": 15.1,\n \"units\": \"MICROGRAMS_PER_CUBIC_METER\"\n },\n \"additionalInfo\": {\n \"sources\": \"...\",\n \"effects\": \"...\"\n }\n }\n ],\n \"healthRecommendations\": {\n \"generalPopulation\": \"...\",\n \"lungDiseasePopulation\": \"...\",\n \"heartDiseasePopulation\": \"...\",\n \"athletes\": \"...\",\n \"pregnantWomen\": \"...\"\n }\n },\n {\n \"dateTime\": \"2024-02-27T12:00:00Z\",\n \"indexes\": [\n {\n \"code\": \"uaqi\",\n \"displayName\": \"Universal AQI\",\n \"aqi\": 67,\n \"aqiDisplay\": \"67\",\n \"color\": {\n \"red\": 0.5882353,\n \"green\": 0.8392157,\n \"blue\": 0.16862746\n },\n \"category\": \"Good air quality\",\n \"dominantPollutant\": \"pm25\"\n }\n ],\n \"pollutants\": [\n {\n \"code\": \"pm25\",\n \"displayName\": \"PM2.5\",\n \"fullName\": \"Fine particulate matter (\\u003c2.5µm)\",\n \"concentration\": {\n \"value\": 19.96,\n \"units\": \"MICROGRAMS_PER_CUBIC_METER\"\n },\n \"additionalInfo\": {\n \"sources\": \"...\",\n \"effects\": \"...\"\n }\n }\n ],\n \"healthRecommendations\": {\n \"generalPopulation\": \"...\",\n \"lungDiseasePopulation\": \"...\",\n \"heartDiseasePopulation\": \"...\",\n \"athletes\": \"...\",\n \"pregnantWomen\": \"...\",\n \"children\": \"...\"\n }\n },\n /.../\n ]\n }\n \"regionCode\": \"us\",\n \"nextPageToken\": \"CjMKEglwCFVq9l5EQBH0aoDSUH9SwBoQCgYI1pDirgYSBgiGiOiuBiABKgMCBAMyAmVuOAEQGA==\"\n}\n```\n\nTo view the next page of forecast information, pass in the `nextPageToken`\nreturned at the end of the response body: \n\n```bash\ncurl -X POST -d '{\n \"universalAqi\": \"true\",\n \"location\": {\n \"latitude\": \"40.741895\",\n \"longitude\": \"-73.989308\"\n },\n \"period\": {\n \"startTime\": \"2024-02-27T13:58:14+02:00\",\n \"endTime\": \"2024-02-28T16:58:14+02:00\"\n },\n \"languageCode\": \"en\",\n \"extraComputations\": [\n \"HEALTH_RECOMMENDATIONS\",\n \"DOMINANT_POLLUTANT_CONCENTRATION\",\n \"POLLUTANT_ADDITIONAL_INFO\"\n ],\n \"uaqiColorPalette\": \"RED_GREEN\",\n \"pageToken\": \"CjMKEglwCFVq9l5EQBH0aoDSUH9SwBoQCgYI1pDirgYSBgiGiOiuBiABKgMCBAMyAmVuOAEQGA==\"\n}' \\\n-H \"Content-Type: application/json\" \\\n-H \"Accept-Language: *\" \\\n\"https://airquality.googleapis.com/v1/forecast:lookup?key=YOUR_API_KEY\"\n```\n\nThis returns the next page of forecast information: \n\n```json\n{\n \"hourlyForecasts\": [\n {\n \"dateTime\": \"2024-02-27T21:00:00Z\",\n \"indexes\": [\n {\n \"code\": \"uaqi\",\n \"displayName\": \"Universal AQI\",\n \"aqi\": 74,\n \"aqiDisplay\": \"74\",\n \"color\": {\n \"red\": 0.44705883,\n \"green\": 0.78431374,\n \"blue\": 0.2\n },\n \"category\": \"Good air quality\",\n \"dominantPollutant\": \"o3\"\n }\n ],\n \"pollutants\": [\n {\n \"code\": \"o3\",\n \"displayName\": \"O3\",\n \"fullName\": \"Ozone\",\n \"concentration\": {\n \"value\": 32.07,\n \"units\": \"PARTS_PER_BILLION\"\n },\n \"additionalInfo\": {\n \"sources\": \"...\",\n \"effects\": \"...\"\n }\n }\n ],\n \"healthRecommendations\": {\n \"generalPopulation\": \"...\",\n \"elderly\": \"...\",\n \"lungDiseasePopulation\": \"...\",\n \"heartDiseasePopulation\": \"...\",\n \"athletes\": \"...\",\n \"pregnantWomen\": \"...\",\n \"children\": \"...\"\n }\n },\n {\n \"dateTime\": \"2024-02-27T22:00:00Z\",\n \"indexes\": [\n {\n \"code\": \"uaqi\",\n \"displayName\": \"Universal AQI\",\n \"aqi\": 75,\n \"aqiDisplay\": \"75\",\n \"color\": {\n \"red\": 0.43137255,\n \"green\": 0.7764706,\n \"blue\": 0.20392157\n },\n \"category\": \"Good air quality\",\n \"dominantPollutant\": \"o3\"\n }\n ],\n \"pollutants\": [\n {\n \"code\": \"o3\",\n \"displayName\": \"O3\",\n \"fullName\": \"Ozone\",\n \"concentration\": {\n \"value\": 30.94,\n \"units\": \"PARTS_PER_BILLION\"\n },\n \"additionalInfo\": {\n \"sources\": \"...\",\n \"effects\": \"...\"\n }\n }\n ],\n \"healthRecommendations\": {\n \"generalPopulation\": \"...\",\n \"lungDiseasePopulation\": \"...\",\n \"heartDiseasePopulation\": \"...\",\n \"athletes\": \"...\",\n \"pregnantWomen\": \"...\",\n \"children\": \"...\"\n }\n },\n /.../\n ]\n \"regionCode\": \"us\"\n}\n```\n\nTry it!\n\nThe APIs Explorer lets you make sample requests so\nthat you can get familiar with the API and the API options.\n\n1. Select the API icon api\n on the right side of the page.\n\n2. Optionally edit the request parameters.\n\n3. Select the **Execute** button. In the dialog, choose the account\n that you want to use to make the request.\n\n4. In the APIs Explorer panel, select the fullscreen icon\n fullscreen to expand the APIs Explorer window."]]