天天看點

Amazon資料(MWS)詳解(一)名詞解釋Amazon 官方不會告訴你

本篇文章從資料開發的角度出發,力求打通從線上抓取系統到離線分析處理的MWS資料邏輯全流程。開篇包含兩個主要系統的簡介以及Amazon 11個接口的資料特點,分别從Amazon端政策、資料特點角度切入,甚至包含了許多官方文檔未曾提及的部分,來避免新接觸Amazon資料的小夥伴繼續踩坑。文中附注的連結包含了我們資料團隊對于資料的大量細節求證,歡迎在内網上和大家交流。

名詞解釋

名詞 說明
MP Marketplace,外部電商平台。MP data Collection 是采集外部電商平台資料需求
Amazon MWS Amazon Marketplace Web Service, an integrated web service API that helps Amazon sellers to programmatically exchange data on listings, orders, payments, reports, and more
MWS API The Amazon MWS API is divided into sections based on functionality. There are 13 APIs in total

Repot

限流政策

Amazon資料(MWS)詳解(一)名詞解釋Amazon 官方不會告訴你

資料特點

The Reports API section of the Amazon Marketplace Web Service (Amazon MWS) API lets you request various reports that help you manage your Sell on Amazon business. Report types are specified using the ReportTypes enumeration.

一般而言,這類資料相同的create_time時間段(start-endtime此時相去甚遠)存在大量重複,随後的一個請求該時間段的正常請求也會出現在重複資料中。

作為請求過程中最複雜的接口,此處單獨拿出來進行說明。對于Amazon的Report請求是異步進行的,即請求分為三步驟:ReportRequest(請求對應Report類型)->GetReportRequestList(擷取Report狀态)->GetReport(依照GenerateId擷取對應的Report) 

Amazon資料(MWS)詳解(一)名詞解釋Amazon 官方不會告訴你

對于 Report 接口抓取參考代碼中AmazonReportTypeEnum的枚舉類,抓取8類Report報告如下所示,标紅和标黃部分為抓取系統按照業務要求觸達的報告。

Amazon資料(MWS)詳解(一)名詞解釋Amazon 官方不會告訴你

Seller請求的各類含義 

ReportType

參見官網 ,此處簡單說明:FBA代表亞馬遜自建倉庫的資訊,Inventory為賣家庫存資訊。Performance為賣家收到的評價回報資訊。Return為退貨的資訊。由于 Inventory 的兩類重要的 Report 都隻有FlatFile格式,受到 iopengw 超網的限制,程式在

參數中心

配置開關,在Task建立的過程中會将任務的Active狀态設定為N(不被運作)。

Amazon資料(MWS)詳解(一)名詞解釋Amazon 官方不會告訴你

注意:

  1. 請求的時效性:參數設定最多傳回過去90天的資料。
  2. MarketPlaceId的有效性:如果傳入店鋪并未實際經營的MarketPlaceId,會傳回報錯。
  3. Token的有效性:失效傳回AccessDenied。

Report去重邏輯

真實的report資料并如同官方所述的那麼純粹,真實的report資料部分攜帶了snapshot_date字段,如:

REPORT_FBA_INVENTORY_AGE("_GET_FBA_INVENTORY_AGED_DATA_")
REPORT_FBA_INVENTORY_HEALTH("_GET_FBA_FULFILLMENT_INVENTORY_HEALTH_DATA_")      

資料由snapshot_date決定,而不是start_time以及end_time。故在處理資料的時候每個snapshot_date取一份資料即可。

對于其他不包含snapshot的資料其實不好定位其切實位于哪天的,這些report包含:

/**
     * report_inventory
     */
    REPORT_INVENTORY("_GET_FLAT_FILE_OPEN_LISTINGS_DATA_"),
    /**
     * report all listings
     */
    REPORT_ALL_LISTINGS("_GET_MERCHANT_LISTINGS_ALL_DATA_"),
    /**
     * report seller performance
     */
    REPORT_SELLER_PERFORMANCE("_GET_V1_SELLER_PERFORMANCE_REPORT_"),
    /**
     * report return date
     */
    REPORT_RETURN_DATE("_GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE_"),
    /**
     * report fba fee preview
     */
    REPORT_FBA_FEE_PREVIEW("_GET_FBA_ESTIMATED_FBA_FEES_TXT_DATA_"),
    /**
     * report fba manage inventory
     */
    REPORT_FBA_MANAGE_INVENTORY("_GET_FBA_MYI_UNSUPPRESSED_INVENTORY_DATA_")      

對于其中的performance報告,由于是狀态資料,是以每次取到最新的一天就好。return是退貨資訊,對資料明細項的去重也可以保證資料不出現重複。對于all_listing這類使用者售賣資訊,批次抓取後發現使用者每批次資料隻增加不減少。故不需要去重,後續處理取最新資訊即可,曆史資料亦可溯源。但是對于像fba_fee_preview、fba_manage_inventory。由于之前的抓取不足一天,業務的需求是每個完整的報告保留最新的一份。涉及到批次資料和批次資料的比較。SQL中使用了tricky的開窗函數,邏輯如下:

  1. 依照start_end_time對資料進行分組,同時彙總抓取批次的總體資料。
  2. 對ipay_user_id、seller_id、marketplace_id、end_time、fingerprint_list(抓取批次彙總)資料進行去重,同時選取最新的end_time <max(end_time)>
  3. 和源資料進行最後的關聯,同時對源資料的批次内資料(包含start、end Time)進行去重。作為最後的結果。

