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”窗口。
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):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)."]]