Skip to content

Retrieve summary

Get a summary of all ratings.

GET /1.0/ratings_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

Example response

{
    "status": "success",
    "message": "Rating summary successfully retrieved!",
    "data": {
        "amount": 26,
        "rating_average": 8.389092, // Ratings scale 1-10
        "ratings_average": {
            "shippingtime": 0,
            "customerservice": 0,
            "pricequality": 0,
            "aftersale": 0
        }
    }
}

rating_average is on a scale of 1 to 10, unlike the ratings of individual reviews, which are on a scale of 1 to 5. Divide it by 2 to show it as stars. amount and rating_average are 0 when there are no ratings.

amount and rating_average include the reviews collected through Trustprofile and the ratings from external review platforms that are enabled for your webshop. Every review counts equally: the score of each source is weighted by its number of reviews. Reviews collected through Trustprofile are not included when your webshop hides them or your package does not include reviews.

The scores in ratings_average are no longer collected or updated. Older webshops return the last scores that were calculated, on a scale of 1 to 5. All other webshops return 0.

Response statuses

status message Explanation
success Ratings 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 Trustprofile. An unexpected error has occurred. This will probably only be solvable by the Trustprofile team.

Example code

<?php

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

$curl = curl_init(
    sprintf(
        'https://dashboard.trustprofile.com/api/1.0/ratings_summary.json?id=%s&code=%s',
        $id,
        $code,
    ),
);

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" => "Ratings summary successfully retrieved!",
        "data" => See example
    ];
    */
} else {
    // An error occurred
}