/api/v4/locations/{locationId}/reviews拠点のインタラクションを一覧表示
単一の拠点のレビューとソーシャルインタラクションを、フィルターを適用したカーソルページネーション形式の一覧で返します。
パラメーター
パス
| 名前 | 型 | 必須 | 説明 |
|---|---|---|---|
| locationId | string | 必須 | Location ID, a raw numeric database ID (e.g. `1800289`) or its Base64-encoded Relay ID (e.g. `TG9jYXRpb246MTgwMDI4OQ==`). |
クエリ
| 名前 | 型 | 必須 | 説明 | デフォルト |
|---|---|---|---|---|
| siteUrls | string | 任意 | JSON-encoded array of publisher hostnames to include, e.g. `["maps.google.com","yelp.com"]`. | — |
| startDate | string | 任意 | Start of the date-range filter (YYYY-MM-DD). | — |
| endDate | string | 任意 | End of the date-range filter (YYYY-MM-DD). | — |
| searchString | string | 任意 | Full-text search across interaction content. | — |
| category | string | 任意 | Single interaction category, e.g. `REVIEW`. | — |
| categories | string | 任意 | JSON-encoded array of interaction categories. | — |
| ratingFilters | string | 任意 | JSON-encoded array of star ratings to include, e.g. `[3,4]`. | — |
| ratingFilter | integer | 任意 | Single star rating to filter by. | — |
| responseStatus | string | 任意 | JSON-encoded response-status filter. Values: `RESPONDED`, `PENDING`. | — |
| sortOrder | string | 任意 | JSON-encoded sort order. Values: `NEWEST_FIRST`, `OLDEST_FIRST`, `LAST_RESPONDED`. | — |
| first | integer | 任意 | 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. | — |
| after | string | 任意 | Cursor to page forward from. Pass `pageInfo.endCursor`, or equivalently the `cursor` of the last edge in the previous page. | — |
| last | integer | 任意 | Number of records to return from the end. | — |
| before | string | 任意 | 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.
{ "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 件のレコードが返されるため、1 回の呼び出しで履歴全体が返されることはありません。
ユースケース:店舗ごとのレビュー受信トレイ
1 つの拠点のレビュー受信トレイを構築するには、first と after を使用してページを順に取得します。まず first=25 をリクエストし、次の呼び出しではレスポンスの pageInfo.endCursor を after として渡します。各エッジには独自の cursor も含まれ、最後のエッジの cursor はそのページの endCursor であるため、どちらの値も after として使用できます。hasNextPage が false の場合、または返されたページの edges 配列が空の場合に停止しますが、ページの区切りが最も古いレビューとちょうど一致すると、その後に最後の空ページが 1 つ返されるため、両方の条件を確認してください。responseStatus=["PENDING"] を追加すると、オーナーからの返信をまだ待っているレビューのみを表示でき、ratingFilters=[1,2] を追加すると、低評価のレビューを優先的に確認できます。各 node の id はインタラクションに返信に渡す値で、canRespond はそのソースがオーナーからの返信を受け付けるかどうかを示します。
ユースケース:増分同期
ローカルのミラーを同期した状態に保つには、startDate/endDate でフィルタリングし、sortOrder=["NEWEST_FIRST"] で並べ替えて、これまでに取得した date の最大値を永続化します。このエンドポイントにはページネーションとレート制限があることに注意し、429 が返された場合は Retry-After ヘッダーに従い、実行のたびに履歴全体を再取得することは避けてください。
Google Maps と Facebook はすべてのプランで利用できます。Yelp は Growth プランと Enterprise プランで利用できます。JSON エンコードされたフィルター(siteUrls、categories、ratingFilters、responseStatus、sortOrder)は、URL エンコードされた JSON 文字列として渡します。
curl -X GET 'https://listingsapi.com/api/v4/locations/<locationId>/reviews' \ -H "Authorization: API $LISTINGSAPI_KEY"