Product collections

Get the average star rating score, sentiment, sentiment change, and reviews sentiment distribution for specific product collections in your store.

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…

Get rating and sentiment metrics for product collections in your store to compare review feedback across collections.

PropertyValue
MethodPOST
Path/insights/v1/topics/products
Full URLhttps://api.yotpo.com/insights/v1/topics/products
API versionv1
Request and success response formatapplication/json
AuthenticationAuthorization: Bearer YOUR_ACCESS_TOKEN
Path and query parametersNone defined; send inputs in the JSON body
📘

Authentication and request format

Authenticate with Authorization: Bearer YOUR_ACCESS_TOKEN. The Insights API does not accept the X-Yotpo-Token header.

Send filters inside the filter object, pagination inside paging and sorting inside sorting. Fields sent at the top level of the body are ignored.

Send a request

PrerequisiteAction
Access tokenGenerate a token using Yotpo Authentication.
Store IDFind your app key (the identifier for your store).
Collection and topicChoose a collection name from your Yotpo product catalog and a topic to analyze, such as quality.
  1. Set Authorization: Bearer YOUR_ACCESS_TOKEN and Content-Type: application/json.
  2. Add your store ID to filter.app_key and topic names to filter.topics.
  3. Add collection names to filter.product_collections to scope the analysis to those collections.
  4. Send the request to https://api.yotpo.com/insights/v1/topics/products.

The following example uses the collection, topic, and date range supplied in the endpoint specification. Replace the token, store ID, and collection name with your own values.

curl --request POST \
  --url 'https://api.yotpo.com/insights/v1/topics/products' \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "filter": {
      "app_key": "YOUR_STORE_ID",
      "topics": ["quality"],
      "product_collections": ["Cool Watches"],
      "date_range": {
        "start_date": "2018-01-11T00:00:00.000Z",
        "end_date": "2018-11-12T00:00:00.000Z"
      },
      "minimum_score": 4,
      "exclude_unpublished": false
    },
    "paging": {
      "page": 0,
      "per_page": 10
    },
    "sorting": {
      "sorting_field": "yotpo_default_sorting"
    }
  }' \
  --include \
  --fail-with-body

Expect HTTP 200 with the JSON structure shown under Response example. With --fail-with-body, curl returns a nonzero exit status for HTTP errors while retaining the response body. Check the status before processing the body; a 401 body is plain text, not JSON.

Request body

FieldTypeRequiredDescription and default
filterobjectYesContains the store ID, topics, and review filters.
pagingobjectNoControls pagination. If omitted, the API returns up to 25 results.
sortingobjectNoControls result ordering. The default ordering is not specified.

Only filter is required at the top level. Within it, app_key and topics are required. Other fields are optional. Unless stated below, the specification does not define a default, length limit, or array-size limit.

Required filter fields

FieldTypeRequiredDescriptionExample
filter.app_keystringYesYour store ID (app key)."YOUR_STORE_ID"
filter.topicsarray of stringsYesTopic names to include.["quality"]

The specification requires topics but does not define whether an empty array is accepted. Supply the topic names you want to analyze.

Optional: Filter reviews

FieldTypeRequiredDescription and constraintsExample
filter.date_rangeobjectNoDate range for the reviews to analyze.See child fields below.
filter.date_range.start_datestringNoRange start in ISO 8601 date-time format."2018-01-11T00:00:00.000Z"
filter.date_range.end_datestringNoRange end in ISO 8601 date-time format."2018-11-12T00:00:00.000Z"
filter.locationobjectNoFilters by reviewer location.See child fields below.
filter.location.countriesarray of stringsNoTwo-letter reviewer country codes. See the country code list.["US"]
filter.location.statesarray of stringsNoReviewer state codes. See the state code list.["CA"]
filter.external_product_idsarray of stringsNoProduct IDs (domain keys or SKUs) to include.["2063374417974"]
filter.product_groupsarray of stringsNoProduct group names as defined in your Yotpo product catalog.Use your catalog's group names.
filter.product_collectionsarray of stringsNoProduct collection names as defined in your Yotpo product catalog.["Cool Watches"]
filter.minimum_scoreintegerNoMinimum star rating, from 1 through 5.4
filter.exclude_unpublishedbooleanNoSet to true to exclude unpublished reviews. No default is specified.false

Optional: Paginate and sort

FieldTypeRequiredDescription and constraintsExample
paging.pageintegerNoZero-based page number; minimum 0. No default is specified.0
paging.per_pageintegerNoResults per page; minimum 1. No maximum or per-field default is specified. Omitting the entire paging object returns up to 25 results.10
sorting.sorting_fieldstringNoOne of yotpo_default_sorting, sentiment_score, average_star_rating, positive_reviews, or negative_reviews. yotpo_default_sorting combines sentiment score and number of opinions."yotpo_default_sorting"
sorting.sorting_directionstringNoCase-sensitive: ASC or DESC. Does not apply to yotpo_default_sorting."ASC"

