The Friends of the Alum Rock library sells books via Amazon to raise money for library programs. We thought it would be fun to see where we send the books.
Amazon makes it surprisingly hard to get programmatic access to order information. They do have an API (Amazon Marketplace Web Service), but it's only available to business sellers.
I wrote a Python script using mechanize that logs in to our seller account, goes to the order page, and clicks each of the orders to get to the order detail page. From there, I used regular expressions to extract the relevant order info (shipping address, date, price, and title). The HTML is not very well marked up, so this is likely to break. I use the MapQuest geocoding API to convert the mailing address to latitude/longitude so it can be mapped easily. I save this data in GeoJSON format, and update it whenever an order comes in. The orders.json
file contains some sample data but is not updated automatically.