Setup
To use the Reviews API, install the @wix/reviews
package using npm or Yarn:
1npm install @wix/reviews
or
1yarn add @wix/reviews
Then import { reviews }
from @wix/reviews
:
1import { reviews } from '@wix/reviews'
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Creates a review.
The createReview()
function returns a promise that resolves to the created review.
This function requires a contactId
.
If the review author does not have a contact ID, use createReviewAndContact()
.
If authorName
is left empty, the member's name will be used. If the author is not a member, the field is left null
.
Permission Scopes
For app development, you must have one of the following permission scopes:function createReview(review: Review): Promise<Review>
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Deletes a review.
The deleteReview()
function returns a promise that resolves to the deleted review.
Permission Scopes
For app development, you must have one of the following permission scopes:function deleteReview(reviewId: string): Promise<DeleteReviewResponse>
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves a review.
The getReview()
function returns a Promise that resolves to the retrieved review.
By default, an unpublished review is not returned. To retrieve an unpublished review, pass returnPrivateReviews
as true
.
Permission Scopes
For app development, you must have one of the following permission scopes:function getReview(reviewId: string, options: GetReviewOptions): Promise<Review>
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Creates a query to retrieve a list of reviews.
The queryReviews()
function builds a query to retrieve a list of reviews and returns a ReviewsQueryBuilder
object.
The returned object contains the query definition, which is typically used to run the query using the find()
function.
You can refine the query by chaining ReviewsQueryBuilder
functions onto the query.
ReviewsQueryBuilder
functions enable you to sort, filter,
and control the results that queryReviews()
returns.
The queryReviews()
function runs with the following defaults, which you can override:
ascending("_createdDate")
limit(100)
The functions that are chained to queryReviews()
are applied in the order they're called. For example, if you apply descending("_createdDate")
and then descending("content.rating")
, the results are sorted first by the _createdDate
, and then, if there are multiple results with the same _createdDate
, the items are sorted by content.rating
.
PROPERTY | SUPPORTED FILTERS & SORTING |
---|---|
namespace | eq() ,ne() ,in() |
_id | eq() ,ne() ,in() |
content.rating | eq() ,ne() ,in() ,lt() ,le() ,gt() ,ge() ,ascending() ,descending() |
_createdDate | eq() ,ne() ,in() ,lt() ,le() ,gt() ,ge() ,ascending() ,descending() |
helpfulness | eq() ,ne() ,in() ,lt() ,le() ,gt() ,ge() ,ascending() ,descending() |
moderation.moderationStatus | eq() ,ne() ,in() |
verified | eq() ,ne() ,ascending() ,descending() |
origin.type | eq() ,ne() ,ascending() ,descending() |
relevanceScore | eq() ,ne() ,in() ,lt() ,le() ,gt() ,ge() ,ascending() ,descending() |
Permission Scopes
For app development, you must have one of the following permission scopes:function queryReviews(options: QueryReviewsOptions): ReviewsQueryBuilder
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Updates a review.
The updateReview()
function returns a promise that resolves to the updated review.
Each time the review is updated, revision
increments by 1. The existing revision
must be included
when updating the review. This ensures you're working with the latest review information, and it prevents unintended overwrites.
This function is not a universal function and runs only on the backend.
Permission Scopes
For app development, you must have one of the following permission scopes:function updateReview(_id: string, review: UpdateReview): Promise<Review>