Glue API: Manage product reviews

Edit on GitHub

Ratings and reviews allow customers to share their opinions and experiences about purchases. This enables customers to take meaningful decisions about purchases and increases their trust with the shop.

Products and ratings API helps you to:

  • Retrieve average rating of any product.
  • Retrieve a list of ratings and reviews of a product.
  • Allow customers to review and rate products.

Installation

For detailed information on the modules that provide the API functionality and related installation instructions, see Install the Product Rating and Reviews Glue API

Retrieve product reviews

To retrieve product reviews, send the request:


GET /abstract-products/{{abstract_product_sku}}/product-reviews


PATH PARAMETER DESCRIPTION
{{abstract_product_sku}} Unique identifier of a product to retrieve product reviews for.

Request

STRING PARAMETER DESCRIPTION POSSIBLE VALUES
page[offset] Offset of the item at which to begin the response. From 0 to any.
page[limit] Maximum number of entries to return. From 1 to any.

Request sample: retrieve product ratings and reviews: GET http://glue.mysprykershop.com/abstract-products/035/product-reviews

Response

Response sample: retrieve product reviews
{
    "data": [
        {
            "type": "product-reviews",
            "id": "40",
            "attributes": {
                "rating": 3,
                "nickname": "Stephen Grumpy",
                "summary": "Not that awesome",
                "description": "The specs are good, but the build quality desires to be better."
            },
            "links": {
                "self": "http://glue.mysprykershop.com/product-reviews/40"
            }
        },
        {
           "type": "product-reviews",
           "id": "42",
           "attributes": {
                "rating": 5,
                "nickname": "John Doe",
                "summary": "Excellent product",
                "description": "Powerful processor, bright screen and beatiful design - what else do you need?"
        },
            "links": {
                "self": "http://glue.mysprykershop.com/product-reviews/42"
            }
        }
    ],
    "links": {
        "self": "http://glue.mysprykershop.com/abstract-products/139/product-reviews",
        "last": "http://glue.mysprykershop.com/abstract-products/139/product-reviews?page[offset]=10&page[limit]=10",
        "first": "http://glue.mysprykershop.com/abstract-products/139/product-reviews?page[offset]=0&page[limit]=10",
        "next": "http://glue.mysprykershop.com/abstract-products/139/product-reviews?page[offset]=10&page[limit]=10"
    }
}

RESOURCE ATTRIBUTE TYPE DESCRIPTIONS
product-reviews nickname String Customer’s nickname.
product-reviews rating Integer Rating given to the product by a customer.
product-reviews summary String Review summary.
product-reviews description String Full review.

Submit a product review

To submit a product review, send the request:


POST/abstract-products/{{product_sku}}/product-reviews


PATH PARAMETER HEADER
{{product_sku}} Unique identifier of an abstract product to post a rating and review for.

Request

HEADER KEY TYPE REQUIRED DESCRIPTION
Authorization string Alphanumeric string that authorizes the customer or company user to send requests to protected resources. Get it by authenticating as a customer or authenticating as a company user.

Request sample: provide a rating and a review of products

POST http://glue.mysprykershop.com/abstract-products/139/product-reviews

{
    "data": {
        "type": "product-reviews",
        "attributes": {
            "nickname": "John Doe",
            "rating": 5,
            "summary": "Excellent product",
            "description": "Powerful processor, bright screen, beautiful design and excellent build quality - what else do you need?"
        }
    }
}
RESOURCE ATTRIBUTE TYPE DESCRIPTIONS
product-reviews nickname String Customer’s nickname.
product-reviews rating Integer Rating given to the product by a customer.
product-reviews summary String Review summary.
product-reviews description String Full review.

Response

{
    "data": {
        "type": "product-reviews",
        "id": "42",
        "attributes": {
            "rating": 5,
            "nickname": "John Doe",
            "summary": "Excellent product",
            "description": "Powerful processor, bright screen, beautiful design and excellent build quality - what else do you need?"
        },
        "links": {
            "self": "http://glue.de.suite-nonsplit.local/product-reviews/42"
        }
    }
}
RESOURCE ATTRIBUTE TYPE DESCRIPTIONS
product-reviews nickname String Customer’s nickname.
product-reviews rating Integer Rating given to the product by a customer.
product-reviews summary String Review summary.
product-reviews description String Full review.

Other management options

You can retrieve the average rating of a product as follows:

Also, all the endpoints that accept abstract-products and concrete-products resources as included resources in requests, return the average product rating.

Possible errors

CODE REASON
001 Access token is invalid.
002 Access token is missing.
301 Abstract product with the specified ID was not found.
311 Abstract product ID is not specified.
901 One or more of the following reasons:
  • The nickname attribute is empty or not specified.
  • The rating attribute is empty or not specified.
  • The summary attribute is empty or not specified.

To view generic errors that originate from the Glue Application, see Reference information: GlueApplication errors.