POST https://merchantapi.googleapis.com/datasources/v1/accounts/{ACCOUNT_ID}/dataSources/{DATASOURCE_ID}
示例
此示例展示了典型的请求和响应。
请求
POST https://merchantapi.googleapis.com/datasources/v1/accounts/123/dataSources {"displayName": "test api feed", "merchantReviewDataSource":{} }
答案
{"name":"accounts/123/dataSources/1000000573361824","dataSourceId":"1000000573361824","displayName":"test api feed","merchantReviewDataSource":{},"input":"API"}
importcom.google.api.gax.core.FixedCredentialsProvider;importcom.google.auth.oauth2.GoogleCredentials;importcom.google.shopping.merchant.products.v1.GetProductRequest;importcom.google.shopping.merchant.products.v1.Product;importcom.google.shopping.merchant.products.v1.ProductsServiceClient;importcom.google.shopping.merchant.products.v1.ProductsServiceSettings;importshopping.merchant.samples.utils.Authenticator;importshopping.merchant.samples.utils.Config;/** This class demonstrates how to get a single product for a given Merchant Center account */publicclassGetProductSample{publicstaticvoidgetProduct(Configconfig,Stringproduct)throwsException{// Obtains OAuth token based on the user's configuration.GoogleCredentialscredential=newAuthenticator().authenticate();// Creates service settings using the credentials retrieved above.ProductsServiceSettingsproductsServiceSettings=ProductsServiceSettings.newBuilder().setCredentialsProvider(FixedCredentialsProvider.create(credential)).build();// Calls the API and catches and prints any network failures/errors.try(ProductsServiceClientproductsServiceClient=ProductsServiceClient.create(productsServiceSettings)){// The name has the format: accounts/{account}/products/{productId}GetProductRequestrequest=GetProductRequest.newBuilder().setName(product).build();System.out.println("Sending get product request:");Productresponse=productsServiceClient.getProduct(request);System.out.println("Retrieved Product below");System.out.println(response);}catch(Exceptione){System.out.println(e);}}publicstaticvoidmain(String[]args)throwsException{Configconfig=Config.load();// The name of the `product`, returned after a `Product.insert` request. We recommend// having stored this value in your database to use for all future requests.Stringproduct="accounts/{datasource}/products/{productId}";getProduct(config,product);}}
[null,null,["最后更新时间 (UTC):2025-08-21。"],[[["\u003cp\u003eSeller ratings can boost ad and organic listing performance, leading to more qualified customer traffic.\u003c/p\u003e\n"],["\u003cp\u003eThis page provides instructions on managing seller reviews using the Merchant API, including creating, viewing, listing, and deleting them.\u003c/p\u003e\n"],["\u003cp\u003eTo use the API, you need an active merchant review data source and enrollment in the store ratings program.\u003c/p\u003e\n"],["\u003cp\u003eCreating a merchant review involves using the \u003ccode\u003eaccounts.merchantreviews.insert\u003c/code\u003e method, providing comprehensive details to avoid data loss.\u003c/p\u003e\n"],["\u003cp\u003eAfter creating a review, allow a few minutes for it to propagate and become visible.\u003c/p\u003e\n"]]],["Merchant reviews, which boost customer trust and purchasing decisions, are managed via the Merchant API. To begin, enroll in the store ratings program and create a merchant review data source using `accounts.dataSources.create`. Use `accounts.merchantReviews.insert` to create or update reviews, including necessary details like rating and reviewer information. View existing reviews with `accounts.merchantReviews.get`, list all with `accounts.merchantReviews.list`, or delete them using `accounts.merchantReviews.delete`. The merchant review resource includes a status field.\n"],null,["# Review sellers using Merchant API\n\n[Seller reviews](//support.google.com/merchants/answer/190657) help people find businesses that offer\nhigh-quality customer experiences, helping to build trust and enabling more\ninformed purchasing decisions. As a result, shop ratings can help businesses\nimprove the performance of ads and organic listings and drive more qualified\ncustomers to their landing pages.\n\nThis page explains how you can manage seller reviews using Merchant API.\n\nPrerequisites\n-------------\n\nGoogle needs you to provide specific information. You must have the following:\n\n- An active merchant review data source in the Google Merchant Center.\n- Your account must be enrolled into the [store ratings\n program](//support.google.com/merchants/answer/190657). If you are unsure whether you are already enrolled, check the Merchant Center. If you aren't enrolled, submit the [request\n form](//docs.google.com/forms/d/e/1FAIpQLSePegrteda-PD48S5z8SFb4i3WOEeUdsf9YFgkOOVrc-G9VXA/viewform).\n\n| **Note:** A merchant review data source is not the same as a product review data source.\n\nCreate a data source\n--------------------\n\nUse the\n[accounts.dataSources.create](/merchant/api/reference/rest/datasources_v1/accounts.dataSources/create)\nmethod to create a merchant reviews feed. If an existing merchant reviews feed\nis available, use\n[accounts.dataSources.get](/merchant/api/reference/rest/datasources_v1/accounts.dataSources/get)\nto fetch the `dataSource.name` field.\n\nThe form of the request is as follows: \n\n POST https://merchantapi.googleapis.com/datasources/v1/accounts/\u003cvar translate=\"no\"\u003e{ACCOUNT_ID}\u003c/var\u003e/dataSources/\u003cvar translate=\"no\"\u003e{DATASOURCE_ID}\u003c/var\u003e\n\n### Example\n\nThe example shows a typical request and response.\n\n**Request** \n\n POST https://merchantapi.googleapis.com/datasources/v1/accounts/123/dataSources {\"displayName\": \"test api feed\", \"merchantReviewDataSource\":{} }\n\n**Response** \n\n {\n \"name\": \"accounts/123/dataSources/1000000573361824\",\n \"dataSourceId\": \"1000000573361824\",\n \"displayName\": \"test api feed\",\n \"merchantReviewDataSource\": {},\n \"input\": \"API\"\n }\n\nFor more information, see [Create a product review data\nsource](/merchant/api/guides/data-sources/manage-various-data-sources#product-review-data-source).\n| **Note:** The data source is immediately available after creation, so you don't need to wait for any processing.\n\nCreate merchant review\n----------------------\n\nYou can use the\n[`accounts.merchantReviews.insert`](/merchant/api/reference/rest/reviews_v1alpha/accounts.merchantReviews/insert)\nmethod to create or update a seller review. The\n`accounts.merchantReviews.insert` method takes a `merchantreview` resource and a\ndata source name as input. It returns the new or updated merchant review, if\nsuccessful. Creating a merchant review requires `datasource.name`.\n| **Important:** This request overwrites the entire merchant review resource, so the request needs to include all the details to avoid losing information.\n\nThe form of the request: \n\n POST https://merchantapi.googleapis.com/reviews/v1alpha/{parent=accounts/*/}merchantReviews:insert\n\nStudy the following sample merchant review for reference. \n\n POST https://merchantapi.googleapis.com/reviews/v1alpha/accounts/\u003cvar translate=\"no\"\u003e{ACCOUNT_ID}\u003c/var\u003e/merchantReviews:insert?dataSource=accounts/\u003cvar translate=\"no\"\u003e{ACCOUNT_ID}\u003c/var\u003e/dataSources/\u003cvar translate=\"no\"\u003e{DATASOURCE_ID}\u003c/var\u003e\n\n merchantReviewId = 'my_own_review'\n merchantReviewAttributes {\n merchantId = 'merchant_id'\n merchantDisplayName = 'merchant_display_name'\n merchantLink = 'publisher_name'\n merchantRatingLink = 'https://www.google.com'\n minRating = 1\n maxRating = 10\n rating = 7.9\n title = 'Amazing Merchant'\n content = 'This is an incredible merchant'\n reviewerId = 'reviewer_id'\n reviewerUsername = 'reviewer_username'\n isAnonymous = false\n collectionMethod = 'AFTER_FULFILLMENT'\n reviewTime = '2024-04-01T00:00:00Z'\n reviewLanguage = 'en'\n reviewCountry = 'US'\n }\n\nAfter merchant review creation, it may take a few minutes for the review to\npropagate.\n\nView merchant reviews\n---------------------\n\nTo view a merchant review, use\n[`accounts.merchantReviews.get`](/merchant/api/reference/rest/reviews_v1alpha/accounts.merchantReviews/get).\nThis is read-only. It requires your `merchantId` and the ID of the merchant\nreview as part of the name field. The get method returns the corresponding\nmerchant review resource.\n\nFor example: \n\n GET https://merchantapi.googleapis.com/reviews/v1alpha/{name=accounts/*/merchantReviews/*}\n\nTo retrieve a single product for a given Merchant Center account, you can use\nthe\n[`google.shopping.merchant.accounts.v1.GetProductRequest`](/merchant/api/reference/rest/reviews_v1alpha/accounts.productReviews/get)\nmethod, as shown in the following sample. \n\n### Java\n\n import com.google.api.gax.core.FixedCredentialsProvider;\n import com.google.auth.oauth2.GoogleCredentials;\n import com.google.shopping.merchant.products.v1.GetProductRequest;\n import com.google.shopping.merchant.products.v1.Product;\n import com.google.shopping.merchant.products.v1.ProductsServiceClient;\n import com.google.shopping.merchant.products.v1.ProductsServiceSettings;\n import shopping.merchant.samples.utils.Authenticator;\n import shopping.merchant.samples.utils.Config;\n\n /** This class demonstrates how to get a single product for a given Merchant Center account */\n public class GetProductSample {\n\n public static void getProduct(Config config, String product) throws Exception {\n\n // Obtains OAuth token based on the user's configuration.\n GoogleCredentials credential = new Authenticator().authenticate();\n\n // Creates service settings using the credentials retrieved above.\n ProductsServiceSettings productsServiceSettings =\n ProductsServiceSettings.newBuilder()\n .setCredentialsProvider(FixedCredentialsProvider.create(credential))\n .build();\n\n // Calls the API and catches and prints any network failures/errors.\n try (ProductsServiceClient productsServiceClient =\n ProductsServiceClient.create(productsServiceSettings)) {\n\n // The name has the format: accounts/{account}/products/{productId}\n GetProductRequest request = GetProductRequest.newBuilder().setName(product).build();\n\n System.out.println(\"Sending get product request:\");\n Product response = productsServiceClient.getProduct(request);\n\n System.out.println(\"Retrieved Product below\");\n System.out.println(response);\n } catch (Exception e) {\n System.out.println(e);\n }\n }\n\n public static void main(String[] args) throws Exception {\n Config config = Config.load();\n // The name of the `product`, returned after a `Product.insert` request. We recommend\n // having stored this value in your database to use for all future requests.\n String product = \"accounts/{datasource}/products/{productId}\";\n\n getProduct(config, product);\n }\n } \n https://github.com/google/merchant-api-samples/blob/c6de994268c785ce22af0065932518a9ac5b3c03/java/src/main/java/shopping/merchant/samples/products/v1/GetProductSample.java#L17-L65\n\nList merchant reviews\n---------------------\n\nYou can use the\n[`accounts.merchantReviews.list`](/merchant/api/reference/rest/reviews_v1alpha/accounts.merchantReviews/list)\nmethod to view all created merchant reviews. \n\n GET https://merchantapi.googleapis.com/reviews/v1alpha/accounts/\u003cvar translate=\"no\"\u003e{ACCOUNT_ID}\u003c/var\u003e/merchantReviews\n\nDelete merchant reviews\n-----------------------\n\nTo delete a merchant review, use\n[`accounts.merchantReviews.delete`](/merchant/api/reference/rest/reviews_v1alpha/accounts.merchantReviews/delete).\nSimilar to the `accounts.merchantReviews.get` method, this method requires the\nname field of the merchant review returned during creation.\n\nFor example: \n\n DELETE https://merchantapi.googleapis.com/reviews/v1alpha/{name=accounts/*/merchantReviews/*}\n\nMerchant review status\n----------------------\n\nThe merchant review resource contains the status similar to other APIs, which is\nthe integral part of the resource and follows the same issue \\& destination\nstructure."]]