遷移資料來源

本指南說明如何將整合服務從 Content API for Shopping 的 datafeedsdatafeedstatuses 服務遷移至 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,你可以建立主要資料來源,而不必指定 feedLabelcontentLanguage。這類資料來源接受任何 feedLabelcontentLanguage 組合的產品,因此可簡化產品上傳程序,適合不需要為不同區域提供個別資料來源的整合服務。

  • 簡化資料目標。每個資料來源現在都對應至單一目標,該目標由 feedLabelcontentLanguage 的專屬組合定義。Merchant API 已淘汰多資料目標動態饋給。

  • 專屬檔案上傳狀態。Merchant API 會使用獨立的唯讀 fileUploads 資源,代表檔案型資料來源的狀態。如要擷取檔案上傳狀態,請搭配 latest 別名使用 fileUploads.get 方法。

  • 新的資料來源類型DataSource 資源支援更多垂直領域,包括促銷活動、店面商品目錄和區域商品目錄,提供統一的方式來管理所有資料管道。

  • 自動資料來源:現在你可以使用 Merchant API,透過 Accounts 子 API 中的 autofeedSettings.updateAutofeedSettings 方法,為帳戶啟用或停用「自動資料來源」功能。詳情請參閱「設定自動動態饋給」。

選擇資料來源策略

管理資料來源有三種方式:

  • 為任何動態饋給標籤和語言建立單一 Merchant API 資料來源。使用這個選項,透過接受任何產品的單一資料來源,簡化管理作業 feedLabelcontentLanguage。在舊版 Content API 設定中,你會透過個別資料來源定義特定標籤和語言的規則,並將產品插入具有相應目標規則的資料來源。如果選擇這個選項,建議你將所有產品遷移至新的資料來源,並在所有產品遷移完畢後,移除 Content API 資料來源。

  • 為每個標籤和語言建立新的 Merchant API 資料來源。 如果需要支援新的 feedLabelcontentLanguage 組合 (並偏好嚴格區分兩者),或是使用依據特定 feedLabelcontentLanguage 設定的資料來源規則,請使用這個選項。你必須為使用的每組 feedLabelcontentLanguage 建立個別資料來源。你可以將 Merchant API 資料來源與使用 Content API for Shopping 建立的資料來源合併。

  • 保留現有的 Content API 資料來源。你可以繼續使用透過 Content API for Shopping 建立的資料來源,因為這些來源與 Merchant API 相容。你可以使用 dataSources.list 或 Merchant Center 使用者介面找出資源名稱。Content API 主要資料來源僅支援建立時使用的特定 feedLabelcontentLanguage。即使產品是透過 Merchant API 插入,Merchant Center 仍會顯示「Content API」來源的 Content API 資料來源。你可以將這些來源與新的 Merchant API 資料來源合併,這些來源也會指定特定的 feedLabelcontentLanguage 配對。

建議你為每個產品儲存所有主要資料來源的名稱,藉此回填店面產品資料庫,避免重複進行 dataSources.list 呼叫。

要求

下表比較 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.listfileUploads.get

ID

Merchant API 會使用字串型資源名稱做為 ID。

ID 說明 Content API for Shopping Merchant API
資料來源 ID datafeedId (數字) name (字串,格式:accounts/{account}/dataSources/{datasource})

方法

下表比較了 Content API for Shopping datafeedsdatafeedstatuses 服務的方法,以及 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 的 DatafeedDatafeedStatus 資源,以及 Merchant API 的 DataSourceFileUpload 資源,兩者之間欄位層級的異動。

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 無法使用 系統會移除 fileEncodingcolumnDelimiterquotingMode 欄位,因為這些欄位現在會自動偵測。
targets primaryProductDataSource.feedLabelprimaryProductDataSource.contentLanguageprimaryProductDataSource.countries 系統會移除重複的 targets 欄位。現在每個資料來源都有由這些欄位定義的單一目標,反映出多重資料目標動態饋給已淘汰。
DatafeedStatus FileUpload 檔案上傳狀態現在是獨立的唯讀資源。
datafeedId name 檔案上傳的 ID,參照其父項資料來源。
processingStatus processingState 上傳項目的處理狀態。字串值 (successfailurein progress) 會由列舉 (SUCCEEDEDFAILEDIN_PROGRESS) 取代。
errorswarnings issues 錯誤和警告會合併為單一 issues 清單。每個問題都有 severity 欄位 (ERRORWARNING)。
lastUploadDate uploadTime 上次上傳的時間戳記。格式已從字串變更為 Timestamp 物件。
countrylanguagefeedLabel 不適用 這些欄位已從狀態資源中移除,現在屬於 DataSource 資源。
targets[].included_destinationstargets[].excluded_destinations primaryProductDataSource.destinations 系統會以單一 destinations 清單取代包含和不適用目的地這兩份獨立清單。新清單中的每個項目都是物件,可指定目的地及其狀態 (ENABLEDDISABLED),提供更明確的設定。