Archive for the ‘Amazon’ Tag

Using the Amazon API

Saturday, March 1st, 2014

Hi again,

Sorry it’s been a while, holidays, tests and homework clogging up a lot of time recently. I decided to do a post today about an API I’ve been working with recently, the Amazon Advertising API. As part of my Maths GCSE Coursework, I need to collect data about book costs, and whilst it was fine to collect 100 books on two genres and compare if one is more expensive, I decided to go with a larger sample, 16,000 in this case. I thought it went quite well, and this is how I did it.

First of all, why did I choose the Amazon API? Well despite there being a fairly wide range (Google and Ebay being large contenders), Amazon stores a surprisingly vast amount of data on each book, including factors like weight and height. You can also be very precise on what you search – not just for books, for anything.

Step 1: Collect an API Key (and a secret code + affiliates account)

To get into the API, I had to sign up for various places to get the API Key. Despite it asking for my credit details on numerous occasions, I somehow dodged giving anything away to Amazon. If you’re a developer doing something on these lines, feel free to contact me on how to get a key.

Screen Shot 2014-03-01 at 21.55.06Step 2: Choose a Python module which supports what you want

In this case, I chose the official Python API, written via Github so you can see the source-code on your browser. This API is by far simpler and has a good functionality compared to using an XML parser. It was a simple install via pip, which is mentioned on the page.

Screen Shot 2014-03-01 at 21.58.55Step 3: Handle the concepts of the API and module, and get cracking!

To make my script, I had to learn some raw basics about how you can run a search request via the API. First of all, you authenticate with Amazon to prove you are a human on the other side. Afterwords, you ask Amazon what you want it to give. It will then give you a mass of data, of which is your task to process.

Read the rest of this entry »