Places Aggregate API (舊稱 Places Insights API) 現已正式發布 (GA)。
發出第一個要求
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
這份文件將逐步說明如何向 Places Aggregate API 提出基本要求,並瞭解回應內容,包括符合條件的地點數量。
試試看!
如要使用 Places Aggregate API,請向 computeInsights
端點傳送 HTTP POST 要求,如下所示:
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 Explorer 提出範例要求,熟悉 API 和 API 選項。
- 選取頁面右側的 API 圖示
。
- 視需要展開「顯示標準參數」,設定任何參數。
- 選擇性步驟:編輯「要求主體」。
- 選取「執行」按鈕。在對話方塊中,選擇要用來提出要求的帳戶。
在 API Explorer 面板中,選取展開圖示
,展開 API Explorer 視窗。
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間:2025-08-29 (世界標準時間)。"],[],[],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)."]]