Samples > Starter stores > Starter store enhancements > Social Commerce > WebSphere Commerce Dojo Enhancements API > Social Commerce services > REST API


Ratings and reviews

The Social Commerce Reviews widget uses the REST API to retrieve existing review content and create new reviews that are stored with the social content provider.

The Reviews widget uses the following methods:

GET

Used to retrieve reviews by item ID or user ID.

POST

Used to create a new review for an item.

REST API for ratings and reviews
HTTP method URI Description Data type Query parameters Authenticated user
GET /items/<itemId>/reviews Retrieves a list of reviews for a specified item. reviewData

  • pageSize

  • onPage

  • sortOptions

 
GET /users/<userId>/reviews Retrieves a list of reviews posted by a user. reviewData

  • pageSize

  • onPage

 
POST /items/<itemId>/reviews Posts a new review for an item. review  


Data types

The following table lists the data types contained in the REST API for the Reviews widget and provides a code snippet to illustrate each data type.
Data type Example
reviewData

reviewData
{
     1 "id":{ "type": "string" },     "ratingStatistics":{ "type": "ratingStatistics" },     "paginationDetails":{ "type":"paginationDetails" },     "reviews":{ "type": "array", "arrayType": "review" }
}

 1  The id depends on the context in which the GET request is made. If the GET request is used to retrieve a list of reviews for an item, itemId is used. If the GET request is used to retrieve a list of reviews posted by a specific user, userId is used.

ratingStatistics

{
    "numOfOverallRatings":{ "type": "integer" },     "ratingRange":{ "type": "ratingRange" },     "avgOverallRating":{ "type": "float" }
}

ratingRange

{
    "lowerBound":{ "type": "integer" },     "upperBound":{ "type": "integer" }
}

paginationDetails

{
    "noOfTotalEntries":{ "type": "integer" },     "noOfTotalPages":{ "type": "integer" },     "noOfEntriesPerPage":{ "type": "integer" },     "pageNum":{ "type": "integer" },     "sortType":{ "type": "string" },     "sortDirection":{ "type": "string" }
}

review

{
    "reviewId":{ "type": "integer" },     "itemId":{ "type": "string" },     "userId":{ "type": "string" },     "ItemDescription":{ "type": "string" },     "isRatingOnly":{ "type": "boolean" },     "title":{ "type": "string" },     "reviewText":{ "type": "string" },     "rating":{ "type": "float" },     "submissionTime":{ "type": "string" }, }

errorData

{
    "inputName":{ "type": "string" },     "required":{ "type": "boolean" },     "errorMsg":{ "type": "string" }
}


Query parameters

The following table lists and describes each of the query parameters contained in the REST API for the Reviews widget.
Name Type Range Description
pageSize integer [1,infinity) The number of reviews to display on each page.
onPage integer [1,infinity) The page of reviews to return.
sortOptions string Pattern: field1|direction,field2|direction The sorting options to use when retrieving reviews.

Notes:

  1. Valid values for field1,field2 are submissionTime and rating.

  2. Valid values for direction are asc and desc.

  3. BaazarVoice only supports sorting when retrieving a list of reviews for a specified item; it does not support sorting when retrieving a list of reviews posted by a specified user.

Related reference

Profiles

Blogs

Photo galleries

Search engine optimized (SEO) content

REST API


+

Search Tips   |   Advanced Search