GET/api/v4/locations/{locationId}/reviews

列出地点的互动

返回单个地点的评价和社交互动列表,支持游标分页和筛选。

需要 API 密钥。请求头格式和密钥轮换请参阅身份验证。

参数

路径

名称类型必填描述
locationIdstring必填Location ID, a raw numeric database ID (e.g. `1800289`) or its Base64-encoded Relay ID (e.g. `TG9jYXRpb246MTgwMDI4OQ==`).

查询

名称类型必填描述默认值
siteUrlsstring可选JSON-encoded array of publisher hostnames to include, e.g. `["maps.google.com","yelp.com"]`.—
startDatestring可选Start of the date-range filter (YYYY-MM-DD).—
endDatestring可选End of the date-range filter (YYYY-MM-DD).—
searchStringstring可选Full-text search across interaction content.—
categorystring可选Single interaction category, e.g. `REVIEW`.—
categoriesstring可选JSON-encoded array of interaction categories.—
ratingFiltersstring可选JSON-encoded array of star ratings to include, e.g. `[3,4]`.—
ratingFilterinteger可选Single star rating to filter by.—
responseStatusstring可选JSON-encoded response-status filter. Values: `RESPONDED`, `PENDING`.—
sortOrderstring可选JSON-encoded sort order. Values: `NEWEST_FIRST`, `OLDEST_FIRST`, `LAST_RESPONDED`.—
firstinteger可选Number of records to return from the beginning (newest first). Defaults to 20 when omitted, the endpoint always returns a single page, never the whole history.—
afterstring可选Cursor to page forward from. Pass `pageInfo.endCursor`, or equivalently the `cursor` of the last edge in the previous page.—
lastinteger可选Number of records to return from the end.—
beforestring可选Cursor to page backward from, used with `last`. Pass the `cursor` of the first edge of the page you are moving back from. `pageInfo` carries no `startCursor` field, so the edge cursor is the value to use.—

响应

200Paginated interactions result. `data.interactions` holds the connection.
Response
{  "data": {    "interactions": {      "pageInfo": {        "hasNextPage": true,        "hasPreviousPage": false,        "endCursor": "SW50ZXJhY3Rpb246MV8xNTU0MjQzMDczMDM2LTllMjZkMmE4LWE2ZWQtNDJlYS04NDU0LTQ3ZDFjOTJlYTg0MQ=="      },      "edges": [        {          "node": {            "id": "9e26d2a8-a6ed-42ea-8454-47d1c92ea841",            "source": "maps.google.com",            "content": "nice place for family together",            "authorName": "vaibhav nakate",            "rating": 5,            "date": "2019-04-02T22:11:13.036997+00:00",            "category": "Review",            "type": "Review",            "responded": false,            "responseCount": 0,            "canRespond": true,            "permalink": "https://maps.google.com/maps?cid=..."          },          "cursor": "SW50ZXJhY3Rpb246MV8xNTU0MjQzMDczMDM2LTllMjZkMmE4LWE2ZWQtNDJlYS04NDU0LTQ3ZDFjOTJlYTg0MQ=="        }      ],      "totalCount": 425    }  }}
401Unauthenticated, missing or invalid API key.
429Rate limit exceeded. Retry after the `Retry-After` header value.

使用基于游标的分页方式返回某个地点的评价和社交互动。结果默认按从新到旧的顺序排列。连接位于 data.interactions,包含 edges[].node(请参阅互动属性参考)、pageInfo 中的一个 endCursor 以及一个 totalCount。

totalCount 是整个结果集中符合您筛选条件的互动数量,而不是本页返回的数量。您可以用它来估算历史数据回填的规模,或核对您自行统计的总数:如果某地点的 totalCount: 450,以 first=50 读取需要 9 次请求,读取到末尾时,各页数量之和应为 450。省略 first 会返回 20 条记录,因此单次调用绝不会返回完整的历史记录。

使用场景:单个门店的评价收件箱

要为一个地点构建评价收件箱,请使用 first 和 after 向后翻页:请求 first=25,然后在下一次调用中将响应中的 pageInfo.endCursor 作为 after 传入。每条 edge 也带有自己的 cursor,而最后一条 edge 的 cursor 就是该页的 endCursor,因此这两个值中的任意一个都可以用作 after。当 hasNextPage 为 false 或某页返回的 edges 数组为空时停止,您需要检查这两个条件,因为如果某页恰好以最早的评价结尾,后面还会返回最后一个空页。叠加 responseStatus=["PENDING"] 可仅显示仍在等待商家回复的评价,或叠加 ratingFilters=[1,2] 以优先处理负面评价。每个 node 中的 id 就是要传给回复互动的值,canRespond 表示该来源是否接受商家回复。

使用场景:增量同步

要保持本地镜像同步,请按 startDate/endDate 筛选,使用 sortOrder=["NEWEST_FIRST"] 排序,并持久化保存您已见到的最大 date 值。请注意,此端点采用分页并有速率限制,收到 429 时请遵循 Retry-After 响应头,并避免每次运行时都重新获取完整的历史记录。

所有套餐均支持 Google Maps 和 Facebook。Growth 和 Enterprise 套餐支持 Yelp。JSON 编码的筛选条件(siteUrls、categories、ratingFilters、responseStatus、sortOrder)以经过 URL 编码的 JSON 字符串形式传递。

Request
curl -X GET 'https://listingsapi.com/api/v4/locations/<locationId>/reviews' \  -H "Authorization: API $LISTINGSAPI_KEY"