Preisvergleichsportal-Produkt abrufen
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Verwenden Sie dieses Beispiel, um ein Preisvergleichsportal-Produkt abzurufen.
cURL
curl --location 'https://css.googleapis.com/v1/accounts/1234567/cssProducts/de~DE~rawProvidedId' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API_TOKEN>'
Java
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package shopping.css.samples.v1.cssproducts;
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.css.v1.CssProduct;
import com.google.shopping.css.v1.CssProductsServiceClient;
import com.google.shopping.css.v1.CssProductsServiceSettings;
import com.google.shopping.css.v1.GetCssProductRequest;
import shopping.css.samples.utils.Authenticator;
import shopping.css.samples.utils.Config;
/** This class demonstrates how to get a CSS Product for a given Account */
public class GetCssProduct {
private static String getName(String domainId) {
return String.format("accounts/%s", domainId);
}
private static String getName(String domainId, String productId) {
return String.format("accounts/%s/cssProducts/%s", domainId, productId);
}
public static void getCssProduct(Config config, String productId) throws Exception {
GoogleCredentials credential = new Authenticator().authenticate();
CssProductsServiceSettings cssProductsServiceSettings =
CssProductsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
String name = getName(config.getDomainId().toString(), productId);
try (CssProductsServiceClient cssProductsServiceClient =
CssProductsServiceClient.create(cssProductsServiceSettings)) {
GetCssProductRequest request = GetCssProductRequest.newBuilder().setName(name).build();
System.out.println("Sending GetCssProduct request");
CssProduct response = cssProductsServiceClient.getCssProduct(request);
System.out.println("Retrieved CssProduct Name below");
System.out.println(response.getName());
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
final Config config = Config.load();
getCssProduct(config, "it~IT~12345");
}
}
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-07-25 (UTC).
[null,null,["Zuletzt aktualisiert: 2025-07-25 (UTC)."],[[["\u003cp\u003eThis page provides instructions and code samples for retrieving a CSS Product using the Comparison Shopping Service (CSS) API.\u003c/p\u003e\n"],["\u003cp\u003eIt includes examples using cURL for making a direct API request and Java code for interacting with the API through the client library.\u003c/p\u003e\n"],["\u003cp\u003eThe provided Java code demonstrates how to authenticate, construct the request, and handle the API response for retrieving a specific CSS Product.\u003c/p\u003e\n"],["\u003cp\u003eThis sample can help you access CSS Product data from your Google Merchant Center account programmatically, using your preferred method.\u003c/p\u003e\n"]]],[],null,["# Get CSS Product\n\nUse this sample to get a CSS Product. \n\n### cURL\n\n curl --location 'https://css.googleapis.com/v1/accounts/1234567/cssProducts/de~DE~rawProvidedId' \\\n --header 'Content-Type: application/json' \\\n --header 'Authorization: Bearer \u003cAPI_TOKEN\u003e'\n\n### Java\n\n // Copyright 2023 Google LLC\n //\n // Licensed under the Apache License, Version 2.0 (the \"License\");\n // you may not use this file except in compliance with the License.\n // You may obtain a copy of the License at\n //\n // https://www.apache.org/licenses/LICENSE-2.0\n //\n // Unless required by applicable law or agreed to in writing, software\n // distributed under the License is distributed on an \"AS IS\" BASIS,\n // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n // See the License for the specific language governing permissions and\n // limitations under the License.\n\n package shopping.css.samples.v1.cssproducts;\n\n import com.google.api.gax.core.FixedCredentialsProvider;\n import com.google.auth.oauth2.GoogleCredentials;\n import com.google.shopping.css.v1.CssProduct;\n import com.google.shopping.css.v1.CssProductsServiceClient;\n import com.google.shopping.css.v1.CssProductsServiceSettings;\n import com.google.shopping.css.v1.GetCssProductRequest;\n import shopping.css.samples.utils.Authenticator;\n import shopping.css.samples.utils.Config;\n\n /** This class demonstrates how to get a CSS Product for a given Account */\n public class GetCssProduct {\n\n private static String getName(String domainId) {\n return String.format(\"accounts/%s\", domainId);\n }\n\n private static String getName(String domainId, String productId) {\n return String.format(\"accounts/%s/cssProducts/%s\", domainId, productId);\n }\n\n public static void getCssProduct(Config config, String productId) throws Exception {\n GoogleCredentials credential = new Authenticator().authenticate();\n\n CssProductsServiceSettings cssProductsServiceSettings =\n CssProductsServiceSettings.newBuilder()\n .setCredentialsProvider(FixedCredentialsProvider.create(credential))\n .build();\n\n String name = getName(config.getDomainId().toString(), productId);\n\n try (CssProductsServiceClient cssProductsServiceClient =\n CssProductsServiceClient.create(cssProductsServiceSettings)) {\n\n GetCssProductRequest request = GetCssProductRequest.newBuilder().setName(name).build();\n\n System.out.println(\"Sending GetCssProduct request\");\n CssProduct response = cssProductsServiceClient.getCssProduct(request);\n System.out.println(\"Retrieved CssProduct Name below\");\n System.out.println(response.getName());\n } catch (Exception e) {\n System.out.println(e);\n }\n }\n\n public static void main(String[] args) throws Exception {\n final Config config = Config.load();\n\n getCssProduct(config, \"it~IT~12345\");\n }\n } \n https://github.com/googleads/comparison-shopping-service-api-samples/blob/2f511c3ca413bdbd497f89ae7468b3191dafaa6d/java/src/main/java/shopping/css/samples/v1/cssproducts/GetCssProduct.java"]]