Lets get started with Amazon Advertising API…
Amazon provide sellers and vendor to advertise their products on Amazon. The Amazon Advertising API power the sellers and vendor to automate, scale and optimize their advertising campaign for Sponsored Product, Sponsored Brand and Sponsored Display through the API by enabling programmatic access to Campaign Management and Reporting.
You can read more on Amazon Advertising API more on https://advertising.amazon.com/about-api.
Amazon Advertising API documentation is tricky for a new developer to get started with, I will provide a detailed step we need to perform to implement the API, including all the technical details.
Read more on Amazon Advertising API at https://advertising.amazon.com/API/docs/en-us/what-is/amazon-advertising-api
Step 1: Apply for API access
We need to apply for API access by completing the signup form. Please specify which APIs you wish to use in the Comments field:
This can be any of Data Provider, DSP, Sponsored Display, Sponsored Brands, or Sponsored Products.
Your request will be reviewed and, if approved, you will receive an email confirmation with instructions to complete the onboarding process. This process usually takes 3–4 working days.
Step 2: Create a new Amazon Developer account or use your existing Amazon Developer account.
Go to the Amazon Developer site. Note that the URL for the Login with Amazon site is https://developer.amazon.com/
Sign in with the Amazon account you will use with the API, or create a new account.
Step 3: Create a new security profile in Amazon Developer account.
a. Go to https://developer.amazon.com/dashboard
b. Click login with Amazon on the menu bar.
c. Click create a new security profile.
d. You’re redirected to the security profile management page. Enter a security profile name, security profile description, and your consent privacy notice URL.
e. Select the Save button when you’ve entered this information. You’re redirected to the login with Amazon page.
d. This page includes a table that lists your security profile name and OAuth2 credentials. Locate the name of the security profile you created earlier, and click show client ID and client secret. These unique values are used to generate the necessary tokens for use with the Advertising API. Note that these values can be retrieved from this panel at any time.
Step 4: Get an authorization code
An Amazon Advertising API authorization code is used to generate both authorization and refresh tokens. Authorization codes are generated in the region where the API is called. The API call to retrieve an authorization code has a different URL for each region:
North America (NA)https://www.amazon.com/ap/oa
Europe (EU)https://eu.account.amazon.com/ap/oa
Far East (FE)https://apac.account.amazon.com/ap/oa
For example, to generate an authorization code in the North America (NA) region, replace the values in the URL below with your values from your Amazon developer account:
https://www.amazon.com/ap/oa?client_id=<CLIENT_ID>&scope=advertising::campaign_management&response_type=code&redirect_uri=<YOUR_RETURN_URL>
Once you’ve navigated to the URL, you’re prompted to sign in with the Seller Central account you used to register your application at Login with Amazon.
Once you’ve signed in, you’re redirected to a consent form:
To grant application access to Amazon Advertising, select Allow. To deny application access to Amazon Advertising, select Cancel.
If you selected Allow in step 3, your browser is redirected to the Amazon site for the same region as the URL used in step 1.
Select and copy the URL string from your browser’s address bar. Paste the URL string into a text editor. Make note of the value of the code
query parameter. The code
query parameter is the authorization code that is exchanged for the authorization token and the refresh tokens in the next step.
For example, the URL string from your browser’s address bar will resemble: https://www.amazon.com/?code=xxxxxxxxxxxxxxxxxxx&scope=cpc_advertising%3Acampaign_management
Step 5: Call the authorization URL to request authorization and refresh tokens
To retrieve authorization and refresh tokens, select the authorization URL for the same region as the URL used in step 1. Note that authorization tokens are valid for 60 minutes and must refreshed using the refresh token once they expire. Refresh tokens do not expire.
Authorization token:
curl \ -X POST \ -H “Content-Type:application/x-www-form-urlencoded;charset=UTF-8” \ — data “grant_type=authorization_code&code=<AUTH_CODE_FROM_PREVIOUS_STEP>&redirect_uri=<YOUR_RETURN_URL>&client_id=<YOUR_CLIENT_ID>&client_secret=<YOUR_SECRET_KEY>” \ https://api.amazon.com/auth/o2/token
Refresh Token:
curl \ -X POST \ -H “Content-Type:application/x-www-form-urlencoded;charset=UTF-8” \ — data “grant_type=refresh_token&client_id=<YOUR_CLIENT_ID>&refresh_token=<YOUR_REFRESH_TOKEN>&client_secret=<YOUR_CLIENT_SECRET>” \ https://api.amazon.com/auth/o2/token
Step 6: Amazon Advertising API — Profiles
Profiles represent an advertiser and their account’s marketplace, and are used in all subsequent API calls via a management scope, Amazon-Advertising-API-Scope
. Reports and all entity management operations are associated with a single profile. Advertisers cannot have more than one profile for each marketplace.
Advertisers who operate in more than one marketplace will have only one profile associated with each marketplace.
Use the returned profileId
as the value for the management scope (Amazon-Advertising-API-Scope
) in the headers for subsequent API calls. To retrieve your profile ids, call the listProfiles operation, and include a valid authorization access token in the header.
Sample call:
curl -X GET -H “Amazon-Advertising-API-ClientId: <YOUR_CLIENT_ID>;Content-Type: application/x-www-form-urlencoded” — data “authorization=Bearer <REFRESH_TOKEN>” https://advertising-api.amazon.com/v2/profiles
Get the profile id from the response and save it in database.
Now, we are ready to make the API call.
Step 7: Making a test API call
For making a test API call, lets list out the All Campaign created by the Amazon Seller. The below curl code will request all Campaign created by the Seller in Advertising Console.
Request:
curl — location — request GET ‘https://advertising-api.amazon.com/v2/sp/campaigns’ \
— header ‘Amazon-Advertising-API-ClientId: <Amazon Developer Account Client ID>’ \
— header ‘Amazon-Advertising-API-Scope: <Profile ID>\
— header ‘Authorization: Bearer <Refresh Token>’ \
— header ‘Content-Type: application/json’
Response:
[
{
“campaignId”: 21675701877XXXX,
“name”: “MWF”,
“campaignType”: “sponsoredProducts”,
“targetingType”: “manual”,
“premiumBidAdjustment”: false,
“dailyBudget”: 50.0,
“startDate”: “20150425”,
“state”: “archived”,
“bidding”: {
“adjustments”: []
}
},
{…}
]
In the next medium article, i will share how to download the Advertising Report i.e. Campaign, Ads Group, Product Ads, Keywords, Targeting and Asin report.
This is how we use Amazon Advertising API to get the analytics data for a Seller. We worked with various Amazon Seller and help them with the integration to Amazon Advertising API for analytics.
Reach out to me for any help on Amazon SP-API and Amazon Advertising API on [email protected] or [email protected] or on Skype “live:jain.jayesh” and visit our amazon mws services page on our website.