目錄
1. 前提概要
1.1. 流程對比
1.1.1. MWS 流程
1.1.2. SP-API 流程
1.2. 官方檔案
1.2.1. ReportType Values
1.2.2. ReportType 請求體
1.2.3. 請求教程
1.3. 下面內容會以 ALL_ORDERS 為案例
2. HTTP 對接
Step 1. Request a report
2.1.1. Headers
2.1.2. Body
2.1.3. 完整請求 URL
Step 2. Confirm report processing has completed
Step 3. Retrieve the report
3. SDK 對接
總結
這一章我將會展示完整的流程,其他模塊將不再重復相似的步驟了,
1. 前提概要
1.1. 流程對比
1.1.1. MWS 流程
RequestReport ==> GetReportRequestList ==> GetReport
1.1.2. SP-API 流程
createReport ==> getReport ==> getReportDocument ==> decrypt
1.2. 官方檔案
1.2.1. ReportType Values
這部分介紹了有哪些列舉類,
https://github.com/amzn/selling-partner-api-docs/blob/main/references/reports-api/reportType_string_array_values.md
1.2.2. ReportType 請求體
這部分介紹了 HTTP 請求的 body 的引數有哪些,
https://github.com/amzn/selling-partner-api-docs/blob/main/references/reports-api/reports_2020-09-04.md
1.2.3. 請求教程
https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/use-case-guides/reports-api-use-case-guide/reports-api-use-case-guide-2020-09-04.md
1.3. 下面內容會以 ALL_ORDERS 為案例
2. HTTP 對接
Step 1. Request a report
2.1.1. Headers
Authorization: AWS4-HMAC-SHA256 Credential=ABCXXXXXXX/20210423/us-east-1/execute-api/aws4_request, SignedHeaders=host;user-agent;x-amz-access-token, Signature=5d672d79c15b13162d9279b0855cfba6789a8edb4c82c400e06b5924aEXAMPLE
user-agent: My Selling Tool/2.0 (Language=Java/1.8.0.221;Platform=Windows/10)
x-amz-access-token=Atza|IQEBLjAsAhRmHjNgHpi0U-Dme37rR6CuUpSREXAMPLE
x-amz-date: 20210423T123400Z
| Name | Description |
|---|---|
| x-amz-date | The date and time of your request. |
| user-agent | Your application name and version number, platform, and programming language. These help Amazon diagnose and fix problems you might encounter with the service. See Include a User-Agent header in all requests. 應用程式名稱和版本號、平臺和編程語言 |
2.1.1.1. x-amz-access-token
access token 有效期為一個小時,我們可以通過 refresh token 獲取最新的 access token,
cURL
curl --location --request POST 'https://api.amazon.com/auth/o2/token' \
--header 'Content-Type: application/x-www-form-urlencoded;charset=UTF-8' \
--data-raw 'grant_type=refresh_token&refresh_token={refresh_token}&client_id={CLIENT_ID}&client_secret={CLIENT_SECRET}'

2.1.1.2. Authorization
對接亞馬遜 SP-API(Selling Partner API) 第四章:簽名
2.1.2. Body
| Name | Description | Required |
|---|---|---|
| reportOptions | Additional information passed to reports. This varies by report type. Type: ReportOptions | No |
| reportType | The report type. For more information, see reportType values. Type: string | Yes |
| dataStartTime | The start of a date and time range, in ISO 8601 date time format, used for selecting the data to report. The default is now. The value must be prior to or equal to the current date and time. Not all report types make use of this. Type: string (date-time) | No |
| dataEndTime | The end of a date and time range, in ISO 8601 date time format, used for selecting the data to report. The default is now. The value must be prior to or equal to the current date and time. Not all report types make use of this. Type: string (date-time) | No |
| marketplaceIds | A list of marketplace identifiers. The report document's contents will contain data for all of the specified marketplaces, unless the report type indicates otherwise. Type: < string > array | Yes |
{
"reportType": "GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL",
"dataStartTime": "2021-04-20T00:00:00.000Z",
"marketplaceIds": [
"A1PA6795UKMFR9",
"ATVPDKIKX0DER"
]
}
2.1.3. 完整請求 URL
cUrl
curl --location --request POST 'https://sellingpartnerapi-na.amazon.com/reports/2020-09-04/reports' \
--header 'Authorization: Authorization' \
--header 'user-agent: My Selling Tool/2.0 (Language=Java/1.8.0.221;Platform=Windows/10)' \
--header 'x-amz-access-token: Atza|XXX' \
--header 'x-amz-date: 20210423T123400' \
--header 'Content-Type: application/json' \
--data-raw '{
"reportType": "GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL",
"dataStartTime": "2021-04-20T00:00:00.000Z",
"marketplaceIds": [
"A1PA6795UKMFR9",
"ATVPDKIKX0DER"
]
}'
Step 2. Confirm report processing has completed
Step 3. Retrieve the report
3. SDK 對接
總結
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/279860.html
標籤:區塊鏈
