It took a while to surface, but over the weekend I finally spotted the obvious possibilities raised by Google Spreadsheet’s new xml-linking features. Abi and I currently enter isbn, title and author data into our bookselling spreadsheet by hand, and this gets old quickly. More so for Abi, who has to check the individual Amazon pages to gauge current prices. I knew of Amazon’s API, and was planning to create something to help speed this up, but the only programming language I was ever any good at was Visual Basic, which isn’t around much any more, and I’m seriously rusty at the little .NET I once knew. So I wasn’t quite sure of the best way to approach things, and GS’ new hotness seemed like an ideal solution, if I could get it to work. Happily it did, and I can now enter an ISBN and have GS download the author, title, amazon URL, amazon price and lowest used price data automatically. Here’s a basic way to set it up:
http://webservices.amazon.co.ukonca/xml?Service=AWSECommerceService &SubscriptionId=[your_ID] &ResponseGroup=Medium &SearchIndex=Books &Operation=ItemLookup &IdType=ISBN &ItemId=0593055489
The most important part of this is the ResponseGroup, which determines how much data Amazon supplies. Medium is a good all-rounder, but there are plenty of more specific request types. Specifying ISBN as the IdType allows the use of 13-digit ISBNs, which a standard ItemLookup doesn’t - Amazon’s documentation claims it doesn’t work on the UK site, but it does.
These can all be combined into one XPath statement with | operators, so the final result is:
“//ListPrice/FormattedPrice | //LowestUsedPrice/FormattedPrice | //DetailPageURL | //Author[1] | //Title”
=importXML(”http://webservices.amazon.co.uk/onca/xml?Service=AWSECommerceService&SubscriptionId=[your_ID]&ResponseGroup=Medium&SearchIndex=Books&Operation=ItemLookup&IdType=ISBN&ItemId=”&B2,”//ListPrice/FormattedPrice | //LowestUsedPrice/FormattedPrice | //DetailPageURL | //Author[1] | //Title”))
The &B2 at the end of the URL appends the ISBN number, so be sure to change this to the appropriate cell.
=if(B2=”",”",importXML(”[your_URL]“&B2,”[your_XPath]“))
isblank() doesn’t seem to work properly with cells that have had content deleted.
Problems with this method:
Hopefully I’ll be able to refine this in the future, but it’s not a bad start, and I’m very impressed that the functionality exists at all.
-----


-----
Nice write up of a great combination of Google Spreadsheets and Amazon WebServices Andrew!