Page Summary
-
This tutorial demonstrates how to interact with Google My Business reviews, including listing, retrieving, replying to, and deleting them using the Google My Business API.
-
You can manage reviews for individual or multiple locations, retrieve specific review details (like comment, rating, reviewer), and programmatically reply to or delete review responses.
-
Before using the API, ensure your application is registered and has obtained OAuth 2.0 credentials, and for reply functionality, your G Suite administrator has enabled the necessary Google services.
-
The tutorial provides code samples in Java and HTTP request formats for various review operations.
-
Additional data fields are accessible through the Java Client Library for more detailed review information.
This tutorial shows you how to list, return, reply, and delete a review. The Google My Business API provides you with the ability to work with review data to perform the following operations:
- List all reviews .
- Get a specific review .
- Get reviews from multiple locations .
- Reply to a review .
- Delete a review reply .
Before you begin
Before you use the Google My Business API, you need to register your application and obtain OAuth 2.0 credentials. For details on how to get started with the Google My Business API, see Basic setup .
List all reviews
List all reviews of a location to audit reviews in bulk. Use the accounts.locations.reviews.list API to return all of the reviews associated with a location.
To return all reviews associated with a location, use the following:
GET https://mybusiness.googleapis.com/v4/accounts/ {accountId} /locations/ {locationId} /reviews
The following function uses Mybusiness.Accounts.Locations.Reviews.List
.
/** * Returns a list of reviews. * @param locationName Name of the location to retrieve reviews for. * @return List<Reviews> A list of reviews. * @throws Exception */ public static List<Review> listReviews ( String locationName ) throws Exception { Mybusiness . Accounts . Locations . Reviews . List reviewsList = mybusiness . accounts (). locations (). reviews (). list ( locationName ); ListReviewsResponse response = accountsList . execute (); List<Reviews> reviews = response . getReviews (); for ( Reviews review : reviews ) { System . out . println ( review . toPrettyString ()); } return reviews ; }
Get a specific review
Return a specific review by name. Use the accounts.locations.reviews.get API to return a specific review associated with a location.
To return a specific review, use the following:
GET https://mybusiness.googleapis.com/v4/accounts/ {accountId} /locations/ {locationId} /reviews/ {reviewId}
The following function uses Mybusiness.Accounts.Locations.Reviews.Get
.
/** * Demonstrates getting a review by name. * @param reviewName The name (resource path) of the review to retrieve. * @return Account The requested review. */ private static Review getReview ( String reviewName ) throws Exception { Mybusiness . Accounts . Locations . Reviews . Get review = mybusiness . accounts (). locations (). reviews (). get ( reviewName ); Review response = review . execute (); return response ; }
Additional data
The Java Client Library gives you access to additional field data for review instances. Use the following methods to return additional data about reviews:
-
getReviewId() -
getComment() -
getReviewer() -
getStarRating() -
getCreateTime() -
getReviewReply()
Get reviews from multiple locations
Get reviews from multiple locations. Use the accounts.locations.batchGetReviews API to return reviews from multiple locations in a single request.
To return reviews from multiple locations, use the following:
POST https://mybusiness.googleapis.com/v4/accounts/ {accountId} /locations:batchGetReviews { "locationNames": [ string ], "pageSize": number, "pageToken": string, "orderBy": string, "ignoreRatingOnlyReviews": boolean }

