本指南說明如何將整合服務從 Content API for Shopping 的 datafeeds 和 datafeedstatuses 服務,遷移至 Merchant API 中的資料來源子 API。新的資料來源子 API 可更直接地控管資料管道,並簡化資料來源管理作業。
如要進一步瞭解新功能,請參閱「管理資料來源」指南。
主要差異
相較於 Content API for Shopping,Merchant API 有多項優勢。
- 明確建立資料來源。API 不再於首次插入產品時,自動建立「Content API」資料來源。在 Merchant API 中,你必須先明確建立資料來源,才能將產品上傳至這些來源。這樣一來,您就能從一開始就進一步控管產品資料管道的組織和管理作業。 
- 支援多個 API 資料來源。在 Content API for Shopping 中,你只能使用系統自動建立的單一「Content API」資料來源。你可以使用 Merchant API 建立及管理 - API輸入類型資料的多個資料來源。
- 沒有標籤和語言的資料來源。透過 Merchant API,你無須指定 - feedLabel和- contentLanguage,即可建立主要資料來源。這類資料來源接受以任意組合的- feedLabel和- contentLanguage形式提交產品,因此如果整合服務不需要為不同地區提供個別資料來源,就能簡化產品上傳程序。
- 簡化資料目標。現在每個資料來源都會對應至單一目標,並由 - feedLabel和- contentLanguage的專屬組合定義。Merchant API 已淘汰多資料目標動態饋給。
- 專屬檔案上傳狀態。Merchant API 會使用獨立的唯讀 - fileUploads資源,代表檔案型資料來源的狀態。如要擷取檔案上傳狀態,請搭配- latest別名使用- fileUploads.get方法。
- 新資料來源類型。 - DataSource資源支援更多垂直產業,包括促銷活動、店面商品目錄和區域商品目錄,提供統一的方式來管理所有資料管道。
- 自動資料來源。現在你可以使用 Merchant API,透過 Accounts 子 API 中的 - autofeedSettings.updateAutofeedSettings方法,為帳戶啟用或停用自動資料來源功能。詳情請參閱「設定自動動態饋給設定」。
要求
下表比較 Content API for Shopping 和 Merchant API 的要求網址格式。
| 要求說明 | Content API for Shopping | Merchant API | 
|---|---|---|
| 建立資料來源 | POST https://shoppingcontent.googleapis.com/content/v2.1/{MERCHANT_ID}/datafeeds | POST https://merchantapi.googleapis.com/v1/accounts/{ACCOUNT_ID}/dataSources | 
| 取得資料來源 | GET https://shoppingcontent.googleapis.com/content/v2.1/{MERCHANT_ID}/datafeeds/{DATAFEED_ID} | GET https://merchantapi.googleapis.com/v1/accounts/{ACCOUNT_ID}/dataSources/{DATASOURCE_ID} | 
| 列出資料來源 | GET https://shoppingcontent.googleapis.com/content/v2.1/{MERCHANT_ID}/datafeeds | GET https://merchantapi.googleapis.com/v1/accounts/{ACCOUNT_ID}/dataSources | 
| 更新資料來源 | PUT https://shoppingcontent.googleapis.com/content/v2.1/{MERCHANT_ID}/datafeeds/{DATAFEED_ID} | PATCH https://merchantapi.googleapis.com/v1/accounts/{ACCOUNT_ID}/dataSources/{DATASOURCE_ID} | 
| 刪除資料來源 | DELETE https://shoppingcontent.googleapis.com/content/v2.1/{MERCHANT_ID}/datafeeds/{DATAFEED_ID} | DELETE https://merchantapi.googleapis.com/v1/accounts/{ACCOUNT_ID}/dataSources/{DATASOURCE_ID} | 
| 擷取資料來源 | POST https://shoppingcontent.googleapis.com/content/v2.1/{MERCHANT_ID}/datafeeds/{DATAFEED_ID}/fetchNow | POST https://merchantapi.googleapis.com/v1/accounts/{ACCOUNT_ID}/dataSources/{DATASOURCE_ID}:fetch | 
| 取得資料來源狀態 | GET https://shoppingcontent.googleapis.com/content/v2.1/{MERCHANT_ID}/datafeedstatuses/{DATAFEED_ID} | GET https://merchantapi.googleapis.com/v1/accounts/{ACCOUNT_ID}/dataSources/{DATASOURCE_ID}/fileUploads/latest | 
| 列出資料來源狀態 | GET https://shoppingcontent.googleapis.com/content/v2.1/{MERCHANT_ID}/datafeedstatuses | 不適用。針對每個檔案型資料來源使用 dataSources.list和fileUploads.get。 | 
ID
Merchant API 會使用以字串為基礎的資源名稱做為 ID。
| ID 說明 | Content API for Shopping | Merchant API | 
|---|---|---|
| 資料來源 ID | datafeedId(數字) | name(字串,格式:accounts/{account}/dataSources/{datasource}) | 
方法
下表比較 Content API for Shopping datafeeds
和 datafeedstatuses 服務的方法,以及 Merchant API 中的對應方法。
| Content API for Shopping 方法 | Merchant API 方法 | 適用情形和注意事項 | 
|---|---|---|
| datafeeds.custombatch | 不適用 | 請改用個別 API 呼叫。 | 
| datafeeds.delete | dataSources.delete | 有。 | 
| datafeeds.fetchnow | dataSources.fetch | 有。這個方法現在僅適用於以檔案輸入的資料來源。 | 
| datafeeds.get | dataSources.get | 有。 | 
| datafeeds.insert | dataSources.create | 有。 | 
| datafeeds.list | dataSources.list | 有。 | 
| datafeeds.update | dataSources.update | 有。使用 PATCH語意,而非PUT。 | 
| datafeedstatuses.custombatch | 不適用 | 請改用個別 API 呼叫。詳情請參閱「一次傳送多個要求」。 | 
| datafeedstatuses.get | fileUploads.get | 適用於檔案型資料來源。使用 latest別名取得最近一次上傳的狀態。如果是其他資料來源類型,狀態資訊會是DataSource資源的一部分。 | 
| datafeedstatuses.list | 不適用 | 如要取得多個資料來源的狀態,請先使用 dataSources.list列出所有資料來源。然後針對每個檔案型資料來源,使用latest別名呼叫fileUploads.get。 | 
詳細欄位變更
下表列出 Content API for Shopping 的 Datafeed 和 DatafeedStatus 資源,以及 Merchant API 的 DataSource 和 FileUpload 資源之間,欄位層級的異動。
| Content API for Shopping | Merchant API | 說明 | 
|---|---|---|
| Datafeed | DataSource | 資料來源設定的主要資源。 | 
| id | name | 資源 ID。從數值 ID 變更為字串資源名稱。 | 
| name | displayName | 資料來源的顯示名稱。 | 
| attributeLanguage | primaryProductDataSource.contentLanguage | 資料來源中項目的雙字母格式 ISO 639-1 語言代碼。 | 
| fileName | fileInput.fileName | 上傳檔案的名稱。這個欄位現在位於 fileInput底下。 | 
| fetchSchedule | fileInput.fetchSettings | 擷取檔案型資料來源的時間表。現在已巢狀結構化至 fileInput下。 | 
| fetchSchedule.paused | fileInput.fetchSettings.enabled | 邏輯會反轉。 paused: true相當於enabled: false。 | 
| format | 不適用 | 已移除 fileEncoding、columnDelimiter和quotingMode欄位。系統現在會自動偵測這些項目。 | 
| targets | primaryProductDataSource.feedLabel、primaryProductDataSource.contentLanguage、primaryProductDataSource.countries | 移除重複的 targets欄位。現在每個資料來源都只有一個目標,由這些欄位定義,反映出多重資料目標動態饋給已淘汰。 | 
| DatafeedStatus | FileUpload | 檔案上傳狀態現在是獨立的唯讀資源。 | 
| datafeedId | name | 檔案上傳的 ID,參照其父項資料來源。 | 
| processingStatus | processingState | 上傳項目的處理狀態。字串值 ( success、failure、in progress) 會由列舉 (SUCCEEDED、FAILED、IN_PROGRESS) 取代。 | 
| errors、warnings | issues | 錯誤和警告會合併為單一 issues清單。每個問題都有severity欄位 (ERROR或WARNING)。 | 
| lastUploadDate | uploadTime | 上次上傳的時間戳記。格式已從字串變更為 Timestamp物件。 | 
| country、language、feedLabel | 不適用 | 狀態資源不再包含這些欄位。這些是 DataSource資源的一部分。 | 
| targets[].included_destinations、targets[].excluded_destinations | primaryProductDataSource.destinations | 系統會以單一 destinations清單,取代包含和排除目的地的兩個獨立清單。新清單中的每個項目都是物件,可指定目的地及其狀態 (ENABLED或DISABLED),提供更明確的設定。 |