ปลายทาง forecast
ให้ข้อมูลพยากรณ์คุณภาพอากาศรายชั่วโมง
สำหรับสถานที่ตั้งที่ระบุได้สูงสุด 96 ชั่วโมง (4 วัน) การพยากรณ์แต่ละครั้งจะมีดัชนีคุณภาพอากาศรายชั่วโมง
รวมถึงข้อมูลเพิ่มเติมดังนี้
- เวลาและวันที่ที่เฉพาะเจาะจงหรือระยะเวลาสำหรับการคาดการณ์
- รหัสภาษาสำหรับฟิลด์ที่แปล
- ดัชนีคุณภาพอากาศ (AQI) ในพื้นที่หรือที่กำหนดเอง
- คำแนะนำด้านสุขภาพ
- สารมลพิษหลัก
- ความเข้มข้นของสารมลพิษ
- ข้อมูลเพิ่มเติมเกี่ยวกับมลพิษ
- ขนาดหน้าการตอบกลับ
- ชุดสี
โปรแกรมสำรวจ API ช่วยให้คุณส่งคำขอแบบเรียลไทม์เพื่อให้คุ้นเคยกับ API และตัวเลือก API ดังนี้
เกี่ยวกับคำขอการคาดการณ์
คุณขอข้อมูลพยากรณ์คุณภาพอากาศรายชั่วโมงได้โดยใช้ ปลายทางการพยากรณ์ด้วยการส่งคำขอ 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" }
ลองใช้งาน
โปรแกรมสำรวจ API ช่วยให้คุณส่งคำขอตัวอย่างได้ เพื่อให้คุ้นเคยกับ API และตัวเลือก API
เลือกไอคอน API api ทางด้านขวาของหน้า
แก้ไขพารามิเตอร์คำขอ (ไม่บังคับ)
เลือกปุ่มดำเนินการ ในกล่องโต้ตอบ ให้เลือกบัญชี ที่ต้องการใช้เพื่อส่งคำขอ
ในแผงโปรแกรมสำรวจ API ให้เลือกไอคอนเต็มหน้าจอ fullscreen เพื่อขยายหน้าต่างโปรแกรมสำรวจ API