Skip to content

Retrieve summary

Get the number of reviews and the average rating of a product.

GET /1.0/product_reviews_summary.json

Query parameters

They should be passed as query parameters to the URL. (ex.: ?id=1&code=abc)

id int (required)

The unique webshop ID.

code string (required)

Your personal API code.

public_code string (required)

* Use instead of code in case you want to fetch data with JavaScript

product_id string (required)

The ID of the product

Example response

{
    "status": "success",
    "message": "Product review summary successfully retrieved!",
    "data": {
        "product_id": "1",
        "amount": 12,
        "rating_average": 4.5 // Ratings scale 1-5
    }
}

amount and rating_average are 0 when the product has no reviews. When no product with this product_id is known for your webshop, status is error and message is Product not found.

Response statuses

status message Explanation
success Product review summary successfully retrieved!
error Not all obligated variables are set. One or more of the required variables (id, code) has/have not been set.
error Incorrect authentication credentials. The combination id and code is invalid.
error Unexpected error while processing. Please contact WebwinkelKeur. An unexpected error has occurred. This will probably only be solvable by the WebwinkelKeur team.

Example code

<?php

$id = 1;
$code = '123456789abc123456789';
$product_id = '1';

$curl = curl_init(
    sprintf(
        'https://dashboard.webwinkelkeur.nl/api/1.0/product_reviews_summary.json?%s',
        http_build_query([
            'id' => $id,
            'code' => $code,
            'product_id' => $product_id,
        ]),
    ),
);

curl_setopt_array($curl, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
]);

$response = curl_exec($curl);

if ($response !== false) {
    $data = json_decode($response, true);

    /*
    $data will look similar to the format below:

    $data = [
        "status" => "success",
        "message" => "Product review summary successfully retrieved!",
        "data" => See example
    ];
    */
} else {
    // An error occurred
}