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,這項功能是一大進步,因為其他動態饋給上傳作業不會意外覆寫更新。在 Merchant API 中,更新會保留,直到該特定產品輸入再次更新或刪除為止。產品更新會套用至ProductInput
資源,而不是處理過的Product
資源。選擇資料來源,讓資料管理更輕鬆:所有
productInputs
寫入作業現在都需要dataSource
查詢參數,明確指出您要修改的資料來源。如果您有多個資料來源,這項功能就特別實用。新資源 ID:產品現在會以 RESTful 資源
name
(而非id
欄位) 做為 ID。格式為accounts/{account}/products/{product}
。沒有自訂批次:
custombatch
方法已無法使用。您可以使用非同步要求或 HTTP 批次處理,在單一 HTTP 呼叫中傳送多個要求。任何動態饋給標籤和語言的資料來源:Merchant API 可建立資料來源,不必指定動態饋給標籤和語言,因此可插入任何動態饋給標籤和語言的產品。
要求
本節將比較 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 批次處理 |
ID
Merchant API 中的產品 ID 格式已變更為標準 REST 資源名稱。
ID 說明 | 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 |
不適用 | 使用 [非同步 |
要求](/merchant/api/samples/insert-product-input-async) 或 HTTP 批次處理。|
詳細欄位變更
下表列出 Merchant API 中已變更、新增或移除的重要欄位。
Content API for Shopping | Merchant API | 說明 |
---|---|---|
id |
name |
產品的主要 ID 現在是 REST 資源 name 。 |
頂層產品資料規格屬性 (例如 title 、price 、link ) |
productAttributes 個物件 |
title 、price 和 link 等產品屬性不再是頂層欄位。現在,Product 和 ProductInput 資源中的物件都會歸類在 productAttributes 物件中。這樣一來,資源結構會更清楚且井然有序。 |
targetCountry |
feedLabel |
資源名稱現在使用 feedLabel ,而非 targetCountry ,以配合 Merchant Center 功能。 |
feedId |
dataSource (查詢參數) |
現在,所有 productInputs 寫入方法 (insert 、update 、delete ) 都必須提供 dataSource 名稱做為查詢參數。 |
channel |
不適用。僅限店面產品使用 legacy_local 。 |
Merchant API 不再提供 channel 欄位。如果產品在 Content API for Shopping 中使用 LOCAL 管道,則應將 legacy_local 欄位設為 true。 |
不適用 | versionNumber |
ProductInput 的新選填欄位,可用來防止順序有誤的插入作業進入主要資料來源。 |
string 類型欄位,並定義一組值 |
enum 類型欄位,並定義一組值 |
現在,產品屬性中具有已定義值集的欄位 (例如 excluded_destinations 、availability ) 為 enum 型別。 |