Places Aggregate API หรือเดิมเรียกว่า Places Insights API พร้อมให้บริการสำหรับผู้ใช้ทั่วไป (GA) แล้ว
ส่งคําขอแรก
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เอกสารนี้จะอธิบายวิธีการส่งคำขอพื้นฐานไปยัง Places Aggregate API
และทำความเข้าใจการตอบกลับ ซึ่งรวมถึงจำนวนสถานที่ที่ตรงกัน
ลองใช้งาน
หากต้องการใช้ Places Aggregate API ให้ส่งคำขอ HTTP POST ไปยังปลายทาง computeInsights
ดังนี้
https://areainsights.googleapis.com/v1:computeInsights
ปรับแต่งคำขอโดยระบุพารามิเตอร์ภูมิภาคและประเภทในเนื้อหา JSON
ตัวอย่างนี้แสดงคำขอให้แสดงจำนวนร้านอาหารในซานฟรานซิสโกที่เปิดให้บริการ มีราคาปานกลาง และได้รับการจัดอันดับระหว่าง 4 ถึง 5 ดาว
curl --location 'https://areainsights.googleapis.com/v1:computeInsights' \
--header 'X-Goog-Api-Key: API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"insights":[
"INSIGHT_COUNT"
],
"filter":{
"locationFilter":{
"region":{
"place":"places/ChIJIQBpAG2ahYAR_6128GcTUEo"
}
},
"typeFilter":{
"includedTypes":[
"restaurant"
]
},
"operatingStatus":[
"OPERATING_STATUS_OPERATIONAL"
],
"priceLevels":[
"PRICE_LEVEL_INEXPENSIVE"
],
"ratingFilter":{
"minRating":4.0,
"maxRating":5.0
}
}
}'
การตอบกลับของ Places Aggregate API
การตอบกลับต่อไปนี้จากคำขอตัวอย่างข้างต้นแสดงจำนวนร้านอาหารที่ตรงตามเกณฑ์
{
"count": "850"
}
ลองใช้งาน
โปรแกรมสำรวจ API ช่วยให้คุณส่งคำขอตัวอย่างได้
เพื่อให้คุ้นเคยกับ API และตัวเลือก API
- เลือกไอคอน API
ทางด้านขวาของหน้า
- (ไม่บังคับ) ขยายแสดงพารามิเตอร์มาตรฐานเพื่อตั้งค่า
พารามิเตอร์
- แก้ไขเนื้อหาคำขอ (ไม่บังคับ)
- เลือกปุ่มดำเนินการ ในกล่องโต้ตอบ ให้เลือกบัญชี
ที่ต้องการใช้เพื่อส่งคำขอ
ในแผงโปรแกรมสำรวจ API ให้เลือกไอคอนขยาย
เพื่อขยายหน้าต่างโปรแกรมสำรวจ API
ขั้นตอนถัดไป
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-29 UTC
[null,null,["อัปเดตล่าสุด 2025-08-29 UTC"],[],[],null,["# Make your first request\n\nThis document walks you through making a basic request to the Places Aggregate API\nand understanding the response, which includes a count of matching places.\n\n[Try it!](#try-it)\n\nTo use Places Aggregate API, send an HTTP POST request to the `computeInsights`\nendpoint as follows: \n\n```bash\nhttps://areainsights.googleapis.com/v1:computeInsights\n```\n\nRefine your [request](/maps/documentation/places-aggregate/reference/rest/v1/TopLevel/computeInsights#request-body) by providing region and type parameters in the JSON\nbody. This example shows a request to return the count of restaurants in San\nFrancisco that are operational, moderately priced, and rated between 4 and 5\nstars. \n\n```bash\ncurl --location 'https://areainsights.googleapis.com/v1:computeInsights' \\\n--header 'X-Goog-Api-Key: API_KEY' \\\n--header 'Content-Type: application/json' \\\n--data '{\n \"insights\":[\n \"INSIGHT_COUNT\"\n ],\n \"filter\":{\n \"locationFilter\":{\n \"region\":{\n \"place\":\"places/ChIJIQBpAG2ahYAR_6128GcTUEo\"\n }\n },\n \"typeFilter\":{\n \"includedTypes\":[\n \"restaurant\"\n ]\n },\n \"operatingStatus\":[\n \"OPERATING_STATUS_OPERATIONAL\"\n ],\n \"priceLevels\":[\n \"PRICE_LEVEL_INEXPENSIVE\"\n ],\n \"ratingFilter\":{\n \"minRating\":4.0,\n \"maxRating\":5.0\n }\n }\n}'\n```\n\nPlaces Aggregate API response\n-----------------------------\n\nThe following response from the example request above shows the count\nof restaurants that match the criteria. \n\n```json\n{\n \"count\": \"850\"\n}\n```\n\nTry it!\n-------\n\nThe API 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, , on the right side of the page.\n2. Optionally expand **Show standard parameters** to set any parameters.\n3. Optionally edit the **Request body**.\n4. Select **Execute** button. In the dialog, choose the account that you want to use to make the request.\n5. In the API Explorer panel, select the expand icon,\n , to expand the API Explorer window.\n\nWhat's next\n-----------\n\n- Explore more [examples](/maps/documentation/places-aggregate/example-requests) of what you can achieve with Places Aggregate API.\n- Look at the [request parameters](/maps/documentation/places-aggregate/request-parameters) in more detail.\n- View the full [API documentation](/maps/documentation/places-aggregate/reference/rest)."]]