Für die
Google Business Performance API gibt es eine
NEUE API-Methode, mit der sich mehrere „DailyMetrics“-Objekte in einer einzelnen Anfrage abrufen lassen.
Sehen Sie sich den
Zeitplan für die Einstellung und die Anleitung für die Migration von der reportInsights API-Methode Version 4 zur Google Business Profile Performance API an.
Mit Rezensionsdaten arbeiten
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
In dieser Anleitung erfahren Sie, wie Sie Rezensionen aufrufen, zurückgeben, beantworten und löschen können. Mit der Google My Business API können Sie Rezensionsdaten nutzen, um Folgendes zu tun:
Hinweis
Sie können die Google My Business API erst verwenden, nachdem Sie Ihre Anwendung registriert und OAuth 2.0-Anmeldedaten abgerufen haben. Weitere Informationen zu den ersten Schritten mit der Google My Business API finden Sie unter Grundlegende Einrichtung.
Alle Rezensionen abrufen
Mit der accounts.locations.reviews.list API können Sie alle Rezensionen für einen Standort abrufen, um sie im Bulk-Verfahren zu prüfen.
Verwenden Sie folgenden Code, um alle Rezensionen für einen Standort abzurufen:
GET
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews
Die folgende Funktion verwendet 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;
}
Eine bestimmte Rezension abrufen
Mit der accounts.locations.reviews.get API können Sie eine bestimmte Rezension für einen Standort anhand seines Namens abrufen.
Verwenden Sie folgenden Code, um eine bestimmte Rezension abzurufen:
GET
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews/{reviewId}
Die folgende Funktion verwendet 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;
}
Zusätzliche Daten
Die Java-Clientbibliothek bietet Zugriff auf zusätzliche Felddaten für Rezensionsinstanzen. Sie können die folgenden Methoden verwenden, um zusätzliche Daten zu Rezensionen abzurufen:
getReviewId()
getComment()
getReviewer()
getStarRating()
getCreateTime()
getReviewReply()
Rezensionen für mehrere Standorte abrufen
Mit der accounts.locations.batchGetReviews API können Sie Rezensionen für verschiedene Standorte in einer Anfrage abrufen.
Verwenden Sie folgenden Code, um Rezensionen für verschiedene Standorte abzurufen:
POST
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations:batchGetReviews
{
"locationNames": [
string
],
"pageSize": number,
"pageToken": string,
"orderBy": string,
"ignoreRatingOnlyReviews": boolean
}
Auf eine Rezension antworten
Sie können auf eine bestimmte Rezension antworten oder eine neue Antwort verfassen, wenn noch keine vorhanden ist. Verwenden Sie die accounts.locations.reviews.updateReply API, um auf eine bestimmte Rezension für einen Standort zu antworten.
Verwenden Sie folgenden Code, um auf eine bestimmte Rezension zu antworten:
PUT
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews/{reviewId}/reply
{
comment: "Thank you for visiting our business!"
}
Die folgende Funktion verwendet Mybusiness.accounts.locations.reviews.reply
.
/*
* Updates the reply for a location review.
* If a review does not exist, creates a new one.
* @param reviewName Name of the review being responded to.
* @param comment A string containing the review response body.
* @throws IOException
*/
private static Reply reply(String reviewName, String comment) throws IOException {
MyBusiness.Accounts.Locations.Reviews.Reply reply =
mybusiness().accounts().locations().reviews().reply(reviewName, comment);
Reply response = reviewReply.execute();
return response;
}
Antworten auf Rezensionen löschen
Mit der accounts.locations.reviews.deleteReply API können Sie eine Antwort auf eine bestimmte Rezension für einen Standort löschen.
Verwenden Sie folgenden Code, um eine bestimmte Antwort auf eine Rezension zu löschen:
DELETE
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews/{reviewId}/reply
Die folgende Funktion verwendet Mybusiness.Accounts.Locations.Reviews.DeleteReply
.
/**
* Demonstrates deleting a review reply by name.
* @param reviewName The name (resource path) of the review reply to delete.
* @return Account The requested review.
*/
private static DeleteReply deleteReply(String reviewName) throws Exception {
Mybusiness.Accounts.Locations.Reviews.DeleteReply toDelete =
mybusiness.accounts().locations().reviews().deleteReply(reviewName);
DeleteReply response = toDelete.execute();
return response;
}
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2025-08-29 (UTC).
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-29 (UTC)."],[[["\u003cp\u003eThis tutorial demonstrates how to interact with Google My Business reviews, including listing, retrieving, replying to, and deleting them using the Google My Business API.\u003c/p\u003e\n"],["\u003cp\u003eYou can manage reviews for individual or multiple locations, retrieve specific review details (like comment, rating, reviewer), and programmatically reply to or delete review responses.\u003c/p\u003e\n"],["\u003cp\u003eBefore 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.\u003c/p\u003e\n"],["\u003cp\u003eThe tutorial provides code samples in Java and HTTP request formats for various review operations.\u003c/p\u003e\n"],["\u003cp\u003eAdditional data fields are accessible through the Java Client Library for more detailed review information.\u003c/p\u003e\n"]]],[],null,["# Work with review data\n\n\u003cbr /\u003e\n\nThis tutorial shows you how to list, return, reply, and delete a review. The\nGoogle My Business API provides you with the ability to work with review data to\nperform the following operations:\n\n- [List all reviews](#list_all_reviews).\n- [Get a specific review](#get_a_specific_review).\n- [Get reviews from multiple locations](#get_reviews_from_multiple_locations).\n- [Reply to a review](#reply_to_a_review).\n- [Delete a review reply](#delete_a_review_reply).\n\nBefore you begin\n----------------\n\nBefore you use the Google My Business API, you need to register your\napplication and obtain OAuth 2.0 credentials. For details on how to get started\nwith the Google My Business API, see\n[Basic setup](/my-business/content/basic-setup).\n\nList all reviews\n----------------\n\nList all reviews of a location to audit reviews in bulk. Use the\n[accounts.locations.reviews.list](/my-business/reference/rest/v4/accounts.locations.reviews/list)\nAPI to return all of the reviews associated with a location.\n\nTo return all reviews associated with a location, use the following:\nHTTP \n\n```\nGET\nhttps://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews\n```\nJava\n\nThe following function uses `Mybusiness.Accounts.Locations.Reviews.List`. \n\n```java\n/**\n * Returns a list of reviews.\n * @param locationName Name of the location to retrieve reviews for.\n * @return List\u003cReviews\u003e A list of reviews.\n * @throws Exception\n */\npublic static List\u003cReview\u003e listReviews(String locationName) throws Exception {\n Mybusiness.Accounts.Locations.Reviews.List reviewsList =\n mybusiness.accounts().locations().reviews().list(locationName);\n ListReviewsResponse response = accountsList.execute();\n List\u003cReviews\u003e reviews = response.getReviews();\n\n for (Reviews review : reviews) {\n System.out.println(review.toPrettyString());\n }\n return reviews;\n}\n```\n\nGet a specific review\n---------------------\n\nReturn a specific review by name. Use the\n[accounts.locations.reviews.get](/my-business/reference/rest/v4/accounts.locations.reviews/get)\nAPI to return a specific review associated with a location.\n\nTo return a specific review, use the following:\nHTTP \n\n```\nGET\nhttps://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews/{reviewId}\n```\nJava\n\nThe following function uses `Mybusiness.Accounts.Locations.Reviews.Get`. \n\n```java\n/**\n * Demonstrates getting a review by name.\n * @param reviewName The name (resource path) of the review to retrieve.\n * @return Account The requested review.\n */\nprivate static Review getReview(String reviewName) throws Exception {\n Mybusiness.Accounts.Locations.Reviews.Get review =\n mybusiness.accounts().locations().reviews().get(reviewName);\n Review response = review.execute();\n\n return response;\n}\n```\n\n### Additional data\n\nThe Java Client Library gives you access to additional field data for review\ninstances. Use the following methods to return additional data about reviews:\n\n- `getReviewId()`\n- `getComment()`\n- `getReviewer()`\n- `getStarRating()`\n- `getCreateTime()`\n- `getReviewReply()`\n\nGet reviews from multiple locations\n-----------------------------------\n\nGet reviews from multiple locations. Use the\n[accounts.locations.batchGetReviews](https://developers.google.com/my-business/reference/rest/v4/accounts.locations/batchGetReviews)\nAPI to return reviews from multiple locations in a single request.\n\nTo return reviews from multiple locations, use the following:\nHTTP\n\n\u003cbr /\u003e\n\n```\nPOST\nhttps://mybusiness.googleapis.com/v4/accounts/{accountId}/locations:batchGetReviews\n\n{\n \"locationNames\": [\n string\n ],\n \"pageSize\": number,\n \"pageToken\": string,\n \"orderBy\": string,\n \"ignoreRatingOnlyReviews\": boolean\n}\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nReply to a review\n-----------------\n\n| **Important:** In order to use this functionality, you need to ensure that your G Suite Organization Administrator has enabled Google Search and/or Google Maps as services for your account, along with Business Profile. If you experience any issues, contact your Administrator. To learn more, see [Who is my administrator?](https://support.google.com/a/answer/6208960), [Control who can access G Suite and Google services](https://support.google.com/a/answer/182442), and [Apply policies to different users](https://support.google.com/a/topic/1227584).\n\nReply to a specific review, or create a new reply if one doesn't exist. Use the\n[accounts.locations.reviews.updateReply](/my-business/reference/rest/v4/accounts.locations.reviews/updateReply)\nAPI to reply to a specific review associated with a location.\n\nTo reply to a specific review, use the following:\nHTTP \n\n```\nPUT\nhttps://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews/{reviewId}/reply\n\n{\n comment: \"Thank you for visiting our business!\"\n}\n```\nJava\n\nThe following function uses `Mybusiness.accounts.locations.reviews.reply`. \n\n```java\n/*\n * Updates the reply for a location review.\n * If a review does not exist, creates a new one.\n * @param reviewName Name of the review being responded to.\n * @param comment A string containing the review response body.\n * @throws IOException\n */\nprivate static Reply reply(String reviewName, String comment) throws IOException {\n\n MyBusiness.Accounts.Locations.Reviews.Reply reply =\n mybusiness().accounts().locations().reviews().reply(reviewName, comment);\n\n Reply response = reviewReply.execute();\n\n return response;\n}\n```\n\nDelete a review reply\n---------------------\n\nDelete a reply to a specific review. Use the\n[accounts.locations.reviews.deleteReply](/my-business/reference/rest/v4/accounts.locations.reviews/deleteReply)\nAPI to delete a reply to a specific review associated with a location.\n\nTo delete a specific reply to a review, use the following:\nHTTP \n\n```\nDELETE\nhttps://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews/{reviewId}/reply\n```\nJava\n\nThe following function uses `Mybusiness.Accounts.Locations.Reviews.DeleteReply`. \n\n```java\n/**\n * Demonstrates deleting a review reply by name.\n * @param reviewName The name (resource path) of the review reply to delete.\n * @return Account The requested review.\n */\nprivate static DeleteReply deleteReply(String reviewName) throws Exception {\n Mybusiness.Accounts.Locations.Reviews.DeleteReply toDelete =\n mybusiness.accounts().locations().reviews().deleteReply(reviewName);\n DeleteReply response = toDelete.execute();\n\n return response;\n}\n```"]]