Product Advertising API 5.0 Scratchpad
Scratchpad is a tool to help Amazon Associates send basic requests to the Product Advertising API. Follow the steps below and you can have a working request with sample code in minutes.
Getting Started
Additional Resources
Get started with the Product Advertising API 5.0 Scratchpad.
See instructions for retrieving your Access Key and Secret Key.
See the complete API documentation to learn more.
Review best practices for using the API.
Join the community of developers using our service.
View terms and conditions that govern your access to and use of the Product Advertising API.
Given a BrowseNodeId, GetBrowseNodes operation returns the specified browse node’s name, children and ancestors.
Given an item identifier, the GetVariations operation returns the variation for a given items and its information depending on the resources requested.
Given an item identifier, the GetItems operation returns some or all of item attributes depending on the resources requested.
SearchItems operation searches for items on Amazon using keywords and other refinement options.
Response types
{
"Message": "JSON response here."
}
{
"Message": "JSON response here."
}
<div class="alert alert-info" role="alert">
<span id="InfoMessage">Rendered response will be displayed here</span>
</div>
<style>
.paapi5-pa-ad-unit {
border: 1px solid #eee;
margin:2px;
position: relative;
overflow: hidden;
padding: 22px 20px;
line-height: 1.1em;
}
.paapi5-pa-ad-unit * {
box-sizing: content-box;
box-shadow: none;
font-family: Arial, Helvetica, sans-serif;
margin: 0;
outline: 0;
padding: 0;
}
.paapi5-pa-ad-unit.pull-left {
float: left;
}
.paapi5-pa-ad-unit.pull-right {
float: right;
}
.paapi5-pa-ad-unit a {
box-shadow: none !important;
}
.paapi5-pa-ad-unit a:hover {
color: #c45500;
}
.paapi5-pa-product-container {
width: 180px;
height: 210px;
}
/* fixed width and height of product image to 150px */
.paapi5-pa-product-image {
display: table;
width: 150px;
height: 150px;
margin: 0 auto;
text-align: center;
}
.paapi5-pa-product-image-wrapper {
display: table-cell;
vertical-align: middle;
}
.paapi5-pa-product-image-link {
position: relative;
display: inline-block;
vertical-align: middle;
}
.paapi5-pa-product-image-source {
max-width: 150px;
max-height: 150px;
vertical-align: bottom;
}
.paapi5-pa-percent-off {
display: block;
width: 32px;
height: 25px;
padding-top: 8px;
position: absolute;
top: -16px;
right: -16px;
color: #ffffff;
font-size: 12px;
text-align: center;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
-ms-border-radius: 50%;
border-radius: 50%;
background-color: #a50200;
background-image: -webkit-linear-gradient(top, #cb0400, #a50200);
background-image: linear-gradient(to bottom, #cb0400, #a50200);
}
.paapi5-pa-ad-unit.hide-percent-off-badge .paapi5-pa-percent-off {
display: none;
}
.paapi5-pa-product-details {
display: inline-block;
max-width: 100%;
margin-top: 11px;
text-align: center;
width: 100%;
}
.paapi5-pa-ad-unit .paapi5-pa-product-title a {
display: block;
width: 100%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
font-size: 13px;
color: #0066c0;
text-decoration: none;
margin-bottom: 3px;
}
.paapi5-pa-ad-unit .paapi5-pa-product-title a:hover {
text-decoration: underline;
color: #c45500;
}
.paapi5-pa-ad-unit.no-truncate .paapi5-pa-product-title a {
text-overflow: initial;
white-space: initial;
}
.paapi5-pa-product-offer-price {
font-size: 13px;
color: #111111;
}
.paapi5-pa-product-offer-price-value {
color: #AB1700;
font-weight: bold;
font-size: 1.1em;
margin-right: 3px;
}
.paapi5-pa-product-list-price {
font-size: 13px;
color: #565656;
}
.paapi5-pa-product-list-price-value {
text-decoration: line-through;
font-size: 0.99em;
}
.paapi5-pa-product-prime-icon .icon-prime-all {
background: url("https://images-na.ssl-images-amazon.com/images/G/01/AUIClients/AmazonUIBaseCSS-sprite_2x_weblab_AUI_100106_T1-4e9f4ae74b1b576e5f55de370aae7aedaedf390d._V2_.png") no-repeat;
display: inline-block;
margin-top: -1px;
vertical-align: middle;
background-position: -192px -911px;
background-size: 560px 938px;
width: 52px;
height: 15px;
}
.paapi5-pa-product-offer-price,
.paapi5-pa-product-list-price,
.paapi5-pa-product-prime-icon {
display: inline-block;
margin-right: 3px;
}
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
.paapi5-pa-ad-unit .paapi5-pa-product-prime-icon .icon-prime-all {
background: url("https://images-na.ssl-images-amazon.com/images/G/01/AUIClients/AmazonUIBaseCSS-sprite_2x_weblab_AUI_100106_T1-4e9f4ae74b1b576e5f55de370aae7aedaedf390d._V2_.png") no-repeat;
display: inline-block;
margin-top: -1px;
vertical-align: middle;
background-position: -192px -911px;
background-size: 560px 938px;
width: 52px;
height: 15px;
}
}
/* css for mobile devices when device width is less than 441px*/
@media screen and (max-width: 440px) {
.paapi5-pa-ad-unit {
float: none;
width: 100%;
}
.paapi5-pa-product-container {
margin: 0 auto;
width: 100%;
}
.paapi5-pa-product-details {
text-align: center;
margin-top: 11px;
}
}
</style>
<div class="alert alert-info" role="alert">
<span id="InfoMessage">Rendered response will be displayed here</span>
</div>
<style>
.paapi5-pa-ad-unit {
border: 1px solid #eee;
margin:2px;
position: relative;
overflow: hidden;
padding: 22px 20px;
line-height: 1.1em;
}
.paapi5-pa-ad-unit * {
box-sizing: content-box;
box-shadow: none;
font-family: Arial, Helvetica, sans-serif;
margin: 0;
outline: 0;
padding: 0;
}
.paapi5-pa-ad-unit.pull-left {
float: left;
}
.paapi5-pa-ad-unit.pull-right {
float: right;
}
.paapi5-pa-ad-unit a {
box-shadow: none !important;
}
.paapi5-pa-ad-unit a:hover {
color: #c45500;
}
.paapi5-pa-product-container {
width: 180px;
height: 210px;
}
/* fixed width and height of product image to 150px */
.paapi5-pa-product-image {
display: table;
width: 150px;
height: 150px;
margin: 0 auto;
text-align: center;
}
.paapi5-pa-product-image-wrapper {
display: table-cell;
vertical-align: middle;
}
.paapi5-pa-product-image-link {
position: relative;
display: inline-block;
vertical-align: middle;
}
.paapi5-pa-product-image-source {
max-width: 150px;
max-height: 150px;
vertical-align: bottom;
}
.paapi5-pa-percent-off {
display: block;
width: 32px;
height: 25px;
padding-top: 8px;
position: absolute;
top: -16px;
right: -16px;
color: #ffffff;
font-size: 12px;
text-align: center;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
-ms-border-radius: 50%;
border-radius: 50%;
background-color: #a50200;
background-image: -webkit-linear-gradient(top, #cb0400, #a50200);
background-image: linear-gradient(to bottom, #cb0400, #a50200);
}
.paapi5-pa-ad-unit.hide-percent-off-badge .paapi5-pa-percent-off {
display: none;
}
.paapi5-pa-product-details {
display: inline-block;
max-width: 100%;
margin-top: 11px;
text-align: center;
width: 100%;
}
.paapi5-pa-ad-unit .paapi5-pa-product-title a {
display: block;
width: 100%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
font-size: 13px;
color: #0066c0;
text-decoration: none;
margin-bottom: 3px;
}
.paapi5-pa-ad-unit .paapi5-pa-product-title a:hover {
text-decoration: underline;
color: #c45500;
}
.paapi5-pa-ad-unit.no-truncate .paapi5-pa-product-title a {
text-overflow: initial;
white-space: initial;
}
.paapi5-pa-product-offer-price {
font-size: 13px;
color: #111111;
}
.paapi5-pa-product-offer-price-value {
color: #AB1700;
font-weight: bold;
font-size: 1.1em;
margin-right: 3px;
}
.paapi5-pa-product-list-price {
font-size: 13px;
color: #565656;
}
.paapi5-pa-product-list-price-value {
text-decoration: line-through;
font-size: 0.99em;
}
.paapi5-pa-product-prime-icon .icon-prime-all {
background: url("https://images-na.ssl-images-amazon.com/images/G/01/AUIClients/AmazonUIBaseCSS-sprite_2x_weblab_AUI_100106_T1-4e9f4ae74b1b576e5f55de370aae7aedaedf390d._V2_.png") no-repeat;
display: inline-block;
margin-top: -1px;
vertical-align: middle;
background-position: -192px -911px;
background-size: 560px 938px;
width: 52px;
height: 15px;
}
.paapi5-pa-product-offer-price,
.paapi5-pa-product-list-price,
.paapi5-pa-product-prime-icon {
display: inline-block;
margin-right: 3px;
}
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
.paapi5-pa-ad-unit .paapi5-pa-product-prime-icon .icon-prime-all {
background: url("https://images-na.ssl-images-amazon.com/images/G/01/AUIClients/AmazonUIBaseCSS-sprite_2x_weblab_AUI_100106_T1-4e9f4ae74b1b576e5f55de370aae7aedaedf390d._V2_.png") no-repeat;
display: inline-block;
margin-top: -1px;
vertical-align: middle;
background-position: -192px -911px;
background-size: 560px 938px;
width: 52px;
height: 15px;
}
}
/* css for mobile devices when device width is less than 441px*/
@media screen and (max-width: 440px) {
.paapi5-pa-ad-unit {
float: none;
width: 100%;
}
.paapi5-pa-product-container {
margin: 0 auto;
width: 100%;
}
.paapi5-pa-product-details {
text-align: center;
margin-top: 11px;
}
}
</style>
Response time : 00.00 ms
Code snippets
/* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
/* Licensed under the Apache License, Version 2.0. */
/**
* Download the following artifacts and add to your projects classpath:
* o httpclient-4.5.5.jar
* o httpcore-4.4.9.jar
* o commons-logging-1.2.jar
* o json-20180130.jar
* Put your Secret Key in place of **********
* Make sure AWSV4Auth Class is available in same package
*/
package com.amazon.paapi.scratchpad;
import java.util.Map;
import java.util.TreeMap;
import java.nio.charset.StandardCharsets;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import com.amazon.paapi.scratchpad.AWSV4Auth;
public class << OP NAME >> {
private static final String HOST = "<< HOST NAME >>";
private static final String URI_PATH = "/<< URI PATH >>";
private static final String ACCESS_KEY = "<< ACCESS_KEY >>";
private static final String SECRET_KEY = "**********";
private static final String REGION = "<< REGION >>";
public static void main(String[] args) throws Exception {
String requestPayload =
"<< PAYLOAD >>";
TreeMap<String, String> headers = new TreeMap<String, String>();
headers.put("host", HOST);
headers.put("content-type", "application/json; charset=UTF-8");
headers.put("x-amz-target", "<< REQUEST TARGET >>");
headers.put("content-encoding", "amz-1.0");
AWSV4Auth awsv4Auth =
new AWSV4Auth.Builder(ACCESS_KEY, SECRET_KEY)
.path(URI_PATH)
.region(REGION)
.service("ProductAdvertisingAPI")
.httpMethodName("POST")
.headers(headers)
.payload(requestPayload)
.build();
HttpClient client = HttpClientBuilder.create().build();
HttpPost httpPost = new HttpPost("https://" + HOST + URI_PATH);
httpPost.setEntity(new StringEntity(requestPayload));
Map<String, String> header = awsv4Auth.getHeaders();
for (Map.Entry<String, String> entrySet : header.entrySet()) {
httpPost.addHeader(entrySet.getKey(), entrySet.getValue());
}
HttpResponse response = client.execute(httpPost);
HttpEntity entity = response.getEntity();
String jsonResponse = EntityUtils.toString(entity, StandardCharsets.UTF_8);
int statusCode = response.getStatusLine().getStatusCode();
System.out.println(jsonResponse);
if(statusCode == 200) {
System.out.println("Successfully received response from Product Advertising API.");
System.out.println(jsonResponse);
} else {
JSONObject json = new JSONObject(jsonResponse);
if(json.has("Errors")) {
JSONArray errorArray = json.getJSONArray("Errors");
for(int i = 0; i < errorArray.length(); i++) {
JSONObject e = errorArray.getJSONObject(i);
System.out.println("Error Code: "+e.get("Code")+", Message: "+e.get("Message"));
}
} else {
System.out.println("Error Code: InternalFailure, Message: The request processing has failed because of an unknown error, exception or failure. Please retry again.");
}
}
}
}
/* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
/* Licensed under the Apache License, Version 2.0. */
/**
* Download the following artifacts and add to your projects classpath:
* o httpclient-4.5.5.jar
* o httpcore-4.4.9.jar
* o commons-logging-1.2.jar
* o json-20180130.jar
* Put your Secret Key in place of **********
* Make sure AWSV4Auth Class is available in same package
*/
package com.amazon.paapi.scratchpad;
import java.util.Map;
import java.util.TreeMap;
import java.nio.charset.StandardCharsets;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import com.amazon.paapi.scratchpad.AWSV4Auth;
public class << OP NAME >> {
private static final String HOST = "<< HOST NAME >>";
private static final String URI_PATH = "/<< URI PATH >>";
private static final String ACCESS_KEY = "<< ACCESS_KEY >>";
private static final String SECRET_KEY = "**********";
private static final String REGION = "<< REGION >>";
public static void main(String[] args) throws Exception {
String requestPayload =
"<< PAYLOAD >>";
TreeMap<String, String> headers = new TreeMap<String, String>();
headers.put("host", HOST);
headers.put("content-type", "application/json; charset=UTF-8");
headers.put("x-amz-target", "<< REQUEST TARGET >>");
headers.put("content-encoding", "amz-1.0");
AWSV4Auth awsv4Auth =
new AWSV4Auth.Builder(ACCESS_KEY, SECRET_KEY)
.path(URI_PATH)
.region(REGION)
.service("ProductAdvertisingAPI")
.httpMethodName("POST")
.headers(headers)
.payload(requestPayload)
.build();
HttpClient client = HttpClientBuilder.create().build();
HttpPost httpPost = new HttpPost("https://" + HOST + URI_PATH);
httpPost.setEntity(new StringEntity(requestPayload));
Map<String, String> header = awsv4Auth.getHeaders();
for (Map.Entry<String, String> entrySet : header.entrySet()) {
httpPost.addHeader(entrySet.getKey(), entrySet.getValue());
}
HttpResponse response = client.execute(httpPost);
HttpEntity entity = response.getEntity();
String jsonResponse = EntityUtils.toString(entity, StandardCharsets.UTF_8);
int statusCode = response.getStatusLine().getStatusCode();
System.out.println(jsonResponse);
if(statusCode == 200) {
System.out.println("Successfully received response from Product Advertising API.");
System.out.println(jsonResponse);
} else {
JSONObject json = new JSONObject(jsonResponse);
if(json.has("Errors")) {
JSONArray errorArray = json.getJSONArray("Errors");
for(int i = 0; i < errorArray.length(); i++) {
JSONObject e = errorArray.getJSONObject(i);
System.out.println("Error Code: "+e.get("Code")+", Message: "+e.get("Message"));
}
} else {
System.out.println("Error Code: InternalFailure, Message: The request processing has failed because of an unknown error, exception or failure. Please retry again.");
}
}
}
}
curl "https://<< ENDPOINT >>" \
-H "Host: << HOST NAME >>" \
-H "Accept: application/json, text/javascript" \
-H "Accept-Language: en-US" \
-H "Content-Type: application/json; charset=UTF-8" \
-H "X-Amz-Date: << AMZ DATE >>" \
-H "X-Amz-Target: << REQUEST TARGET >>" \
-H "Content-Encoding: amz-1.0" \
-H "Authorization: << AUTH HEADER >>" \
-d "<< PAYLOAD >>"
curl "https://<< ENDPOINT >>" \
-H "Host: << HOST NAME >>" \
-H "Accept: application/json, text/javascript" \
-H "Accept-Language: en-US" \
-H "Content-Type: application/json; charset=UTF-8" \
-H "X-Amz-Date: << AMZ DATE >>" \
-H "X-Amz-Target: << REQUEST TARGET >>" \
-H "Content-Encoding: amz-1.0" \
-H "Authorization: << AUTH HEADER >>" \
-d "<< PAYLOAD >>"