Amazon advertising API for price checking (C#)

Note: This article was originally published in 2011.

This simple demonstration gives you an idea of how you can use the Amazon Advertising API to check the prices of your items against the Amazon marketplace.

The Product Advertising API gives you access to Amazon’s selection of millions of products in categories such as books, music, digital downloads and electronics from,,,,, and

I would highly recommend that you click the link above to gain a better understanding of the API provided by Amazon. In a nutshell you can use this API to connect to Amazon’s extensive database system and query their marketplace.

In this guide we will be using the following sample code to streamline the process of developing a very nifty price checking application: Product Advertising API Signed Requests Sample Code – C# REST/QUERY


Since this is not a programming guide nor a fully fledged tutorial, I assume you have basic understanding of creating new applications for C#. Below is a checklist of what’’s required to get going:

  • Visual Studio Express 2008 or later
  • API Signed Requests Sample Code Click here
  • Amazon Product Advertising API Account Click here
  • AWS Access Key ID and AWS Secret Key (available when you create your account)

Run the sample code

Once you have downloaded the sample code, opened the solution and input your Access Key ID & AWS secret key (edit the file ItemLookupSample.cs), you can run the application. Hopefully you’ll get a console window pop-up & and some kind of product information output to the console (books in this case).

How does it work?

Simple! – the sample program creates a stateless REST query with the Amazon servers. It specifies a query string in the form of a URL – the string may contain information about the product you are querying. For example if you have the ISBN of a book, you can use this to form a part of the query as a parameter & the Amazon server will understand you are specifying that you want to query using an ISBN & you are going to provide the ISBN to use as part of the query. The Amazon server will then search through the Amazon product catalogue for that particular ISBN and if a match is found it will return a html response of data (in XML).

Now that you have a brief idea of how this works, you can tweak your query to access information about your products from Amazon using the API – you’re probably wondering what information is returned:

  • ASIN code
  • Author
  • Manufacturer
  • Product title
  • Product price
  • Product category
  • and a few others..

Lets check prices

Our modification will create new behaviour on top of the sample program. We are going to query a single product from Amazon’s Electronics category using the product EAN code. Beware as we will be performing some minor alterations to the existing code so you may want to save the sample solution as a new project: File > Save as.

Firstly create a new method in the ItemLookupSample.cs class like so:

public void CheckPrice()
string ean = "8714574569482"
string price;
SignedRequestHelper helper = new SignedRequestHelper(MY_AWS_ACCESS_KEY_ID, MY_AWS_SECRET_KEY, DESTINATION);
String requestString = "Service=AWSECommerceService"
+ "&Version=2009-03-31"
+ "&Operation=ItemLookup"
+ "&IdType=EAN"
+ "&ItemId=" + ean
+ "&SearchIndex=Electronics"
+ "&ResponseGroup=OfferSummary"
+ "&AssociateTag=dummy-20";
requestUrl = helper.Sign(requestString);
 <span>price = FetchTitle(requestUrl);</span>

As you can see I have modified the request string to accommodate our new query. The API supports a number of query variations all depending on the information you want to extract from Amazon. For a detailed spec please click here: Product Advertising API Documentation


The API offers a variety of query methods to search for products. The operation ItemLookup enables us to search for a product with specific parameters such an ISBN, UPC, EAN or SKU.


IdType is only required if you decide to search for a product other than an ASIN. You can specify either EAN, UPC or SKU.

"ItemId=" + ean

When you specify ItemType as EAN, UPC or SKU you must also specify the ItemId attribute with a parameter. In my example I have set this to a 13-digit EAN number 8714574569482.

Note that if you specify ItemType as EAN, the number must be 13-digits long, if you specify ItemType as UPC then the number must be 12-digits long. Failure to specify the correct ItemType will result in an error.


SearchIndex enables you to select which Amazon categorisation to search within. Since this is an extreme example where we know before hand that the item is under Electronics, we can specify this parameter. Below are some of the available search indices for the UK marketplace.

  • Apparel
  • Automotive
  • Beauty
  • Books
  • Electronics
  • Jewellery
  • and more..

Click here for a list of all the searchable categories Search Index Support by Locale


ResponseGroup allows you to create a customised response from Amazon. In this example we used OfferSummary since it returns the lowest price for the item.

Run the new example

Go ahead and run the new function – place the following function call CheckPrice() anywhere within the method Main(), e.g.:

public static void Main()
SignedRequestHelper helper = new SignedRequestHelper(MY_AWS_ACCESS_KEY_ID, MY_AWS_SECRET_KEY, DESTINATION);
 * The helper supports two forms of requests - dictionary form and query string form.
String requestUrl;
String title;

You probably would have noticed the output in the console is blank for our custom response since we haven’t modified the FetchTitle() method to retrieve the the price of the product.

For those who are familiar with debugging your apps, we are now going to set a breakpoint so we can analyse the response from the Amazon server.

Set a breakpoint at return title; in the FetchTitle() method and then re-run the program.

Once Visual Studio hits the breakpoint you will then be able to view the XML response – see the following screenshot to find out how to do this:

Visual Studio breakpoint

Visual Studio breakpoint


Amazon Product API Offer Summary XML Response

Amazon Product API Offer Summary XML Response

Now that we have a good idea of the information returned, you simply need to extract the desired data from the XML sheet & and assign it to a variable in your application. For our price check we want to extract the the lowest price on Amazon. If you look at the XML you can see that Amazon specifies this as an element labelled <LowestNewPrice> and a child element within that labelled <Amount>.

I have not covered how to parse XML documents but you can easily do this either by altering the existing code in the sample code or creating a new custom parser using the XmlTextReader or XmlReader classes from the .NET framework.

Bulk price querying

One real world example is that you can use the Amazon Product API to check prices against your entire inventory. This can be done easily by looping through say for example an array of EAN numbers:

private void SomeRandomMethod()
//an array of EAN numbers
string[] eanArray = new string[]{"8714574569482","2714574569325","5614574569123"};
//Loop through each array item & query
foreach(string s in eanArray){
//Modify the CheckPrice() method to accept a parameter
private void CheckPrice(string s)
//Modify the requestString to use the parameter sent in our query
"&ItemId=" + s
//Modify the FetchTitle() method to extract the item price from the XML doc


I hope this short article has given you a quick introduction of how you can use the Amazon Product API to obtain product pricing – e.g: you can create an application that will parse a text file that contains a product catalogue with EAN numbers. Your custom method can then use that list of EAN numbers to check prices against the Amazon API.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.