Trust Vega API (1.0)

This is a JSON based REST API.

This means that resources are represented as JSON dictionaries and you use a different HTTP verb to do your standard CRUD operations on them:

GET Retrieve a resource
POST Create a new resource
PATCH Update a resource
PUT Replace a resource entirely
DELETE Delete a resource

Not all verbs are supported by each endpoint.


Get Reviews

Endpoint:
GET https://app.trustvega.com/api/v1.0/reviews/
Parameters:
Name Description
campaign
Integer
Campaign ID from the "Display Reviews" page of your account.
Required
page
Integer (default: 0)
Page to return.
Optional
per_page
Integer (max: 200, default: 10)
Reviews to return per page.
Optional
featured
Bool (default: 0)
Restrict response to just featured reviews.
Optional
tags
Integer CSV
Restrict response to reviews tagged with any these Tag IDs.
Optional
Example:
$url = 'https://app.trustvega.com/api/v1.0/reviews/';
$params = array(
  'campaign' => 123456,
  'per_page' => 2,
  'page'     => 0,
  'featured' => 0,
  'tags'     => '2,5,14'
);
$query_string = http_build_query($params);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . '?' . $query_string);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$json = json_decode($response, true);

if ($json) {
  // Average rating
  echo $json['campaign']['average_rating'];

  // Iterate reviews
  foreach($json['reviews'] as $review){
    echo $review['title'];
  }
} else {
  // Something went wrong
}
Return Success:
{
  "powered_by": "https://www.trustvega.com/",
  "campaign": {
    "name": "Business Name",
    "url": "https://www.example.com",
    "telephone": "01632 123456",
    "street_address": "1600 Amphitheatre Parkway",
    "address_locality": "Mountain View",
    "address_region": "CA",
    "postal_code": "94043",
    "address_country": "US",
    "price_range": "$-$$$",
    "image": "https://app.trustvega.com/example-logo.jpg",
    "average_rating": "4.92",
    "rating_count": "24",
    "review_count": "11"
  },
  "total_pages": 2,
  "current_page": 0,
  "per_page": 2,
  "reviews": [
    {
      "displayname": "John D",
      "is_verified": true,
      "is_featured": true,
      "rating": "5.00",
      "title": "What a fantastic business!",
      "text": "This was the best experience of my life",
      "reply": "",
      "image": "https://app.trustvega.com/abc123.jpg",
      "created": "2017-07-14T19:09:41Z"
    },
    {
      "displayname": "Jane Doe",
      "is_verified": true,
      "is_featured": true,
      "rating": "4.00",
      "title": "Generally very good",
      "text": "I achieved my goals in 4 sessions, but the chair was uncomfortable",
      "reply": "Thanks for the feedback - chair fixed!",
      "image": "",
      "created": "2017-08-07T10:29:02Z"
    }
  ],
  "generated": "2018-11-29T17:00:18Z"
}
Return Error:
{
  "error" : {
    "message" : "Invalid parameters",
    "code"    : "400",
    "type"    : "BadRequestError"
  }
}
Return Codes:
Code Description
200 Success
400 Bad Request (Invalid or missing parameters)
403 Forbidden (Campaign does not have API access)
404 Not found (Campaign no longer active)
500 Internal Server Error (Uh oh...)

Create A Review Request

Endpoint:
POST https://app.trustvega.com/api/v1.0/reviews/
Parameters:
Name Description
campaign
Integer
Campaign ID from the "Display Reviews" page of your account.
Required
key
String
API key from the "Display Reviews" page of your account.
Required
firstname
String (max: 255)
Customer's first name.
Required
lastname
String (max: 255)
Customer's last name.
Required
email
String (max: 160)
Customer's email address.
Required
delay
Integer
Days to delay first reminder email.
Optional. Default: 0
tags
Integer CSV
Tag IDs from the Reviews > Tags area of your account to set.
Optional
Example:
$url = 'https://app.trustvega.com/api/v1.0/reviews/';
$params = array(
  'campaign'  => 123456,
  'key'       => 'G7RvF0LHRSlBf5dNFqJmvyeXkbOawI9U',
  'firstname' => 'John',
  'lastname'  => 'Doe',
  'email'     => '[email protected]',
  'delay'     => 0,
  'tags'      => '2,5,14'
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = json_decode(curl_exec($ch), true);

if (isset($response['error'])) {
  // Error
  $code    = $response['error']['code'];
  $message = $response['error']['message'];
  echo "Error $code: $message";
}
else if (isset($response['success'])) {
  // Success
  $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  echo "OK Status: $status";
}
else {
  // Something went wrong
}
Return Success:
{
  "success": true,
}
Return Error:
{
  "error" : {
    "message" : "Required data missing.",
    "code"    : "400",
    "type"    : "BadRequestError"
  }
}
Return Codes:
Code Description
200 Success (Review request previously created)
201 Success (Review request created)
400 Bad Request (Invalid or missing parameters)
403 Forbidden (Invalid API Key / No API access)
404 Not found (Campaign no longer active)
500 Internal Server Error (Uh oh...)

Powered by Trust Vega