去重結果:保留每個不重複的批次的抓取,重複批次保留最新批次,同時對批次内的資料進行去重。

境外銀行對amazon資料的具體探索和實驗參見語雀:(省略)

Seller

Amazon資料(MWS)詳解(一)名詞解釋Amazon 官方不會告訴你

The Amazon MWS Sellers API section of the Amazon Marketplace Web Service (Amazon MWS) API lets sellers retrieve information about their seller account, such as the marketplaces they participate in. Along with listing the marketplaces that a seller can sell in, the API also provides additional information about the marketplace such as the default language and the default currency. The API also provides seller-specific information such as whether the seller has suspended listings in that marketplace.

即相應的賣家資訊。風控側想從五個次元來對客戶進行使用者畫像,即:KYB資訊 -> WFAccount ->IpayUserId -> SellerId -> MarketplaceId。KYB資訊來源于WF側維護(表陳舊,極少更新)從上到下分别是1:N 的對應關系。對于seller接口的請求主要為 

ListMarketplaceParticipations

以及

ListMarketplaceParticipationsByNextToken

Amazon資料(MWS)詳解(一)名詞解釋Amazon 官方不會告訴你

在抓取過程中對應單階段,即如果傳回中存在nexToken資訊,将全部請求完成後存儲到對應的資料庫。單階段的抓取在此處不做贅述。

Amazon資料(MWS)詳解(一)名詞解釋Amazon 官方不會告訴你

Order

Order接口分别請求 ListOrders 和 ListOrderItems 接口。

Amazon資料(MWS)詳解(一)名詞解釋Amazon 官方不會告訴你

The ListOrders operation returns a list of orders created or updated during a time frame that you specify. You define that time frame using the CreatedAfter parameter or the LastUpdatedAfter parameter. You must use one of these parameters, but not both. You can also apply a range of filtering criteria to narrow the list of orders that is returned. The ListOrders operation includes order information for each order returned, including AmazonOrderId, OrderStatus, FulfillmentChannel, and LastUpdateDate.

The ListOrderItems operation returns order item information for an AmazonOrderId that you specify. The order item information includes Title, ASIN, SellerSKU, ItemPrice, ShippingPrice, as well as tax and promotion information.

You can retrieve order item information by first using the ListOrders operation to find orders created or updated during a time frame that you specify. An AmazonOrderId is included with each order that is returned. You can then use these AmazonOrderId values with the ListOrderItems operation to get detailed order item information for each order.

任務同樣是單階段執行。多一個步驟是在擷取完所有orderList後将其傳入OrderItems接口,全部請求成功後再将上述兩個階段請求得到的資料存儲入庫。

protected void doHandle(CreditBizHandlerContext context) throws Exception {
        // assemble different api request
        AmazonRequest request = assembleDifferentAPIRequest(context);
        //call Amazon api to get order data
        List<ListOrder> orderList = Lists.newArrayList();
        String nextToken = getOrdersData(request, context, orderList);
        // call Amazon api to order item data
        List<ListerOrderItem> orderItemList = Lists.newArrayList();
        getOrderItemsData(request, orderList, orderItemList);
        // store data
        storeData(nextToken, context, orderList, orderItemList);
    }      

Finance

Amazon資料(MWS)詳解(一)名詞解釋Amazon 官方不會告訴你

finance的抓取和order相類似,兩個關聯接口:finance_event_group 對應 listorderId ,financial_event對應orderItem,但是限流的政策略有不同:order接口的瓶頸在于orderItem的數量。finacial接口的瓶頸在于financial_event_by_next_token.

The ListFinancialEventGroups operation returns a list of financial event groups opened during a time frame specified by the FinancialEventGroupStartedAfter or the FinancialEventGroupStartedBefore request parameters.

Event groups opened more than 18 months before the current date are not returned.

誠如上述官方陳述,目前finance隻顯示status為open狀态的event,在随後的抓取過程之中需要進行回溯才能捕捉到金融事件的狀态變化進行貸中管控政策的配置。finance接口為目前螞蟻金服的特色采集接口,其他企業諸如pingpong,lianlian都隻是擷取settlement ReportAPI 接口進行處理。

由于在資料插入的過程中做了資料幂等處理(即設計financial_event_group_id為unique index)故在目前的抓取過程中預設不存在重複。同時,随着回溯(backTrace)在後續版本的修改,此時資料幂等的唯一健修改為:ipayUserId, groupId和processingStatus三個字段做幂等。

Amazon 官方不會告訴你

1、請求亞馬遜接口時,end_time 必須在目前時間兩分鐘前,否則會報錯。為此我們在某一個版本的疊代中專門修複了這個問題。

2、資料最長回溯時間。部分接口擷取的最早資料和start/endtime 無關,一般而言最長回溯5天。

上一篇: Java Vector 類
下一篇: C 變量