Product reviews are an important part of Shopping experience for customers. These ratings and reviews help customers with product research and purchase decisions. Positive product reviews can drive more qualified customers to a seller's product pages. Sources include sellers, review aggregators, review sites, and Google users.
This page explains how you can manage product reviews using Merchant API.
Prerequisites
Google needs you to provide specific information. You must have the following:
- An active product review feed in the Google Merchant Center.
- Your account must be enrolled into the Product ratings program. If you are unsure whether you are already enrolled, check the Merchant Center. If you are not enrolled, learn more about enrolling into the product ratings program .
- To review products using Merchant API, submit a request using this form .
Create a data source
Use the datasource.create
API to create a product review feed. If an existing
product review feed is available, use accounts.dataSources.get
to fetch the accounts.dataSources.name
. The form of the request is as follows:
POST https://merchantapi.googleapis.com/datasources/v1beta/accounts/{account}/dataSources/{datasource}
Example
The example shows a typical request and response.
Request
POST https://merchantapi.googleapis.com/datasources/v1beta/accounts/123/dataSources {"displayName": "test api feed", "productReviewDataSource":{} }
Response
{
"name"
:
"accounts/123/dataSources/1000000573361824"
,
"dataSourceId"
:
"1000000573361824"
,
"displayName"
:
"test api feed"
,
"productReviewDataSource"
:
{},
"input"
:
"API"
}
For more information, see Create a product review data source .
Create product review
You can use the accounts.productreviews.insert
method to create or update a
product review. The accounts.productreviews.insert
method takes a productreview
resource and a data source name as input. It returns the new or
updated productreview
, if successful. To create a product review, you must
have a datasource.name
.
The form of the request:
POST https://merchantapi.googleapis.com/reviews/v1alpha/{parent=accounts/ {ACCOUNT_ID}
/}productReviews:insert
The following sample request illustrates how you can create a product review.
POST https://merchantapi.googleapis.com/reviews/v1alpha/accounts/ {ACCOUNT_ID}
/productReviews:insert?dataSource=accounts/ {ACCOUNT_ID}
/dataSources/ {DATASOURCE_ID}
productReviewId = 'my_product_review'
productReviewAttributes {
aggregatorName = 'aggregator_name'
subclientName = 'subclient_name'
publisherName = 'publisher_name'
publisherFavicon = 'https://www.google.com/favicon.ico'
reviewerId = 'reviewer_id'
reviewerIsAnonymous = false
reviewerUsername = 'reviewer_username'
reviewLanguage = 'en'
reviewCountry = 'US'
reviewTime = '2024-04-01T00:00:00Z'
title = 'Incredible product'
content = 'This is an incredible product.'
pros = ['pro1', 'pro2']
cons = ['con1', 'con2']
reviewLink = {
type = 'SINGLETON'
link = 'https://www.google.com'
}
reviewerImageLink = 'https://www.google.com/reviewer.png'
minRating = 1
maxRating = 10
rating = 8.5
productName = 'product_name'
productLink = 'https://www.google.com/product'
asins = ['asin1', 'asin2']
gtins = ['gtin1', 'gtin2']
mpns = ['mpn1', 'mpn2']
skus = ['sku1', 'sku2']
brands = ['brand1', 'brand2']
isSpam = false
collectionMethod = 'POST_FULFILLMENT'
transactionId = 'transaction_id'
}
After product review creation, it can take a few minutes for the review to propagate.
Here's a sample you can use to insert multiple product reviews asynchronously:
Java
import
com.google.api.gax.core.FixedCredentialsProvider
;
import
com.google.auth.oauth2.GoogleCredentials
;
import
com.google.shopping.merchant.reviews.v1beta.ListProductReviewsRequest
;
import
com.google.shopping.merchant.reviews.v1beta.ProductReview
;
import
com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceClient
;
import
com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceClient.ListProductReviewsPagedResponse
;
import
com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceSettings
;
import
shopping.merchant.samples.utils.Authenticator
;
import
shopping.merchant.samples.utils.Config
;
/** This class demonstrates how to list all the product reviews in a given account. */
public
class
ListProductReviewsSample
{
public
static
void
listProductReviews
(
String
accountId
)
throws
Exception
{
GoogleCredentials
credential
=
new
Authenticator
().
authenticate
();
ProductReviewsServiceSettings
productReviewsServiceSettings
=
ProductReviewsServiceSettings
.
newBuilder
()
.
setCredentialsProvider
(
FixedCredentialsProvider
.
create
(
credential
))
.
build
();
try
(
ProductReviewsServiceClient
productReviewsServiceClient
=
ProductReviewsServiceClient
.
create
(
productReviewsServiceSettings
))
{
ListProductReviewsRequest
request
=
ListProductReviewsRequest
.
newBuilder
()
.
setParent
(
String
.
format
(
"accounts/%s"
,
accountId
))
.
build
();
System
.
out
.
println
(
"Sending list product reviews request:"
);
ListProductReviewsPagedResponse
response
=
productReviewsServiceClient
.
listProductReviews
(
request
);
int
count
=
0
;
// Iterates over all rows in all pages and prints all product reviews.
for
(
ProductReview
element
:
response
.
iterateAll
())
{
System
.
out
.
println
(
element
);
count
++
;
}
System
.
out
.
print
(
"The following count of elements were returned: "
);
System
.
out
.
println
(
count
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
);
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Config
config
=
Config
.
load
();
listProductReviews
(
config
.
getAccountId
().
toString
());
}
}
Retrieve a product review
To view a product review, use accounts.productreviews.get
. This is read-only.
It requires your accountId
and the ID of the product review as part of the
name field. The GET
method returns the corresponding product review resource.
GET https://merchantapi.googleapis.com/reviews/v1/{name=accounts/ {ACCOUNT_ID}
/productReviews/*}
Here's a sample you can use to retrieve a product review:
Java
import
com.google.api.gax.core.FixedCredentialsProvider
;
import
com.google.auth.oauth2.GoogleCredentials
;
import
com.google.shopping.merchant.reviews.v1beta.GetProductReviewRequest
;
import
com.google.shopping.merchant.reviews.v1beta.ProductReview
;
import
com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceClient
;
import
com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceSettings
;
import
shopping.merchant.samples.utils.Authenticator
;
import
shopping.merchant.samples.utils.Config
;
/** This class demonstrates how to get a product review. */
public
class
GetProductReviewSample
{
public
static
void
getProductReview
(
String
accountId
,
String
productReviewId
)
throws
Exception
{
GoogleCredentials
credential
=
new
Authenticator
().
authenticate
();
ProductReviewsServiceSettings
productReviewsServiceSettings
=
ProductReviewsServiceSettings
.
newBuilder
()
.
setCredentialsProvider
(
FixedCredentialsProvider
.
create
(
credential
))
.
build
();
try
(
ProductReviewsServiceClient
productReviewsServiceClient
=
ProductReviewsServiceClient
.
create
(
productReviewsServiceSettings
))
{
GetProductReviewRequest
request
=
GetProductReviewRequest
.
newBuilder
()
.
setName
(
String
.
format
(
"accounts/%s/productReviews/%s"
,
accountId
,
productReviewId
))
.
build
();
System
.
out
.
println
(
"Sending get product review request:"
);
ProductReview
response
=
productReviewsServiceClient
.
getProductReview
(
request
);
System
.
out
.
println
(
"Product review retrieved successfully:"
);
System
.
out
.
println
(
response
.
getName
());
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
);
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Config
config
=
Config
.
load
();
String
productReviewId
=
"YOUR_PRODUCT_REVIEW_ID"
;
getProductReview
(
config
.
getAccountId
().
toString
(),
productReviewId
);
}
}
List product reviews
You can use the productreviews.list
method to view all created product
reviews.
GET https://merchantapi.googleapis.com/reviews/v1/{parent=accounts/ {ACCOUNT_ID}
}/productReviews
Here's a sample you can use to list all the reviews for a product:
Java
import
com.google.api.gax.core.FixedCredentialsProvider
;
import
com.google.auth.oauth2.GoogleCredentials
;
import
com.google.shopping.merchant.reviews.v1beta.ListProductReviewsRequest
;
import
com.google.shopping.merchant.reviews.v1beta.ProductReview
;
import
com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceClient
;
import
com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceClient.ListProductReviewsPagedResponse
;
import
com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceSettings
;
import
shopping.merchant.samples.utils.Authenticator
;
import
shopping.merchant.samples.utils.Config
;
/** This class demonstrates how to list all the product reviews in a given account. */
public
class
ListProductReviewsSample
{
public
static
void
listProductReviews
(
String
accountId
)
throws
Exception
{
GoogleCredentials
credential
=
new
Authenticator
().
authenticate
();
ProductReviewsServiceSettings
productReviewsServiceSettings
=
ProductReviewsServiceSettings
.
newBuilder
()
.
setCredentialsProvider
(
FixedCredentialsProvider
.
create
(
credential
))
.
build
();
try
(
ProductReviewsServiceClient
productReviewsServiceClient
=
ProductReviewsServiceClient
.
create
(
productReviewsServiceSettings
))
{
ListProductReviewsRequest
request
=
ListProductReviewsRequest
.
newBuilder
()
.
setParent
(
String
.
format
(
"accounts/%s"
,
accountId
))
.
build
();
System
.
out
.
println
(
"Sending list product reviews request:"
);
ListProductReviewsPagedResponse
response
=
productReviewsServiceClient
.
listProductReviews
(
request
);
int
count
=
0
;
// Iterates over all rows in all pages and prints all product reviews.
for
(
ProductReview
element
:
response
.
iterateAll
())
{
System
.
out
.
println
(
element
);
count
++
;
}
System
.
out
.
print
(
"The following count of elements were returned: "
);
System
.
out
.
println
(
count
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
);
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Config
config
=
Config
.
load
();
listProductReviews
(
config
.
getAccountId
().
toString
());
}
}
Delete product reviews
To delete a product review, use accounts.productreviews.delete
. Similar to the GET
method, this method requires the name field of the product review returned
during creation.
DELETE https://merchantapi.googleapis.com/reviews/v1/{name=accounts/ {ACCOUNT_ID}
/productReviews/*}
Here's a sample you can use to delete a product review:
Java
import
com.google.api.gax.core.FixedCredentialsProvider
;
import
com.google.auth.oauth2.GoogleCredentials
;
import
com.google.shopping.merchant.reviews.v1beta.DeleteProductReviewRequest
;
import
com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceClient
;
import
com.google.shopping.merchant.reviews.v1beta.ProductReviewsServiceSettings
;
import
shopping.merchant.samples.utils.Authenticator
;
import
shopping.merchant.samples.utils.Config
;
/** This class demonstrates how to delete a product review. */
public
class
DeleteProductReviewSample
{
public
static
void
deleteProductReview
(
String
accountId
,
String
productReviewId
)
throws
Exception
{
GoogleCredentials
credential
=
new
Authenticator
().
authenticate
();
ProductReviewsServiceSettings
productReviewsServiceSettings
=
ProductReviewsServiceSettings
.
newBuilder
()
.
setCredentialsProvider
(
FixedCredentialsProvider
.
create
(
credential
))
.
build
();
try
(
ProductReviewsServiceClient
productReviewsServiceClient
=
ProductReviewsServiceClient
.
create
(
productReviewsServiceSettings
))
{
DeleteProductReviewRequest
request
=
DeleteProductReviewRequest
.
newBuilder
()
.
setName
(
String
.
format
(
"accounts/%s/productReviews/%s"
,
accountId
,
productReviewId
))
.
build
();
System
.
out
.
println
(
"Sending delete product review request:"
);
productReviewsServiceClient
.
deleteProductReview
(
request
);
System
.
out
.
println
(
"Product review deleted successfully"
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
);
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Config
config
=
Config
.
load
();
String
productReviewId
=
"YOUR_PRODUCT_REVIEW_ID"
;
deleteProductReview
(
config
.
getAccountId
().
toString
(),
productReviewId
);
}
}
Product review status
The product review resource contains the status similar to other APIs, which is an integral part of the resource and follows the same issue & destination structure.