Retrieving Review Data

On this page:

  • Import reviews in your own system infrastructure
  • Call the Reviews API
  • Connect the API response data

If you want to connect review data to your own system infrastructure, you can access them directly via API call. This facilitates evaluation and analysis processes.

Step: Call the Customer Reviews API

Once your customers have written some reviews, they are accessible via the Reviews API.

Call the API via GET like so:

``` php tab="PHP" <?php

$curl = curl_init();

curl_setopt_array($curl, array( CURLOPT_URL => "https://api.etrusted.com/reviews", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_POSTFIELDS => "", CURLOPT_HTTPHEADER => array( "Authorization: Bearer {access_token}", "Content-Type: application/json", "cache-control: no-cache" ), ));

$response = curl_exec($curl); $err = curl_error($curl);

curl_close($curl);

if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }

!!! Note
    Make sure that you replace `{access_token}` with your actual access token. See [authentication](https://developers.etrusted.com/etrusted-api.html#section/Authentication).

    You may apply various filters to your `GET` call.
    Most importantly you can query *eTrusted* for reviews in specific channels.
    See our API documentation how to do that.

If the `GET` call succeeded, you should have a response that looks like this:

``` json
{
    "totalElements": 1,
    "paging": {
        "count": 1,
        "cursor": {
            "before": "rev-xxxxxxxx-yyyy-xxxx-yyyy-xxxxxxxxxxxx",
            "after": "rev-xxxxxxxx-yyyy-xxxx-yyyy-xxxxxxxxxxxx"
        },
        "links": {
            "previous": "https://api.etrusted.com/channels/{channelId}/customer-reviews?count=1&before=rev-xxxxxxxx-yyyy-xxxx-yyyy-xxxxxxxxxxxx",
            "next": "https://api.etrusted.com/channels/{channelId}/customer-reviews?count=1&after=rev-xxxxxxxx-yyyy-xxxx-yyyy-xxxxxxxxxxxx"
        }
    },
    "items": [
        {
            "_object": "CustomerReview",
            "id": "rev-xxxxxxxx-yyyy-xxxx-yyyy-xxxxxxxxxxxx",
            "accountRef": "acc-xxxxxxxx-yyyy-xxxx-yyyy-xxxxxxxxxxxx",
            "channelRef": "chl-xxxxxxxx-yyyy-xxxx-yyyy-xxxxxxxxxxxx",
            "rating": 4.0,
            "title": "Great experience",
            "comment": "Everything went well. Very helpful staff!",
            "createdAt": "2018-02-01T17:09:41.790Z",
            "updatedAt": "2018-02-01T17:09:41.790Z",
            "submittedAt": "2018-02-01T17:09:41.790Z",
            "state": "DRAFT",
            "type": "SERVICE_REVIEW",
            "inviteRef": "inv-xxxxxxxx-yyyy-xxxx-yyyy-xxxxxxxxxxxx",
            "customer": {
                "fullName": "John Doe",
                "email": "john.doe@example.com",
                "mobile": "+123456789"
            },
            "transaction": {
                "reference": "ORDER-12792",
                "date": "2018-01-04T12:09:50.722Z"
            },
            "event": {
                "id": "evt-xxxxxxxx-yyyy-xxxx-yyyy-xxxxxxxxxxxx",
                "type": "checkout"
            },
            "questionnaire": {
                "id": "qre-xxxxxxxx-yyyy-xxxx-yyyy-xxxxxxxxxxxx",
                "locale": "de_DE",
                "templateRef": "qrt-xxxxxxxx-yyyy-xxxx-yyyy-xxxxxxxxxxxx"
            }
        }
    ]
}

Step: Connect the API Response Data

If you want to display the response data in a frontend, use the predefined pagination cursor that eTrusted included in the response of Customer Reviews API calls. See our article on paginating response data for details.

If there is no frontend, you may want to connect the JSON response data with your system directly, e.g. import the list of reviews in your data backend. There will be sample connector tutorials in the future that will cover this topic.