Responses

StatusMeaningAction
200Successful request. Returns collection metrics and pagination metadata.Read product_collections and use paging to determine whether to request another page.
400Bad request. The documented example is {}; no error fields are defined.Check required fields, nesting, types, rating bounds, and sorting values before retrying.
401Missing or invalid bearer token. The body is the plain string unauthorized.Check the Authorization header and generate a valid token if necessary. Do not use X-Yotpo-Token.

These are the status codes defined in the endpoint specification. It does not define additional error codes or error-body formats.

Response fields

FieldTypeDescription
product_collectionsarray of objectsCollection metrics returned by the request. Handle an empty array without assuming a first result exists.
product_collections[].product_collectionsstringCollection name.
product_collections[].average_star_ratingnumberAverage star rating for the collection.
product_collections[].sentiment_scorenumberCollection sentiment score. The specification does not define its scale or calculation.
product_collections[].sentiment_changeobjectSentiment change value and associated error string.
product_collections[].sentiment_change.valuenumberSentiment change value. The comparison period and calculation are not defined in the specification.
product_collections[].sentiment_change.errorstringError information associated with sentiment change; empty in the success example.
product_collections[].positive_reviewsintegerCount of positive reviews.
product_collections[].negative_reviewsintegerCount of negative reviews.
product_collections[].neutral_reviewsintegerCount of neutral reviews.
product_collections[].reviews_countintegerReview count returned for the collection.
product_collections[].products_in_collectionarray of objectsProducts in the collection.
product_collections[].products_in_collection[].product_idstringProduct identifier.
product_collections[].products_countintegerNumber of products in the collection.
pagingobjectPagination metadata.
paging.pageintegerCurrent page number, starting at 0.
paging.page_countintegerTotal number of pages.
paging.per_pageintegerResults per page.
paging.totalintegerTotal number of results.

The response schema does not mark fields as required. Check that a field is present before reading it, and treat a nonempty sentiment_change.error as information to inspect rather than assuming the change value is usable.

Response example

PropertyValue
Status200
Content typeapplication/json
Example scopeOne result per page, as supplied in the specification; this is separate from the request example's per_page: 10.
{
  "product_collections": [
    {
      "product_collections": "Cool Watches",
      "average_star_rating": 4.882443928847641,
      "sentiment_score": 85.60082,
      "sentiment_change": {
        "value": 0.29634076789936614,
        "error": ""
      },
      "positive_reviews": 3418,
      "negative_reviews": 77,
      "neutral_reviews": 406,
      "reviews_count": 3903,
      "products_in_collection": [
        { "product_id": "1850285" },
        { "product_id": "10228864" },
        { "product_id": "24857299" },
        { "product_id": "24857295" },
        { "product_id": "35392356" },
        { "product_id": "35787751" }
      ],
      "products_count": 6
    }
  ],
  "paging": {
    "page": 0,
    "page_count": 6,
    "per_page": 1,
    "total": 6
  }
}

Error examples

StatusBody formatDefined error fields
400JSON objectNone
401Plain textNot applicable

HTTP 400:

{}

HTTP 401:

unauthorized

Rate limits and troubleshooting

Response headerTypeMeaning
ratelimit-limitintegerMaximum requests allowed in the current time window.
ratelimit-remainingintegerRequests remaining in the current time window.
ratelimit-resetintegerSeconds until the rate limit resets.
x-ratelimit-limit-minuteintegerMaximum requests allowed per minute.
x-ratelimit-remaining-minuteintegerRequests remaining in the current minute.

The specification defines these headers for 200 and 400 responses, but does not specify fixed quota values or a rate-limit error response. Monitor the returned values instead of hard-coding a quota. When ratelimit-remaining reaches 0, pause requests for the number of seconds in ratelimit-reset; also pace requests to avoid exhausting the per-minute allowance.

  • Filters appear to have no effect: Move filter fields under filter. Keep pagination under paging and sorting under sorting; flat fields are ignored.
  • The API returns 400: Include filter.app_key and filter.topics. Check ISO 8601 dates, minimum_score from 1 to 5, paging.page of at least 0, and paging.per_page of at least 1.
  • The API returns 401: Send the token in Authorization: Bearer YOUR_ACCESS_TOKEN. Follow Yotpo Authentication to obtain a valid token.
  • Sort direction has no effect: sorting_direction does not apply to yotpo_default_sorting. For other sorting fields, use uppercase ASC or DESC.
  • No collections are returned: Handle the empty result without indexing into it, then check your catalog collection names and review filters.
Body Params
filter
object
required

Filters for the request. app_key is required.

paging
object

Pagination. If omitted, up to 25 results are returned.

sorting
object

Sorting options.

Responses

401

Missing or invalid bearer token. The body is the plain string unauthorized.

Language
Credentials
Bearer
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json