Skip to content

Retrieve JSON

Retrieve a list of product reviews in JSON format.

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

Filter reviews by specific product ID

offset int

Get only reviews after the given offset. (e.g. you have 15 results, with offset 10 you will get the last 5)

limit int

Limit the number of results you receive. (e.g. you have 100 reviews, with limit 50, you will see 50 of your 100 reviews)

with_media boolean

Include the photos and videos attached to each review in a media field. Default false

Example response

{
    "total": 1,
    "product_reviews": [
        {
            "id": 1,
            "reviewer": {
                "name": "John Doe",
                "email": "example@email.com"
            },
            "rating": 5,
            "review": "Example review text",
            "translations": {
                "de": "Beispiel Bewertungstext",
                "fr": "Exemple de texte d'avis"
            },
            "product_id": "1",
            "order_number": "order123",
            "language": "nl",
            "deleted": false,
            "created": "2022-03-11 09:13:50",
            "media": [
                {
                    "id": 12,
                    "slot": 1,
                    "type": "image/jpeg",
                    "url": "https://example.com/photo.jpg",
                    "poster_url": null
                },
                {
                    "id": 13,
                    "slot": 1,
                    "type": "video/mp4",
                    "url": "https://example.com/video.mp4",
                    "poster_url": "https://example.com/video-poster.jpg"
                }
            ]
        }
    ]
}

translations contains the available translations of review, keyed by language in ISO-639-1 format. It is an empty array when the review has no translations.

media is only present when with_media is passed. It lists the photos and videos attached to the review, with images first, each ordered by slot. type is the MIME type of the file. poster_url is a preview image for videos once it has been generated, and null otherwise. It is an empty array when the review has no media.

Example code

<?php

$id = 1;
$code = '123456789abc123456789';
$offset = 10;
$limit = 10;

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

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

$response = curl_exec($curl);

if ($response !== false) {
    $data = json_decode($response, true);
} else {
    // An error occurred
}