Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Điểm cuối currentConditions cung cấp thông tin về chất lượng không khí theo giờ hiện tại. Bạn có thể kiểm soát những chỉ số AQI và thông tin liên quan được trả về (chẳng hạn như mức độ nồng độ chất gây ô nhiễm và các khuyến nghị về sức khoẻ).
Bạn có thể yêu cầu chất lượng không khí theo giờ hiện tại bằng cách sử dụng điểm cuối currentConditions bằng cách gửi yêu cầu HTTP POST đến:
Thêm các lựa chọn yêu cầu vào nội dung yêu cầu JSON.
Phần nội dung yêu cầu chứa vị trí mà bạn muốn nhận thông tin về tình trạng hiện tại của chất lượng không khí và nhiều lựa chọn để kiểm soát thông tin về chất lượng không khí cần đưa vào phản hồi.
API Explorer cho phép bạn đưa ra các yêu cầu trực tiếp để có thể làm quen với API và các lựa chọn API:
Lệnh gọi ở trên sẽ tạo ra phản hồi JSON sau đây.
Để biết thêm thông tin về dữ liệu phản hồi, hãy xem phần Dữ liệu phản hồi.
{"dateTime":"2023-10-26T18:00:00Z","regionCode":"us","indexes":[{"code":"uaqi","displayName":"Universal AQI","aqi":52,"aqiDisplay":"52","color":{"red":0.9490196,"green":0.98039216,"blue":0.019607844},"category":"Moderate air quality","dominantPollutant":"no2"}]}
Ví dụ về yêu cầu có nhiều tham số
Yêu cầu nhiều tham số
Đoạn mã sau đây cho biết cách tạo một nội dung yêu cầu cho yêu cầu currentConditions.
Trong ví dụ này, ngoài vị trí, một số phép tính bổ sung và ngôn ngữ phản hồi cũng được chỉ định.
Lệnh gọi ở trên sẽ tạo ra phản hồi JSON sau đây.
Để biết thêm thông tin về dữ liệu phản hồi, hãy xem phần Dữ liệu phản hồi.
{"dateTime":"2023-06-15T10:00:00Z","regionCode":"us","indexes":[{"code":"uaqi","displayName":"Universal AQI","aqi":89,"aqiDisplay":"89","color":{"red":48,"green":175,"blue":55,"alpha":255},"category":"Excellent air quality","dominantPollutant":"o3"},{"code":"usa_epa","displayName":"AQI (US)","aqi":41,"aqiDisplay":"41","color":{"green":228,"alpha":255},"category":"Good air quality","dominantPollutant":"pm25"}],"pollutants":[{"code":"co","displayName":"CO","fullName":"Carbon monoxide","concentration":{"value":334.24,"units":"PARTS_PER_BILLION"},"additionalInfo":{"sources":"Typically originates from incomplete combustion...","effects":"When inhaled, carbon monoxide can prevent the blood from..."}},{"code":"no2","displayName":"NO2","fullName":"Nitrogen dioxide","concentration":{"value":13.12,"units":"PARTS_PER_BILLION"},"additionalInfo":{"sources":"Main sources are fuel burning processes, such as...","effects":"Exposure may cause increased bronchial reactivity..."}},{"code":"o3","displayName":"O3","fullName":"Ozone","concentration":{"value":13.88,"units":"PARTS_PER_BILLION"},"additionalInfo":{"sources":"Ozone is created in a chemical reaction between atmospheric oxygen...","effects":"Ozone can irritate the airways and cause coughing, a burning..."}},{"code":"pm10","displayName":"PM10","fullName":"Inhalable particulate matter (<10µm)","concentration":{"value":5.07,"units":"MICROGRAMS_PER_CUBIC_METER"},"additionalInfo":{"sources":"Main sources are combustion processes (e.g. indoor heating, wildfires)...","effects":"Inhalable particles can penetrate into the lungs. Short term exposure..."}},{"code":"pm25","displayName":"PM2.5","fullName":"Fine particulate matter (<2.5µm)","concentration":{"value":2.83,"units":"MICROGRAMS_PER_CUBIC_METER"},"additionalInfo":{"sources":"Main sources are combustion processes (e.g. power plants, indoor heating...","effects":"Fine particles can penetrate into the lungs and bloodstream. Short term..."}},{"code":"so2","displayName":"SO2","fullName":"Sulfur dioxide","concentration":{"value":0.02,"units":"PARTS_PER_BILLION"},"additionalInfo":{"sources":"Main sources are burning processes of sulfur-containing fuel in industry...","effects":"Exposure causes irritation of the respiratory tract, coughing and generates..."}}],"healthRecommendations":{"generalPopulation":"With this level of air quality, you have no limitations. Enjoy the outdoors!","elderly":"If you start to feel respiratory discomfort such as coughing or breathing difficulties...","lungDiseasePopulation":"...","heartDiseasePopulation":"...","athletes":"...","pregnantWomen":"...","children":"..."}}
Hãy dùng thử!
Trình khám phá API cho phép bạn đưa ra các yêu cầu mẫu để có thể làm quen với API và các lựa chọn API.
Chọn biểu tượng API api ở bên phải trang.
Bạn có thể chỉnh sửa các tham số yêu cầu (không bắt buộc).
Chọn nút Thực thi. Trong hộp thoại, hãy chọn tài khoản mà bạn muốn dùng để đưa ra yêu cầu.
Trong bảng điều khiển APIs Explorer, hãy chọn biểu tượng toàn màn hình fullscreen để mở rộng cửa sổ APIs Explorer.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[[["\u003cp\u003eThe \u003ccode\u003ecurrentConditions\u003c/code\u003e endpoint provides access to hourly air quality data, including AQI, pollutant concentrations, and health recommendations.\u003c/p\u003e\n"],["\u003cp\u003eYou can customize the response to include specific AQIs and extra computations like health recommendations and dominant pollutant information.\u003c/p\u003e\n"],["\u003cp\u003eRequests are made via HTTP POST to the endpoint URL with an API key and a JSON request body containing location and optional parameters.\u003c/p\u003e\n"],["\u003cp\u003eThe response provides current air quality information for the specified location, including relevant AQIs, pollutant concentrations, and optional health recommendations.\u003c/p\u003e\n"]]],["The `currentConditions` endpoint provides hourly air quality data. To use it, send an HTTP POST request to `https://airquality.googleapis.com/v1/currentConditions:lookup?key=YOUR_API_KEY`, including a JSON request body with the desired location. You can specify various options like AQIs, pollutant levels, health recommendations, and language. The response contains current conditions, indexes, pollutants details, and health advice. You can modify your request to get more specific information. The API Explorer allows testing the requests.\n"],null,["The [`currentConditions`](/maps/documentation/air-quality/reference/rest/v1/currentConditions/lookup) endpoint\nprovides current hourly air quality information. You can control which AQIs and\npertinent information are returned (such as pollutants concentration level and\nhealth recommendations).\n\nYou can request current hourly air quality using the\n[`currentConditions`](/maps/documentation/air-quality/reference/rest/v1/currentConditions/lookup)\nendpoint by sending an HTTP POST request to: \n\n```html\nhttps://airquality.googleapis.com/v1/currentConditions:lookup?key=YOUR_API_KEY\n```\n\nInclude your request options in the JSON\n[request body](/maps/documentation/air-quality/reference/rest/v1/currentConditions/lookup#request-body).\nThe request body contains the location for which you would like to get the air\nquality current conditions and various options to control what air quality\ninformation to include in the response.\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\nExample of basic request\n\nBasic request body\n\nThe following code shows how to construct a basic request body for a\n[`currentConditions`](/maps/documentation/air-quality/reference/rest/v1/currentConditions/lookup)\nrequest. In this example, you set only the location. \n\n```bash\ncurl -X POST -d '{\n \"location\": {\n \"latitude\": 37.419734,\n \"longitude\": -122.0827784\n }\n}' \\\n-H 'Content-Type: application/json' \\\n'https://airquality.googleapis.com/v1/currentConditions:lookup?key=YOUR_API_KEY'\n```\n\nBasic request response\n\nThe call above generates the following\n[JSON response](/maps/documentation/air-quality/reference/rest/v1/currentConditions/lookup#response-body).\nFor more details about the response data, see [Response data](/maps/documentation/air-quality/response-data).\n**Note:** By default, the response includes the Universal AQI with the basic AQI information. The AQI can be removed or replaced with a different AQI by setting the corresponding parameters. \n\n```json\n{\n \"dateTime\": \"2023-10-26T18:00:00Z\",\n \"regionCode\": \"us\",\n \"indexes\": [\n {\n \"code\": \"uaqi\",\n \"displayName\": \"Universal AQI\",\n \"aqi\": 52,\n \"aqiDisplay\": \"52\",\n \"color\": {\n \"red\": 0.9490196,\n \"green\": 0.98039216,\n \"blue\": 0.019607844\n },\n \"category\": \"Moderate air quality\",\n \"dominantPollutant\": \"no2\"\n }\n ]\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\nMultiple parameters request\n\nThe following code shows how to construct a request body for a\n[`currentConditions`](/maps/documentation/air-quality/reference/rest/v1/currentConditions/lookup) request.\nIn this example, in addition to the location, several extra computations and\nthe response language are specified. \n\n```bash\ncurl -X POST -d '{\n \"universalAqi\": true,\n \"location\": {\n \"latitude\": 37.419734,\n \"longitude\": -122.0827784\n },\n \"extraComputations\": [\n \"HEALTH_RECOMMENDATIONS\",\n \"DOMINANT_POLLUTANT_CONCENTRATION\",\n \"POLLUTANT_CONCENTRATION\",\n \"LOCAL_AQI\",\n \"POLLUTANT_ADDITIONAL_INFO\"\n ],\n \"languageCode\": \"en\"\n}' \\\n-H 'Content-Type: application/json' \\\n'https://airquality.googleapis.com/v1/currentConditions:lookup?key=YOUR_API_KEY'\n```\n\nMultiple parameters response\n\nThe call above generates the following\n[JSON response](/maps/documentation/air-quality/reference/rest/v1/currentConditions/lookup#response-body).\nFor more details about the response data, see [Response data](/maps/documentation/air-quality/response-data). \n\n```json\n{\n \"dateTime\": \"2023-06-15T10:00:00Z\",\n \"regionCode\": \"us\",\n \"indexes\": [\n {\n \"code\": \"uaqi\",\n \"displayName\": \"Universal AQI\",\n \"aqi\": 89,\n \"aqiDisplay\": \"89\",\n \"color\": {\n \"red\": 48,\n \"green\": 175,\n \"blue\": 55,\n \"alpha\": 255\n },\n \"category\": \"Excellent air quality\",\n \"dominantPollutant\": \"o3\"\n },\n {\n \"code\": \"usa_epa\",\n \"displayName\": \"AQI (US)\",\n \"aqi\": 41,\n \"aqiDisplay\": \"41\",\n \"color\": {\n \"green\": 228,\n \"alpha\": 255\n },\n \"category\": \"Good air quality\",\n \"dominantPollutant\": \"pm25\"\n }\n ],\n \"pollutants\": [\n {\n \"code\": \"co\",\n \"displayName\": \"CO\",\n \"fullName\": \"Carbon monoxide\",\n \"concentration\": {\n \"value\": 334.24,\n \"units\": \"PARTS_PER_BILLION\"\n },\n \"additionalInfo\": {\n \"sources\": \"Typically originates from incomplete combustion...\",\n \"effects\": \"When inhaled, carbon monoxide can prevent the blood from...\"\n }\n },\n {\n \"code\": \"no2\",\n \"displayName\": \"NO2\",\n \"fullName\": \"Nitrogen dioxide\",\n \"concentration\": {\n \"value\": 13.12,\n \"units\": \"PARTS_PER_BILLION\"\n },\n \"additionalInfo\": {\n \"sources\": \"Main sources are fuel burning processes, such as...\",\n \"effects\": \"Exposure may cause increased bronchial reactivity...\"\n }\n },\n {\n \"code\": \"o3\",\n \"displayName\": \"O3\",\n \"fullName\": \"Ozone\",\n \"concentration\": {\n \"value\": 13.88,\n \"units\": \"PARTS_PER_BILLION\"\n },\n \"additionalInfo\": {\n \"sources\": \"Ozone is created in a chemical reaction between atmospheric oxygen...\",\n \"effects\": \"Ozone can irritate the airways and cause coughing, a burning...\"\n }\n },\n {\n \"code\": \"pm10\",\n \"displayName\": \"PM10\",\n \"fullName\": \"Inhalable particulate matter (\u003c10µm)\",\n \"concentration\": {\n \"value\": 5.07,\n \"units\": \"MICROGRAMS_PER_CUBIC_METER\"\n },\n \"additionalInfo\": {\n \"sources\": \"Main sources are combustion processes (e.g. indoor heating, wildfires)...\",\n \"effects\": \"Inhalable particles can penetrate into the lungs. Short term exposure...\"\n }\n },\n {\n \"code\": \"pm25\",\n \"displayName\": \"PM2.5\",\n \"fullName\": \"Fine particulate matter (\u003c2.5µm)\",\n \"concentration\": {\n \"value\": 2.83,\n \"units\": \"MICROGRAMS_PER_CUBIC_METER\"\n },\n \"additionalInfo\": {\n \"sources\": \"Main sources are combustion processes (e.g. power plants, indoor heating...\",\n \"effects\": \"Fine particles can penetrate into the lungs and bloodstream. Short term...\"\n }\n },\n {\n \"code\": \"so2\",\n \"displayName\": \"SO2\",\n \"fullName\": \"Sulfur dioxide\",\n \"concentration\": {\n \"value\": 0.02,\n \"units\": \"PARTS_PER_BILLION\"\n },\n \"additionalInfo\": {\n \"sources\": \"Main sources are burning processes of sulfur-containing fuel in industry...\",\n \"effects\": \"Exposure causes irritation of the respiratory tract, coughing and generates...\"\n }\n }\n ],\n \"healthRecommendations\": {\n \"generalPopulation\": \"With this level of air quality, you have no limitations. Enjoy the outdoors!\",\n \"elderly\": \"If you start to feel respiratory discomfort such as coughing or breathing difficulties...\",\n \"lungDiseasePopulation\": \"...\",\n \"heartDiseasePopulation\": \"...\",\n \"athletes\": \"...\",\n \"pregnantWomen\": \"...\",\n \"children\": \"...\"\n }\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."]]