开始使用购物比较服务 (CSS)
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
使用 API 执行基本操作是开始使用该 API 的好方法。
前提条件
在开始之前,请完成以下步骤:
- 确保您拥有有效的 CSS Center 账号。
- 注册 API 开发者。
- 验证权限设置是否正确。
- 验证您是否已启用 CSS API。
- 验证您是否已为您的环境安装客户端库。
如需了解详情,请参阅快速入门。
启用 CSS API
如需注册成为开发者以使用 CSS API,您必须使用开发者注册方法关联您的 CSS Center 账号和 Google Cloud 项目,具体操作如下:
关联 CSS Center 和您的 Google Cloud 项目:系统会自动建立关联,因为调用者有权根据访问令牌或 API 密钥访问 Google Cloud 项目,并且是 CSS Center 账号的授权用户。
注册 API 开发者
向 CSS 中心账号添加 API 开发者用户:如果用户已存在,系统只会向其授予新的“API 开发者”访问权限类型。如果是新用户,他们会收到 CSS Center 电子邮件邀请。
注册后,您可以使用 GetDeveloperRegistration
查看注册状态,也可以使用 UnregisterGCP
取消注册。您可以使用以下注册调用:
POST https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/developerRegistration:registerGcp
{
developer_email:"example-email@example.com"
}
请求成功运行后,您会收到以下响应:
{
"developerRegistration":
{
"name": "accounts/ACCOUNT_ID/developerRegistration",
"gcpIds": [
"GOOGLE_CLOUD_PROJECT_ID"
]
}
}
CSS 产品
与 Products 子 API 类似,CSS API 会区分 CssProductInput
和 ListCssProduct
。插入具有 InsertCssProductInput
的商品。
我们的内部系统处理完商品后(这可能需要几分钟时间),使用 ListCssProducts
检索该商品。
使用 raw_provided_id
识别您的商品。我们建议您使用自己系统中已在使用的标识符。或者,创建此类文件的常用方法包括使用以下任一工具:
- 全局唯一标识符 (GUID)
- 通用唯一标识符 (UUID)
- 串联的唯一商品属性(例如 brand_model_color_size)
如需了解详情,请参阅插入/列出/更新/删除商品。
基本操作
您可以尝试提出以下一些基本请求。
使用 InsertCssProductInput
插入测试商品。
如需有关要发送的属性的帮助,请查看此示例代码。
使用 ListCssProducts
列出您的所有商品。
请注意,插入商品与商品显示在商品详情中之间会存在短暂的处理延迟。如果您没有立即看到,请稍等几秒钟,然后重试。
使用 cssproductinput.name
通过 UpdateCssProductInput
更新单个商品。您只需发送需要更新的属性。如需查看示例,请参阅示例代码。
使用 DeleteCssProductInpu
删除测试商品,并提供 raw_provided_id
。
限制
插入或删除单个商品可能需要较长时间。如需提升性能,请参阅使用 Async 提升性能。
这样就可以并行调用 API。
列出账号并为其添加标签
借助 CSS API 中的标签管理功能,您可以使用自定义标签以编程方式整理客户 Merchant Center 账号。此功能可帮助您高效地对客户进行分类(例如,按类型或策略),从而更好地组织和简化运营。您可以使用该 API 对标签执行以下功能:
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-08。
[null,null,["最后更新时间 (UTC):2025-08-08。"],[],[],null,["# Get started with Comparison Shopping Services (CSS)\n\nPerforming basic operations with the API is a good way to start using it.\n\nPrerequisites\n-------------\n\nBefore you start, complete the following:\n\n- Make sure that you have a valid CSS Center account.\n- Register an API developer.\n- Verify the correctness of your permissions setup.\n- Verify that you have enabled CSS API.\n- Verify that you have installed the client libraries for your environment.\n\nFor more information, see\n[Quickstart](/comparison-shopping-services/api/guides/quickstart).\n\nEnable the CSS API\n------------------\n\nRegister as a developer to use the CSS API, you must link your CSS Center\naccount and your Google Cloud project using the Developer Registration method,\nas follows:\n\nLink CSS Center and your Google Cloud project: The link is established\nautomatically, as the caller has access to the Google Cloud project based on the\nAccess token or API key, and is an authorized user of the CSS Center account.\n\nRegister an API developer\n-------------------------\n\nAdd an API developer user to the CSS Center account: If a user already exists\nthey will just be granted the new \"API Developer\" access type. In case of a new\nuser, they receive a CSS Center email invite.\n\nAfter registration you can view the Registration status using\n`GetDeveloperRegistration` or unregister using `UnregisterGCP`. You can use the\nfollowing registration call: \n\n POST https://merchantapi.googleapis.com/accounts/v1/accounts/{ACCOUNT_ID}/developerRegistration:registerGcp\n\n {\n developer_email:\"example-email@example.com\"\n }\n\nAfter the request runs successfully, expect the response: \n\n {\n \"developerRegistration\":\n {\n \"name\": \"accounts/ACCOUNT_ID/developerRegistration\",\n \"gcpIds\": [\n \"GOOGLE_CLOUD_PROJECT_ID\"\n ]\n }\n }\n\nCSS products\n------------\n\nSimilar to the [Products](/merchant/api/guides/products/overview) sub-API, CSS\nAPI distinguishes between `CssProductInput` and `ListCssProduct`. Insert a\nproduct with\n[`InsertCssProductInput`](/comparison-shopping-services/api/reference/rpc/google.shopping.css.v1#google.shopping.css.v1.CssProductInputsService.InsertCssProductInput).\n\nOnce our internal systems have processed the product (this can take a few\nminutes), retrieve it with\n[`ListCssProducts`](/comparison-shopping-services/api/reference/rpc/google.shopping.css.v1#google.shopping.css.v1.CssProductsService.ListCssProducts).\n\nIdentify your products using `raw_provided_id`. We recommend that you use an\nidentifier you are already using in your own system. Alternately, common methods\nto create one include the use of one of the following:\n\n- Globally Unique Identifiers (GUIDs)\n- Universally Unique Identifiers (UUIDs)\n- Concatenated unique product attributes (for example, brand_model_color_size)\n\nFor more information, see [Insert/List/Update/Delete a\nproduct](/comparison-shopping-services/api/guides/best_practices#insertlistupdatedelete_a_product).\n\n### Basic operations\n\nHere are a few basic requests you can try.\n\n1. Insert a test product using\n [`InsertCssProductInput`](/comparison-shopping-services/api/reference/rpc/google.shopping.css.v1#google.shopping.css.v1.CssProductInputsService.InsertCssProductInput).\n For help on the attributes to send, review this [sample\n code](/comparison-shopping-services/api/code-samples/cssproducts/insert-css-product-input).\n\n2. List all your products using\n [`ListCssProducts`](/comparison-shopping-services/api/reference/rpc/google.shopping.css.v1#google.shopping.css.v1.CssProductsService.ListCssProducts).\n Note that there is a small processing delay between inserting a product and\n its appearance for listing. If you don't see one right away, try again after\n a few seconds.\n\n3. Update a single product using [`UpdateCssProductInput`](/comparison-shopping-services/api/reference/rpc/google.shopping.css.v1#google.shopping.css.v1.CssProductInputsService.UpdateCssProductInput)\n using your `cssproductinput.name`. You need to send only the attributes\n required to be updated. For an example, see the [sample\n code](/comparison-shopping-services/api/code-samples/cssproducts/update-css-product-input).\n\n4. Delete the test product using\n [`DeleteCssProductInpu`](/comparison-shopping-services/api/reference/rpc/google.shopping.css.v1#google.shopping.css.v1.CssProductInputsService.DeleteCssProductInput),\n supplying the `raw_provided_id`.\n\n### Limitations\n\nInserting or deleting an individual product can be slow. To improve performance,\n[Use Async to improve\nperformance](/comparison-shopping-services/api/guides/best_practices#use_async_to_improve_performance).\nThis enables calling the API in parallel.\n\n### List and label your accounts\n\nLabel Management in CSS API lets you programmatically organize your client\nMerchant Center accounts using custom tags. This feature helps you efficiently\ncategorize clients (for example, by type or strategy), enabling better\norganization and streamlined operations. You can use the API to perform the\nfollowing functions on labels:\n\n- [CreateAccountLabel](/comparison-shopping-services/api/reference/rpc/google.shopping.css.v1#google.shopping.css.v1.AccountLabelsService.CreateAccountLabel)\n- [ListAccountLabels](/comparison-shopping-services/api/reference/rpc/google.shopping.css.v1#google.shopping.css.v1.AccountLabelsService.ListAccountLabels)\n- [DeleteAccountLabel](/comparison-shopping-services/api/reference/rpc/google.shopping.css.v1#google.shopping.css.v1.AccountLabelsService.DeleteAccountLabel)\n- [assign to accounts](/comparison-shopping-services/api/reference/rpc/google.shopping.css.v1#google.shopping.css.v1.AccountsLabelsService.CreateAccountLabel)\n- [unassign from accounts](/comparison-shopping-services/api/reference/rpc/google.shopping.css.v1#google.shopping.css.v1.AccountsLabelsService.DeleteAccountLabel)"]]