Amazon Advertising API Request Format
Intro
The official documentation for the Amazon Advertising API has some gaps or poorly worded information regarding the proper configuration of calls to the Advertising API. The goal of this post is to provide a clear example of how to properly configure these requests.
Say for example we would like to make a request to one of these endpoints:
Amazon Advertising API - Sponsored Products
Required Parameters
For basically all of these endpoints we require the following "parameters"
Parameter | What it is |
---|---|
Authentication | Valid Amazon profile Access Token |
Amazon-Advertising-API-ClientId | The client ID from developer registration process |
Amazon-Advertising-API-Scope | The Advertising Profile ID |
Getting these credentials is a multi-step process. The client ID is a fairly straightforward part of the application to the API so if you are reading this you likely already have this. This ID remains static regardless of which advertising profile we are querying and does not expire. Therefore we will not cover how to obtain this in this post.
Getting the Access Token
The documentation to retrieve the Access Token is covered in reasonable detail, but the exact configuration of the request is tricky. Here is a screenshot of a Postman setup.
Note the very specific Content-Type
of application/x-www-form-urlencoded;charset=UTF-8
And then for the body note the following settings.
These will vary depending on whether you are exchanging an auth code or a refresh token, but the format is basically the same.
Be absolutely certain that you are not making your secret key publicly available. This request cannot be sent directly from a web application client, it must be sent from a secure server, or if you are running a serverless application architecture, you must route this request through Lambda or a similar service.
At this point we have two of the three key pieces of information that we require to make requests to the advertising API. All we have left is...
Getting the Profile ID
Commonly an Amazon account will have access to more than one advertising profile, therefore when we make the request for the profiles information we get back an array of advertising profile data. If the Amazon account does not have access to any advertising profiles the array will be empty.
Note that in this instance we only require the Client ID and User Access Token. Also the body of the request is blank.
Putting It All Together
We now have the three items that we need we can put together a request to a list of Advertising Campaigns for our chosen advertising profile.
The official documentation refers to the Client ID and Scope as parameters, but they are in fact headers. Adding these items as parameters will fail the request.
Once your request is working properly in Postman you can then convert it to whatever format you like.
Comments
Recent Work
Basalt
basalt.softwareFree desktop AI Chat client, designed for developers and businesses. Unlocks advanced model settings only available in the API. Includes quality of life features like custom syntax highlighting.
BidBear
bidbear.ioBidbear is a report automation tool. It downloads Amazon Seller and Advertising reports, daily, to a private database. It then merges and formats the data into beautiful, on demand, exportable performance reports.