위 호출은 다음 JSON 응답을 생성합니다.
응답 데이터에 관한 자세한 내용은 응답 데이터를 참고하세요.
{"hoursInfo":[{"dateTime":"2023-06-26T15:00:00Z","indexes":[{"code":"uaqi","displayName":"Universal AQI","aqi":73,"aqiDisplay":"73","color":{"red":118,"green":202,"blue":51,"alpha":255},"category":"Good air quality","dominantPollutant":"pm10"}]}],"regionCode":"us"}
기간 요청의 예
기간 요청
다음 코드는 시간별 과거 대기질 기록을 여러 개 반환하는 history의 요청 본문을 구성하는 방법을 보여줍니다.
시작 및 종료 타임스탬프인 시간 범위를 지정하거나 현재 시간으로부터 이전 시간 수를 지정하여 여러 레코드를 요청할 수 있습니다.
아래 예에서는 페이지 크기를 2로 설정했으므로 4시간의 대기질 기록 요청이 두 페이지로 반환되며 각 페이지에는 2시간의 데이터가 포함됩니다.
위의 호출은 아래 형식의 JSON 응답을 생성합니다. 응답 데이터에 관한 자세한 내용은 응답 데이터를 참고하세요.
위의 두 호출 모두 4시간의 공기질 데이터를 요청합니다. 하지만 요청에서 pageSize 속성을 2로 설정했기 때문에 응답에는 가장 최근 2시간의 결과만 포함됩니다.
{"hoursInfo":[{"dateTime":"2023-06-15T11:00:00Z","indexes":[{"code":"uaqi","displayName":"Universal AQI","aqi":83,"aqiDisplay":"83","color":{"red":74,"green":185,"blue":54,"alpha":255},"category":"Excellent air quality","dominantPollutant":"o3"}]},{"dateTime":"2023-06-15T10:00:00Z","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"}]}],"regionCode":"us","nextPageToken":"ChYaEgl3gv3XubVCQBEsNMY9TTdUMTE6MDA6MDA"}
응답에는 nextPageToken 속성도 포함됩니다. 이 속성을 사용하여 다음 2시간의 데이터가 포함된 결과의 다음 페이지에 액세스합니다.
결과의 다음 페이지에 액세스하려면 history 엔드포인트에 두 번째 요청을 하지만 이번에는 pageToken 속성을 첫 번째 응답의 nextPageToken 값으로 설정합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-31(UTC)"],[[["\u003cp\u003eThe \u003ccode\u003ehistory\u003c/code\u003e endpoint provides historical hourly air quality data for specific locations, covering up to 30 days.\u003c/p\u003e\n"],["\u003cp\u003eYou can request data for a single hour or a time range, controlling the air quality indexes and pollutants information returned.\u003c/p\u003e\n"],["\u003cp\u003eRequests are made via HTTP POST to the endpoint, including location and time parameters in the JSON request body.\u003c/p\u003e\n"],["\u003cp\u003eResponses include hourly air quality information with indexes, categories, and dominant pollutants, potentially paginated for larger requests.\u003c/p\u003e\n"],["\u003cp\u003eWhen requesting data for a time range, results are paginated, and you can retrieve subsequent pages using the \u003ccode\u003enextPageToken\u003c/code\u003e provided in the response.\u003c/p\u003e\n"]]],[],null,["The [`history`](/maps/documentation/air-quality/reference/rest/v1/history/lookup) endpoint provides\nhistorical hourly air quality information for a specific location, for a given\ntime range, up to a maximum of 30 days. You can control the which AQIs and\npertinent information are returned (such as pollutants concentration level and\nhealth recommendations).\n\nYou can request history of hourly air quality using the\n[`history`](/maps/documentation/air-quality/reference/rest/v1/history/lookup)\nendpoint by sending an HTTP POST request to: \n\n```html\nhttps://airquality.googleapis.com/v1/history:lookup?key=YOUR_API_KEY\n```\n\nInclude your request options in the JSON\n[request body](/maps/documentation/air-quality/reference/rest/v1/history/lookup#request-body). The request body\ncontains the location and the time range for which you would like to get the\nhourly air quality history. It may also include various options to control\nwhat air quality information 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 a single hour request\n\nSingle hour request body\n\nThe following code shows how to construct a request body for a single hour\nhistory request using the\n[`history`](/maps/documentation/air-quality/reference/rest/v1/history/lookup) method.\nIn this example, you set the location and the past timestamp.\n**Note:** Ensure that the `dateTime` parameter specifies a time period within the past 30 days. \n\n```json\ncurl -X POST -d '{\n \"dateTime\": \"2023-06-26T15:01:23Z\",\n \"location\": {\n \"latitude\": 37.419734,\n \"longitude\": -122.0827784\n }\n}' \\\n-H 'Content-Type: application/json' \\\n'https://airquality.googleapis.com/v1/history:lookup?key=YOUR_API_KEY'\n```\n\nSingle hour response\n\nThe call above generates the following\n[JSON response](/maps/documentation/air-quality/reference/rest/v1/history/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 parameter(s). \n\n```json\n{\n \"hoursInfo\": [\n {\n \"dateTime\": \"2023-06-26T15:00:00Z\",\n \"indexes\": [\n {\n \"code\": \"uaqi\",\n \"displayName\": \"Universal AQI\",\n \"aqi\": 73,\n \"aqiDisplay\": \"73\",\n \"color\": {\n \"red\": 118,\n \"green\": 202,\n \"blue\": 51,\n \"alpha\": 255\n },\n \"category\": \"Good air quality\",\n \"dominantPollutant\": \"pm10\"\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 time range request\n\nTime range request\n\nThe following code shows how to construct a request body for a\n[`history`](/maps/documentation/air-quality/reference/rest/v1/history/lookup) which returns multiple\nrecords of historical hourly air quality.\n\nYou can requesting multiple records by specifying a time range, meaning a start\nand end timestamp, or by specifying the number of hours back from the current\ntime.\n| **Note:** Results are returned in *pages* , with the most recent results returned in the first page. Use the `pageSize` property to control the maximum number of results per page. If more than one page is required to retrieve all results, then each page includes the `nextPageToken` property that contains the token you use to retrieve the subsequent page.\n\nIn the example below, because you set the page size to `2`, your request for\nfour hours of air quality history is returned in two pages, where each page\ncontains two hours of data. \n\n```json\ncurl -X POST -d '{\n \"hours\": 4,\n \"pageSize\": 2,\n \"pageToken\":\"\",\n \"location\": {\n \"latitude\": 37.419734,\n \"longitude\": -122.0827784\n }\n}' \\\n-H 'Content-Type: application/json' \\\n'https://airquality.googleapis.com/v1/history:lookup?key=YOUR_API_KEY'\n```\n\nYou can make a similar request by passing the start and end timestamps:\n**Note:** Ensure that the `startTime` and `endTime` parameters specify a time period within the past 30 days. \n\n```json\ncurl -X POST -d '{\n \"period\": {\n \"startTime\":\"2023-06-15T08:00:00Z\",\n \"endTime\":\"2023-06-15T12:00:00Z\"\n },\n \"pageSize\": 2,\n \"pageToken\":\"\",\n \"location\": {\n \"latitude\": 37.419734,\n \"longitude\": -122.0827784\n }\n}' \\\n-H 'Content-Type: application/json' \\\n'https://airquality.googleapis.com/v1/history:lookup?key=YOUR_API_KEY'\n```\n\nTime range response\n\nThe calls above generates a\n[JSON response](/maps/documentation/air-quality/reference/rest/v1/history/lookup#response-body) in the form\nbelow. For more details about the response data, see\n[Response data](/maps/documentation/air-quality/response-data).\n\nBoth calls above request four hours air quality data. However, because you set\nthe `pageSize` property to `2` in the request, the response only includes\nresults for the most recent two hours. \n\n```json\n{\n \"hoursInfo\": [\n {\n \"dateTime\": \"2023-06-15T11:00:00Z\",\n \"indexes\": [\n {\n \"code\": \"uaqi\",\n \"displayName\": \"Universal AQI\",\n \"aqi\": 83,\n \"aqiDisplay\": \"83\",\n \"color\": {\n \"red\": 74,\n \"green\": 185,\n \"blue\": 54,\n \"alpha\": 255\n },\n \"category\": \"Excellent air quality\",\n \"dominantPollutant\": \"o3\"\n }\n ]\n },\n {\n \"dateTime\": \"2023-06-15T10:00:00Z\",\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 }\n ],\n \"regionCode\": \"us\",\n \"nextPageToken\": \"ChYaEgl3gv3XubVCQBEsNMY9TTdUMTE6MDA6MDA\"\n}\n```\n\nNotice that the response also includes the `nextPageToken` property. Use this\nproperty to access the next page of the results, which contains the next two\nhours of data.\n\nTo access the next page of results, make a second request to the\n`history` endpoint, but this time set the `pageToken` property to\nthe value of `nextPageToken` from the first response.\n**Note:** When passing the `pageToken` property to access subsequent data pages, all other request parameters must match the original call that provided the page token. \n\n```json\ncurl -X POST -d '{\n \"hours\": 4,\n \"pageSize\": 2,\n \"pageToken\":\"ChYaEgl3gv3XubVCQBEsNMY9TTdUMTE6MDA6MDA\",\n \"location\": {\n \"latitude\": 37.419734,\n \"longitude\": -122.0827784\n }\n}' \\\n-H 'Content-Type: application/json' \\\n'https://airquality.googleapis.com/v1/history:lookup?key=YOUR_API_KEY'\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."]]