This article intends to show how to import reviews collected by Trustvox through API.
The reviews can be used in:
Product pages
Shelfs
Email marketing
Whenever you see it's a good place to display customer reviews.
Request Header required fields
In order to make a proper request, the header should have the following fields:
CurrentStoreId: Your store ID
Authorization: Bearer token
Each company has it's own store ID and token. Both are provided by Trustvox.
Get all products in Trustvox
You can use this endpoint to query all the products that your company has on Trustvox:
Endpoint: https://api.trustvox.com.br/products
HTTP Method: GET
cURL Example
Suppose you want to query all products Trustvox has in order to get each product review:
curl --request GET \
--url https://api.trustvox.com.br/products \
--header 'Authorization: Bearer YourAuthorizationToken' \
--header 'Cache-Control: no-cache' \
--header 'CurrentStoreId: YourStoreID'
Gives your the following response:
{
"data": [
{
"id": "15096921",
"type": "products",
"attributes": {
"code": null,
"name": "My main product ",
"created_at": "2017-10-11T23:46:09.000Z",
"average_rate": "0.0",
"photo_url": "https://s3.trustvox.com.br/trustvox-core-production-uploads/uploads/product/photo/15096921/",
"has_photo": false,
"current_url": null
},
"relationships": {
"store": {
"data": {
"id": "100",
"type": "stores"
}
},
"sale_items": {
"data": []
},
"current_url": {
"data": {
"id": "20015769",
"type": "product_urls"
}
}
}
}
],
"meta": {
"current_page": 1,
"next_page": 2,
"prev_page": null,
"total_pages": 5030,
"total_count": 125742
}
}
Get reviews from a specific product
You can use this endpoint to query opinions for a specific product:
Endpoint: https://api.trustvox.com.br/products
HTTP Method: GET
code: Your product code (As Trustvox keeps your product code, you can query using it)
cURL Example
Suppose you want to query reviews about product with code 500021
curl --request GET \
--url https://api.trustvox.com.br/products/code/500021/profile?include=opinions \
--header 'Authorization: Bearer YourAuthorizationToken' \
--header 'Cache-Control: no-cache' \
--header 'CurrentStoreId: YourStoreID'
{
"data": {
"id": "15059031",
"type": "product_profile",
"attributes": {
"code": "500021",
"name": "Barra de Supino Polimet com Presilhas - 1,20 M",
"created_at": "2017-10-11T23:30:09.000Z",
"average_rate": "4.8",
"photo_url": "https://s3.trustvox.com.br/trustvox-core-production-uploads/uploads/product/photo/15059031/barra-de-supino-polimet-com-presilhas-1-20-m-img.jpg",
"has_photo": true,
"current_url": "https://www.storeurl.com.br/storeproduct.html",
"last_price": 50,
"opinions_total": 6,
"opinions_with_rate_total": 3,
"sales_total": 69,
"questions_total": 0,
"opinions_with_text": 3,
"opinions_with_answer": 0,
"opinions_without_answer": 6,
"questions_with_answer": 0,
"questions_without_answer": 0,
"public_answers": 0,
"private_answers": 0,
"reported_questions": 0,
"history_chart": [
[
1446336000000,
"4.0"
],
[
1512086400000,
"4.5"
],
[
1514764800000,
"5.0"
],
[
1517443200000,
"5.0"
],
[
1525132800000,
"5.0"
]
],
"sell_rate": 0.003290647122448318
},
"relationships": {
"store": {
"data": {
"id": "100",
"type": "stores"
}
},
"sale_items": {
"data": [
{
"id": "202010983",
"type": "sale_items"
},
{
"id": "203626816",
"type": "sale_items"
},
{
"id": "203811199",
"type": "sale_items"
},
{
"id": "204011437",
"type": "sale_items"
},
{
"id": "204016201",
"type": "sale_items"
},
{
"id": "204467089",
"type": "sale_items"
},
{
"id": "204498691",
"type": "sale_items"
},
{
"id": "204528385",
"type": "sale_items"
},
{
"id": "204608815",
"type": "sale_items"
},
{
"id": "204879514",
"type": "sale_items"
},
{
"id": "205167118",
"type": "sale_items"
},
{
"id": "205228219",
"type": "sale_items"
},
{
"id": "205594792",
"type": "sale_items"
},
{
"id": "206736178",
"type": "sale_items"
},
{
"id": "206805406",
"type": "sale_items"
},
{
"id": "206854600",
"type": "sale_items"
},
{
"id": "207024166",
"type": "sale_items"
},
{
"id": "207170074",
"type": "sale_items"
},
{
"id": "207303502",
"type": "sale_items"
},
{
"id": "208213933",
"type": "sale_items"
},
{
"id": "208235758",
"type": "sale_items"
},
{
"id": "208283296",
"type": "sale_items"
},
{
"id": "208362571",
"type": "sale_items"
},
{
"id": "208423171",
"type": "sale_items"
},
{
"id": "208508659",
"type": "sale_items"
},
{
"id": "208716394",
"type": "sale_items"
},
{
"id": "208731205",
"type": "sale_items"
},
{
"id": "209170189",
"type": "sale_items"
},
{
"id": "209798998",
"type": "sale_items"
},
{
"id": "212446081",
"type": "sale_items"
},
{
"id": "215590513",
"type": "sale_items"
},
{
"id": "217797427",
"type": "sale_items"
},
{
"id": "218905972",
"type": "sale_items"
},
{
"id": "218980018",
"type": "sale_items"
},
{
"id": "219889963",
"type": "sale_items"
},
{
"id": "223540483",
"type": "sale_items"
},
{
"id": "227366726",
"type": "sale_items"
},
{
"id": "228394013",
"type": "sale_items"
},
{
"id": "228417089",
"type": "sale_items"
},
{
"id": "228490076",
"type": "sale_items"
},
{
"id": "229179523",
"type": "sale_items"
},
{
"id": "229704983",
"type": "sale_items"
},
{
"id": "229711817",
"type": "sale_items"
},
{
"id": "229763071",
"type": "sale_items"
},
{
"id": "231155000",
"type": "sale_items"
},
{
"id": "231171282",
"type": "sale_items"
},
{
"id": "231195044",
"type": "sale_items"
},
{
"id": "232661296",
"type": "sale_items"
},
{
"id": "233043166",
"type": "sale_items"
},
{
"id": "233901346",
"type": "sale_items"
},
{
"id": "236279934",
"type": "sale_items"
},
{
"id": "238960788",
"type": "sale_items"
},
{
"id": "241332411",
"type": "sale_items"
},
{
"id": "242319921",
"type": "sale_items"
},
{
"id": "244001547",
"type": "sale_items"
},
{
"id": "244616001",
"type": "sale_items"
},
{
"id": "245278796",
"type": "sale_items"
},
{
"id": "245425808",
"type": "sale_items"
},
{
"id": "245433461",
"type": "sale_items"
},
{
"id": "246265368",
"type": "sale_items"
},
{
"id": "255940718",
"type": "sale_items"
},
{
"id": "257230961",
"type": "sale_items"
},
{
"id": "262264986",
"type": "sale_items"
},
{
"id": "262291664",
"type": "sale_items"
},
{
"id": "264273328",
"type": "sale_items"
},
{
"id": "286233108",
"type": "sale_items"
},
{
"id": "292322382",
"type": "sale_items"
},
{
"id": "297306973",
"type": "sale_items"
},
{
"id": "297443117",
"type": "sale_items"
}
]
},
"current_url": {
"data": {
"id": "19977888",
"type": "product_urls"
}
},
"questions": {
"data": []
},
"urls": {
"data": [
{
"id": "19977888",
"type": "product_urls"
}
]
},
"tags": {
"data": [
{
"id": "394",
"type": "tags"
},
{
"id": "3165",
"type": "tags"
},
{
"id": "5265",
"type": "tags"
},
{
"id": "1309",
"type": "tags"
},
{
"id": "385",
"type": "tags"
},
{
"id": "717",
"type": "tags"
},
{
"id": "18886",
"type": "tags"
},
{
"id": "729",
"type": "tags"
}
]
},
"opinions": {
"data": [
{
"id": "5245483",
"type": "opinions"
},
{
"id": "5790793",
"type": "opinions"
},
{
"id": "5802550",
"type": "opinions"
},
{
"id": "6095508",
"type": "opinions"
},
{
"id": "6375973",
"type": "opinions"
},
{
"id": "7066802",
"type": "opinions"
}
]
}
}
},
"included": [
{
"id": "5245483",
"type": "opinions",
"attributes": {
"rate": 4,
"text": "The product I've ever used",
"created_at": "2015-11-02T09:09:33.000Z",
"third_party_id": 28056,
"is_third_party": true
},
"relationships": {
"store": {
"data": {
"id": "100",
"type": "stores"
}
},
"customer": {
"data": {
"id": "4133110",
"type": "customer"
}
},
"sale_item": {
"data": null
},
"product": {
"data": {
"id": "15059031",
"type": "products"
}
},
"sale": {
"data": null
}
}
},
{
"id": "5790793",
"type": "opinions",
"attributes": {
"rate": 4,
"text": null,
"created_at": "2017-12-09T16:50:08.000Z",
"third_party_id": null,
"is_third_party": false
},
"relationships": {
"store": {
"data": {
"id": "100",
"type": "stores"
}
},
"customer": {
"data": {
"id": "15806197",
"type": "customer"
}
},
"sale_item": {
"data": {
"id": "208283296",
"type": "sale_items"
}
},
"product": {
"data": {
"id": "15059031",
"type": "products"
}
},
"sale": {
"data": {
"id": "117628798",
"type": "sales"
}
}
}
},
{
"id": "5802550",
"type": "opinions",
"attributes": {
"rate": 5,
"text": "Excellent! I can use to go anywhere I want to",
"created_at": "2017-12-11T00:31:14.000Z",
"third_party_id": null,
"is_third_party": false
},
"relationships": {
"store": {
"data": {
"id": "100",
"type": "stores"
}
},
"customer": {
"data": {
"id": "2923501",
"type": "customer"
}
},
"sale_item": {
"data": {
"id": "208362571",
"type": "sale_items"
}
},
"product": {
"data": {
"id": "15059031",
"type": "products"
}
},
"sale": {
"data": {
"id": "117701683",
"type": "sales"
}
}
}
},
{
"id": "6095508",
"type": "opinions",
"attributes": {
"rate": 5,
"text": "It'll last forever!",
"created_at": "2018-01-11T10:45:11.000Z",
"third_party_id": null,
"is_third_party": false
},
"relationships": {
"store": {
"data": {
"id": "100",
"type": "stores"
}
},
"customer": {
"data": {
"id": "18717758",
"type": "customer"
}
},
"sale_item": {
"data": {
"id": "228394013",
"type": "sale_items"
}
},
"product": {
"data": {
"id": "15059031",
"type": "products"
}
},
"sale": {
"data": {
"id": "129152507",
"type": "sales"
}
}
}
},
{
"id": "6375973",
"type": "opinions",
"attributes": {
"rate": 5,
"text": null,
"created_at": "2018-02-12T20:09:03.000Z",
"third_party_id": null,
"is_third_party": false
},
"relationships": {
"store": {
"data": {
"id": "100",
"type": "stores"
}
},
"customer": {
"data": {
"id": "20719287",
"type": "customer"
}
},
"sale_item": {
"data": {
"id": "246265368",
"type": "sale_items"
}
},
"product": {
"data": {
"id": "15059031",
"type": "products"
}
},
"sale": {
"data": {
"id": "142461423",
"type": "sales"
}
}
}
},
{
"id": "7066802",
"type": "opinions",
"attributes": {
"rate": 5,
"text": null,
"created_at": "2018-05-08T10:54:05.000Z",
"third_party_id": null,
"is_third_party": false
},
"relationships": {
"store": {
"data": {
"id": "100",
"type": "stores"
}
},
"customer": {
"data": {
"id": "24212823",
"type": "customer"
}
},
"sale_item": {
"data": {
"id": "286233108",
"type": "sale_items"
}
},
"product": {
"data": {
"id": "15059031",
"type": "products"
}
},
"sale": {
"data": {
"id": "172916643",
"type": "sales"
}
}
}
}
]
}
In this response, you'll get:
The product itself
Average rate
All the reviews with rate, text.
You can use this info to use in your product page all the collected reviews in the way that you want it.