本指南說明如何將整合服務從 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方法,為帳戶啟用或停用自動資料來源功能。詳情請參閱「設定自動動態饋給」。
選擇資料來源策略
管理資料來源有三種方式:
為任何動態饋給標籤和語言建立單一 Merchant API 資料來源。使用這個選項,透過接受任何產品的單一資料來源,簡化管理作業
feedLabelcontentLanguage。在舊版 Content API 設定中,你會透過個別資料來源定義特定標籤和語言的規則,並將產品插入具有相應目標規則的資料來源。如果選擇這個選項,建議你將所有產品遷移至新的資料來源,並在所有產品遷移完畢後,移除 Content API 資料來源。為每個標籤和語言建立新的 Merchant API 資料來源。 如果您需要支援新的
feedLabel和contentLanguage組合 (且偏好嚴格區分兩者),或是使用依賴特定feedLabel和contentLanguage的資料來源規則設定,請使用這個選項。您必須為使用的每組feedLabel和contentLanguage建立個別的資料來源。你可以將 Merchant API 資料來源與使用 Content API for Shopping 建立的資料來源合併。
- 保留現有的 Content API 資料來源。你仍可繼續使用透過 Content API for Shopping 建立的資料來源,因為這些資料來源與 Merchant API 相容。你可以使用
dataSources.list或 Merchant Center 使用者介面,找出資源名稱。Content API 主要資料來源僅支援建立時使用的特定feedLabel和contentLanguage。即使產品是使用 Merchant API 插入,Merchant Center 仍會顯示「Content API」來源的 Content API 資料來源。你可以將這些資料來源與新的 Merchant API 資料來源合併,這些資料來源也會指定feedLabel和contentLanguage配對。
建議您為每個產品儲存所有主要資料來源的名稱,藉此回填店面產品資料庫,避免重複進行 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.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),提供更明確的設定。 |