Skip to content

Retrieve

Get a list of ratings sorted by date (most recent first).

GET /1.0/ratings.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

language string

Language in ISO-639-1 format

offset int

Offset of returned ratings. For example: an offset 10 would result in the 10 newest ratings to be excluded.

limit int

The maximum amount of returned ratings. The range of the variable is 1-100.

Example response

{
    "status": "success",
    "message": "Ratings successfully retrieved!",
    "total": 2,
    "ratings": [
        {
            "name": "J. Doe",
            "email": "john.doe@example.com",
            "rating": 4, // Ratings scale 1-5
            "ratings": {
                "shippingtime": 5,
                "customerservice": 3,
                "pricequality": 4,
                "aftersale": 4
            },
            "comment": "Great product, very nice webshop!",
            "date": "2016-02-14",
            "country": "GB",
            "language": "en",
            "created": "2016-02-14 19:08:00",
            "read": false,
            "quarantine": false,
            "verified": false,
            "reaction": "Thank you for the nice words!"
        },
        {
            "name": "Jane Doe",
            "email": "jane.doe@example.com",
            "rating": 1,
            "ratings": {
                "shippingtime": 1,
                "customerservice": 2,
                "pricequality": 4,
                "aftersale": 1
            },
            "comment": null,
            "date": "2016-02-12",
            "country": "NL",
            "language": "nl",
            "created": "2016-02-12 12:34:12",
            "read": true,
            "quarantine": true,
            "verified": true,
            "reaction": ""
        }
    ]
}

Response statuses

status message Explanation
success Ratings 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';
$language = 'nl';
$offset = 0;
$limit = 10;

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

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