Merchant API 推出了一种更强大、更直观的商品数据管理方式。主要变化是将商品数据分为两个不同的资源:ProductInput 用于提交数据,Product 用于查看最终处理的版本,包括商品状态和问题。这种新结构可提供更可预测、更透明的体验。
本指南将引导您了解关键区别,帮助您将集成从 Content API for Shopping 迁移。如需详细了解如何使用新功能,请参阅管理产品。
主要差异
与 Content API for Shopping 相比,Merchant API 在商品管理方面做出了以下重大变更:
- 用于输入数据和处理后数据的专用资源:Merchant API 将商品管理拆分为两个资源。您可以使用 - ProductInput资源来插入、更新和删除商品数据。您可以使用只读的- Product资源来查看 Google 处理您的输入、应用规则并合并来自补充来源的数据后生成的最终商品。
- 集成产品状态: - productstatuses服务已移除。 商品验证问题和平台状态现在直接包含在- productStatus字段内的- Product资源中,从而简化了数据检索。
- 可预测的产品更新:新的 - productInputs.patch方法可直接修改特定产品输入。与 Content API for Shopping 相比,这是一个重大改进,因为在 Content API for Shopping 中,更新可能会被其他 Feed 上传意外覆盖。在 Merchant API 中,更新会一直保留,直到相应商品输入再次更新或被删除。 产品更新应用于- ProductInput资源,而不是已处理的- Product资源。
- 选择数据源,以便更轻松地管理数据:所有 - productInputs写操作现在都需要- dataSource查询参数,以便明确您要修改的数据源。如果您有多个数据源,此功能尤其有用。
- 新的资源标识符:现在,产品通过 RESTful 资源 - name而不是- id字段来标识。格式为- accounts/{account}/products/{product}。
- 无自定义批次: - custombatch方法不再可用。您可以使用异步请求或 HTTP 批处理在单个 HTTP 调用中发送多个请求。
- 适用于任何 Feed 标签和语言的数据源:借助 Merchant API,您可以创建数据源,而无需指定 Feed 标签和语言,因此可以插入具有任何 Feed 标签和语言的商品。 
请求
本部分比较了 Content API for Shopping 和 Merchant API 的请求格式。
| 请求说明 | Content API for Shopping | Merchant API | 
|---|---|---|
| 获取商品 | GET https://shoppingcontent.googleapis.com/content/v2.1/{merchantId}/products/{productId} | GET https://merchantapi.googleapis.com/products/v1/accounts/{account}/products/{product} | 
| 列出商品 | GET https://shoppingcontent.googleapis.com/content/v2.1/{merchantId}/products | GET https://merchantapi.googleapis.com/products/v1/accounts/{account}/products | 
| 插入产品 | POST https://shoppingcontent.googleapis.com/content/v2.1/{merchantId}/products | POST https://merchantapi.googleapis.com/products/v1/accounts/{account}/productInputs:insert | 
| 更新商品 | PATCH https://shoppingcontent.googleapis.com/content/v2.1/{merchantId}/products/{productId} | PATCH https://merchantapi.googleapis.com/products/v1/accounts/{account}/productInputs/{productinput} | 
| 删除商品 | DELETE https://shoppingcontent.googleapis.com/content/v2.1/{merchantId}/products/{productId} | DELETE https://merchantapi.googleapis.com/products/v1/accounts/{account}/productInputs/{productinput} | 
| 获取商品状态 | GET https://shoppingcontent.googleapis.com/content/v2.1/{merchantId}/productstatuses/{productId} | GET https://merchantapi.googleapis.com/products/v1/accounts/{account}/products/{product} | 
| 列出商品状态 | GET https://shoppingcontent.googleapis.com/content/v2.1/{merchantId}/productstatuses | GET https://merchantapi.googleapis.com/products/v1/accounts/{account}/products | 
| 批量处理多个请求 | POST https://shoppingcontent.googleapis.com/content/v2.1/products/custombatch | 异步请求、HTTP 批处理 | 
标识符
Merchant API 中的商品标识符格式已更改为标准 REST 资源名称。
| 标识符说明 | Content API for Shopping | Merchant API | 
|---|---|---|
| 产品 ID | 一个由英文冒号 ( :) 分隔的多个部分组成的字符串。格式: channel:contentLanguage:targetCountry:offerId或channel:contentLanguage:feedLabel:offerId。示例: online:en:US:sku123 | REST 资源 name字符串。格式: accounts/{account}/products/{product},其中{product}为contentLanguage~feedLabel~offerId。示例: accounts/12345/products/en~US~sku123 | 
方法
下表显示了 Content API for Shopping 方法及其在 Merchant API 中的等效方法。
| Content API for Shopping 方法 | Merchant API 方法 | 适用范围和备注 | 
|---|---|---|
| products.get | products.get | 检索最终处理后的商品。 | 
| products.list | products.list | 列出最终的已处理商品。 | 
| products.insert | productInputs.insert | 插入商品输入。需要 dataSource。 | 
| products.update | productInputs.update | 行为有显著不同。它会更新特定商品输入,并且是持久性的。 | 
| products.delete | productInputs.delete | 删除特定商品输入。需要 dataSource。 | 
| products.custombatch | 不可用 | 使用异步请求或 HTTP 批处理。 | 
| productstatuses.get | products.get | productstatuses服务已被移除。状态信息现在是Product资源的一部分。 | 
| productstatuses.list | products.list | productstatuses服务已被移除。状态信息现在是Product资源的一部分。 | 
| productstatuses.custombatch | 不可用 | 使用 [asynchronous | 
请求](/merchant/api/samples/insert-product-input-async)或 HTTP 批处理。|
详细的字段更改
下表重点介绍了 Merchant API 中已更改、添加或移除的重要字段。
| Content API for Shopping | Merchant API | 说明 | 
|---|---|---|
| id | name | 商品的唯一标识符现在是 REST 资源 name。 | 
| 顶级商品数据规范属性(例如, title、price、link) | productAttributes对象 | title、price和link等商品属性不再是顶级字段。现在,它们在Product和ProductInput资源中都归类于productAttributes对象中。这样可以提供更清晰、更有条理的资源结构。 | 
| targetCountry | feedLabel | 资源名称现在使用 feedLabel而不是targetCountry,以与 Merchant Center 功能保持一致。 | 
| feedId | dataSource(查询参数) | 现在, dataSource名称是所有productInputs写入方法(insert、update、delete)的必需查询参数。 | 
| channel | 无法使用。请为仅限本地的商品使用 legacy_local。 | Merchant API 中不再提供 channel字段。在 Content API for Shopping 中,具有LOCAL渠道的商品应将legacy_local字段设置为 true。 | 
| 不可用 | versionNumber | ProductInput上新增了一个可选字段,可用于防止无序插入到主要数据源中。 | 
| 具有已定义值集的 string类型字段 | 具有已定义值集的 enum类型字段 | 具有已定义值集(例如 excluded_destinations、availability)的产品属性中的字段现在为enum类型。 |