Places Aggregate API(以前称为 Places Insights API)现已正式发布 (GA)。
Thực hiện yêu cầu đầu tiên của bạn
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Tài liệu này hướng dẫn bạn cách đưa ra yêu cầu cơ bản cho Places Aggregate API và hiểu phản hồi, bao gồm cả số lượng địa điểm phù hợp.
Hãy làm thử!
Để sử dụng Places Aggregate API, hãy gửi một yêu cầu HTTP POST đến điểm cuối computeInsights
như sau:
https://areainsights.googleapis.com/v1:computeInsights
Tinh chỉnh yêu cầu bằng cách cung cấp các tham số khu vực và loại trong phần nội dung JSON. Ví dụ này cho thấy một yêu cầu trả về số lượng nhà hàng đang hoạt động, có giá vừa phải và được đánh giá từ 4 đến 5 sao ở San Francisco.
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
}
}
}'
Phản hồi của Places Aggregate API
Phản hồi sau đây từ yêu cầu mẫu ở trên cho biết số lượng nhà hàng đáp ứng các tiêu chí.
{
"count": "850"
}
Hãy dùng thử!
API Explorer cho phép bạn đưa ra các yêu cầu mẫu để làm quen với API và các lựa chọn API.
- Chọn biểu tượng API
ở bên phải trang.
- Bạn có thể mở rộng phần Hiện các thông số chuẩn để đặt bất kỳ thông số nào.
- Bạn có thể chỉnh sửa Nội dung yêu cầu (không bắt buộc).
- Chọn nút Thực thi. Trong hộp thoại, hãy chọn tài khoản mà bạn muốn dùng để đưa ra yêu cầu.
Trong bảng điều khiển API Explorer, hãy chọn biểu tượng mở rộng
để mở rộng cửa sổ API Explorer.
Bước tiếp theo
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-08-29 UTC.
[null,null,["Cập nhật lần gần đây nhất: 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)."]]