亚马逊广告API调用步骤
本教程用Python做描述, 分三步, 分别是获取授权token,获取店铺profile,获取广告活动列表
获取亚马逊广告授权TOKEN
import requests
import json
url = "https://api.amazon.com/auth/o2/token"
payload = json.dumps({
"grant_type": "refresh_token",
"refresh_token": "用户授权获取到的refresh_token",
"client_id": "amzn1.application-oa2-client.开发者ID",
"client_secret": "开发者client_secret"
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
# {
# "access_token": "Atza|access_token",
# "refresh_token": "Atzr|refresh_token",
# "token_type": "bearer",
# "expires_in": 3600
# }
获取店铺列表
import requests
import json
url = "https://advertising-api.amazon.com/v2/profiles"
headers = {
'Content-Type': 'application/json',
'Authorization': 'bearer refresh_token获取到的授权access_token',
'Amazon-Advertising-API-ClientId': 'amzn1.application-oa2-client.开发者ID'
}
response = requests.request("GET", url, headers=headers)
print(response.text)
# [
# {
# "profileId": 100000086,
# "countryCode": "BR",
# "currencyCode": "BRL",
# "timezone": "America/Sao_Paulo",
# "accountInfo": {
# "marketplaceStringId": "A2Q3Y263D00KWC",
# "id": "ENTITY4XXXXXX",
# "type": "vendor",
# "name": "XXXX-XXXX",
# "validPaymentMethod": true
# }
# }
# ]
获取广告活动列表
import requests
import json
url = "https://advertising-api.amazon.com/v2/sp/campaigns/extended"
headers = {
'Content-Type': 'application/json',
'Authorization': 'bearer refresh_token获取到的授权access_token',
'Amazon-Advertising-API-ClientId': 'amzn1.application-oa2-client.开发者ID'
'Amazon-Advertising-API-Scope': '100000086店铺的profileId'
}
response = requests.request("GET", url, headers=headers)
print(response.text)
# [
# {
# "campaignId": 100002220,
# "name": "SP-test-0001",
# "campaignType": "sponsoredProducts",
# "targetingType": "manual",
# "premiumBidAdjustment": false,
# "dailyBudget": 1.0,
# "startDate": "20220608",
# "state": "archived",
# "bidding": {
# "strategy": "legacyForSales",
# "adjustments": []
# },
# "servingStatus": "CAMPAIGN_ARCHIVED",
# "creationDate": 1654744776732,
# "lastUpdatedDate": 1657093194579
# }
# ]
完成这三步, 最基本的API调用已经没问题了.更多参考API文档
当然, 深入进去肯定是需要了解亚马逊广告知识的,所以,最好能有广告业务侧协助.