Kaplooey Blog! - Getting Book Info from Various Web Services
mom stuff, geek stuff, writing stuff, weightloss stuff, and more
 
# Monday, March 16, 2009

<geek alert>

Hi, I’m Leah and I’m a bookaholic.

In my quest to tame my addiction, I’m working on a little app to keep track of what I have and what I want. Kind of like Library Thing without any of the social stuff. And not necessarily a browser based system.

So, I’ve got a WPF client that will go out and touch four (so far) different web services to get the xml about a particular book – based on isbn or isbn13.

Getting the Data

There are some other choices out there, but I concentrated on the main ones, as far as information is concerned. In alphabetical order: Amazon, ISBNdb, Library Thing, and Library of Congress. Here’s how to get the XML from each service.

(note – blog jet is not the best at formatting the xml, and this is my first time at a serious tech post, so pretend all is properly indented until I get it cleaned up)

Amazon

First, get a key. Then make your url like this:

http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&SubscriptionId=YOURKEYHERE&Operation=ItemLookup&ResponseGroup=Medium&ItemId=0441172695

Then, here’s what your xml looks like:

<?xml version="1.0" ?> 
- <ItemLookupResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2005-10-05">
- <OperationRequest>
- <HTTPHeaders>
  <Header Name="UserAgent" Value="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1;
InfoPath.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
" />
  </HTTPHeaders>
  <RequestId>38eed815-71e3-420b-902f-ade8746fb3ca</RequestId>
- <Arguments>
  <Argument Name="Operation" Value="ItemLookup" />
  <Argument Name="Service" Value="AWSECommerceService" />
  <Argument Name="ItemId" Value="0441172695" />
  <Argument Name="ResponseGroup" Value="Medium" />
  <Argument Name="SubscriptionId" Value="YOURKEYHERE" />
  </Arguments>
  <RequestProcessingTime>0.0165120000000000</RequestProcessingTime>
  </OperationRequest>
- <Items>
- <Request>
  <IsValid>True</IsValid>
- <ItemLookupRequest>
  <Condition>New</Condition>
  <DeliveryMethod>Ship</DeliveryMethod>
  <IdType>ASIN</IdType>
  <MerchantId>Amazon</MerchantId>
  <OfferPage>1</OfferPage>
  <ItemId>0441172695</ItemId>
  <ResponseGroup>Medium</ResponseGroup>
  <ReviewPage>1</ReviewPage>
  </ItemLookupRequest>
  </Request>
- <Item>
  <ASIN>0441172695</ASIN>
  <DetailPageURL>http://www.amazon.com/Dune-Messiah-Chronicles-Book/dp/0441172695_
%3FSubscriptionId%3YOURKEYHERE%26tag%3Dws%26linkCode%3Dxm2%26camp%3D2025%26_
creative%3D165953%26creativeASIN%3D0441172695</DetailPageURL>
  <SalesRank>8349</SalesRank>
- <SmallImage>
  <URL>http://ecx.images-amazon.com/images/I/712XDW1BRHL._SL75_.gif</URL>
  <Height Units="pixels">75</Height>
  <Width Units="pixels">45</Width>
  </SmallImage>
- <MediumImage>
  <URL>http://ecx.images-amazon.com/images/I/712XDW1BRHL._SL160_.gif</URL>
  <Height Units="pixels">160</Height>
  <Width Units="pixels">95</Width>
  </MediumImage>
- <LargeImage>
  <URL>http://ecx.images-amazon.com/images/I/712XDW1BRHL.gif</URL>
  <Height Units="pixels">475</Height>
  <Width Units="pixels">283</Width>
  </LargeImage>
- <ImageSets>
- <ImageSet Category="primary">
- <SwatchImage>
  <URL>http://ecx.images-amazon.com/images/I/712XDW1BRHL._SL30_.gif</URL>
  <Height Units="pixels">30</Height>
  <Width Units="pixels">18</Width>
  </SwatchImage>
- <SmallImage>
  <URL>http://ecx.images-amazon.com/images/I/712XDW1BRHL._SL75_.gif</URL>
  <Height Units="pixels">75</Height>
  <Width Units="pixels">45</Width>
  </SmallImage>
- <MediumImage>
  <URL>http://ecx.images-amazon.com/images/I/712XDW1BRHL._SL160_.gif</URL>
  <Height Units="pixels">160</Height>
  <Width Units="pixels">95</Width>
  </MediumImage>
- <LargeImage>
  <URL>http://ecx.images-amazon.com/images/I/712XDW1BRHL.gif</URL>
  <Height Units="pixels">475</Height>
  <Width Units="pixels">283</Width>
  </LargeImage>
  </ImageSet>
  </ImageSets>
- <ItemAttributes>
  <Author>Frank Herbert</Author>
  <Binding>Paperback</Binding>
  <DeweyDecimalNumber>813.54</DeweyDecimalNumber>
  <EAN>9780441172696</EAN>
  <ISBN>0441172695</ISBN>
  <Label>Ace</Label>
- <Languages>
- <Language>
  <Name>English</Name>
  <Type>Original Language</Type>
  </Language>
- <Language>
  <Name>English</Name>
  <Type>Unknown</Type>
  </Language>
- <Language>
  <Name>English</Name>
  <Type>Published</Type>
  </Language>
  </Languages>
- <ListPrice>
  <Amount>799</Amount>
  <CurrencyCode>USD</CurrencyCode>
  <FormattedPrice>$7.99</FormattedPrice>
  </ListPrice>
  <Manufacturer>Ace</Manufacturer>
  <NumberOfItems>1</NumberOfItems>
  <NumberOfPages>336</NumberOfPages>
- <PackageDimensions>
  <Height Units="hundredths-inches">120</Height>
  <Length Units="hundredths-inches">670</Length>
  <Weight Units="hundredths-pounds">35</Weight>
  <Width Units="hundredths-inches">410</Width>
  </PackageDimensions>
  <ProductGroup>Book</ProductGroup>
  <PublicationDate>1987-07-15</PublicationDate>
  <Publisher>Ace</Publisher>
  <Studio>Ace</Studio>
  <Title>Dune Messiah (Dune Chronicles, Book 2)</Title>
  </ItemAttributes>
- <OfferSummary>
- <LowestNewPrice>
  <Amount>1</Amount>
  <CurrencyCode>USD</CurrencyCode>
  <FormattedPrice>$0.01</FormattedPrice>
  </LowestNewPrice>
- <LowestUsedPrice>
  <Amount>1</Amount>
  <CurrencyCode>USD</CurrencyCode>
  <FormattedPrice>$0.01</FormattedPrice>
  </LowestUsedPrice>
- <LowestCollectiblePrice>
  <Amount>1000</Amount>
  <CurrencyCode>USD</CurrencyCode>
  <FormattedPrice>$10.00</FormattedPrice>
  </LowestCollectiblePrice>
  <TotalNew>42</TotalNew>
  <TotalUsed>441</TotalUsed>
  <TotalCollectible>10</TotalCollectible>
  <TotalRefurbished>0</TotalRefurbished>
  </OfferSummary>
- <EditorialReviews>
- <EditorialReview>
  <Source>Product Description</Source>
  <Content>Paul Atreides, genetically bred and trained to become the leader of his planet, is still subject_
to human frailties. The second book of the series.
</Content>
  </EditorialReview>
  </EditorialReviews>
  </Item>
  </Items>
  </ItemLookupResponse>

 

ISBNdb

Get a key. Then make your url like this (for isbn):

http://isbndb.com/api/books.xml?access_key=YOURKEYHERE&index1=isbn&results=details&value1=9780441172695

Here’s what they give back:

<?xml version="1.0" encoding="UTF-8" ?> 
- <ISBNdb server_time="2009-03-16T19:38:39Z">
- <BookList total_results="1" page_size="10" page_number="1" shown_results="1">
<BookData book_id="dune_messiah" isbn="0441172695" isbn13="9780441172696">
  <Title>Dune Messiah</Title>
  <TitleLong>Dune Messiah (Dune Chronicles, Book 2)</TitleLong>
  <AuthorsText>Frank Herbert</AuthorsText>
  <PublisherText publisher_id="ace_charter">ACE Charter</PublisherText>
  <Details change_time="2004-12-24T01:24:17Z" price_time="2009-03-16T16:59:06Z" _
edition_info="Mass Market Paperback; 1994-11-01" language="" _
physical_description_text="4.2"x6.9"x0.9"; 329 pages; 0.3 lb" lcc_number=""
dewey_decimal_normalized="" dewey_decimal="" />
  </BookData>
</BookList>
 </ISBNdb>

 

Library Thing

Another key needed. Make your URL like this:

http://www.librarything.com/services/rest/1.0/?method="librarything.ck.getwork&isbn=0441172695&apikey=YOURKEYHERE

Library Thing’s response:

<?xml version="1.0" encoding="UTF-8" ?> 
- <response stat="ok">
- <ltml xmlns="http://www.librarything.com/" version="1.0">
- <item id="8183" type="work">
  <author id="54" authorcode="herbertfrank">Frank Herbert</author>
  <url>http://www.librarything.com/work/8183</url>
- <commonknowledge>
- <fieldList>
- <field type="13" name="disambiguation" displayName="Disambiguation notice">
- <versionList>
- <version id="848067" archived="0" lang="eng">
  <date timestamp="1230621463">Tue, 30 Dec 2008 02:17:43 -0500</date>
- <person id="501960">
  <name>alexdaw</name>
  <url>http://www.librarything.com/profile/alexdaw</url>
  </person>
- <factList>
  <fact><![CDATA[ A shorter version of this book appeared in Galaxy Magazine for July-September, 1969 ]]></fact>
  </factList>
  </version>
  </versionList>
  </field>
- <field type="26" name="lastwords" displayName="Last words">
- <versionList>
- <version id="827623" archived="0" lang="eng">
  <date timestamp="1230087264">Tue, 23 Dec 2008 21:54:24 -0500</date>
- <person id="487278">
  <name>Grandeplease</name>
  <url>http://www.librarything.com/profile/Grandeplease</url>
  </person>
- <factList>
  <fact><![CDATA[ She led him back across the qanat into the darkness at the base of the massif and its Place of Safety. ]]></fact>
  <fact><![CDATA[ Epilogue . . . He strides through the long cavern of time, Scattering the fool-self of his dream -The Ghola's Hymn ]]></fact>
  </factList>
  </version>
  </versionList>
  </field>
- <field type="25" name="firstwords" displayName="First words">
- <versionList>
- <version id="827605" archived="0" lang="eng">
  <date timestamp="1230087106">Tue, 23 Dec 2008 21:51:46 -0500</date>
- <person id="487278">
  <name>Grandeplease</name>
  <url>http://www.librarything.com/profile/Grandeplease</url>
  </person>
- <factList>
  <fact><![CDATA[ Excerpts from the death cell interview with Bronso of IX- Q: What led you to take _
your particular approach to a history of Muad'dib? A: Why should I answer your questions? ]]></fact>
  </factList>
  </version>
  </versionList>
  </field>
- <field type="2" name="placesmentioned" displayName="Important places">
- <versionList>
- <version id="672922" archived="0" lang="eng">
  <date timestamp="1224171231">Thu, 16 Oct 2008 11:33:51 -0400</date>
- <person id="61056">
  <name>amweb</name>
  <url>http://www.librarything.com/profile/amweb</url>
  </person>
- <factList>
  <fact>Arrakis (Dune)</fact>
  </factList>
  </version>
  </versionList>
  </field>
- <field type="23" name="series" displayName="Series">
- <versionList>
- <version id="581299" archived="0" lang="eng">
  <date timestamp="1220475254">Wed, 03 Sep 2008 16:54:14 -0400</date>
- <person id="47275">
  <name>PhoenixTerran</name>
  <url>http://www.librarything.com/profile/PhoenixTerran</url>
  </person>
- <factList>
  <fact>Dune (2)</fact>
  <fact>Dune: complete chronology (9)</fact>
  </factList>
  </version>
  </versionList>
  </field>
- <field type="3" name="characternames" displayName="People/Characters">
- <versionList>
- <version id="289511" archived="0" lang="eng">
  <date timestamp="1205984261">Wed, 19 Mar 2008 23:37:41 -0400</date>
- <person id="138345">
  <name>jmjackson</name>
  <url>http://www.librarything.com/profile/jmjackson</url>
  </person>
- <factList>
  <fact>Paul Atreides</fact>
  <fact>Alia Atreides (St. Alia of the Knife)</fact>
  <fact>Chani</fact>
  <fact>Princess Irulan</fact>
  <fact>Duncan Idaho</fact>
  <fact>Stilgar</fact>
  <fact>Gaius Helen Mohiam</fact>
  <fact>Edric</fact>
  <fact>Scytale</fact>
  <fact>Hayt</fact>
  <fact>Bijaz</fact>
  </factList>
  </version>
  </versionList>
  </field>
- <field type="21" name="canonicaltitle" displayName="Canonical title">
- <versionList>
- <version id="278019" archived="0" lang="eng">
  <date timestamp="1205206730">Mon, 10 Mar 2008 23:38:50 -0400</date>
- <person id="118708">
  <name>ATimson</name>
  <url>http://www.librarything.com/profile/ATimson</url>
  </person>
- <factList>
  <fact>Dune Messiah</fact>
  </factList>
  </version>
  </versionList>
  </field>
- <field type="16" name="originalpublicationdate" displayName="Original publication date">
- <versionList>
- <version id="96006" archived="0" lang="eng">
  <date timestamp="1194630684">Fri, 09 Nov 2007 12:51:24 -0500</date>
- <person id="303911">
  <name>michaelhehir</name>
  <url>http://www.librarything.com/profile/michaelhehir</url>
  </person>
- <factList>
  <fact>1969</fact>
  </factList>
  </version>
  </versionList>
  </field>
  </fieldList>
  </commonknowledge>
  </item>
  <legal>By using this data you agree to the LibraryThing API terms of service.</legal>
  </ltml>
  </response>

 

Library Of Congress

No key needed (yay!). Your URL like so:

http://z3950.loc.gov:7090/voyager?version=1.1&operation=searchRetrieve&query=9780441015610&maximumRecords=100&recordSchema=dc

And they give back:

<?xml version="1.0" ?> 
- <zs:searchRetrieveResponse xmlns:zs="http://www.loc.gov/zing/srw/">
  <zs:version>1.1</zs:version>
  <zs:numberOfRecords>1</zs:numberOfRecords>
- <zs:records>
- <zs:record>
  <zs:recordSchema>info:srw/schema/1/dc-v1.1</zs:recordSchema>
  <zs:recordPacking>xml</zs:recordPacking>
- <zs:recordData>
- <srw_dc:dc xmlns:srw_dc="info:srw/schema/1/dc-schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns
="http://purl.org/dc/elements/1.1/"
xsi:schemaLocation="info:srw/schema/1/dc-schema http://www.loc.gov/standards/sru/resources/dc-schema.xsd">
  <title>Dune messiah /</title>
  <creator>Herbert, Frank.</creator>
  <type>text</type>
  <type>Science fiction. gsafd</type>
  <publisher>New York : Ace Books,</publisher>
  <date>2008.</date>
  <language>eng</language>
  <subject>Dune (Imaginary place)--Fiction.</subject>
  <identifier>URN:ISBN:9780441015610</identifier>
  </srw_dc:dc>
  </zs:recordData>
  <zs:recordPosition>1</zs:recordPosition>
  </zs:record>
  </zs:records>
  </zs:searchRetrieveResponse>

 

Conclusion

Library Thing’s api is useless to me in this format. LOC is good, but a little terse. For my purposes, I’ll probably search ISBN db first, then if I can’t find it, look at amazon. Amazon’s info is designed, and licensed, for marketing purposes, so you’re supposed to be linking back to the website for purchases. If this becomes a public app, I may reverse the lookup order.

Feel free to let me know if there are other reliable, and sizeable, databases with web service access out there.

Next up, sometime – building an app in WPF, and LINQ to XML.

</geekalert>

Monday, March 16, 2009 8:02:34 PM (GMT Standard Time, UTC+00:00)  #    Comments [0]   geek | websites  | 
Copyright © 2012 Leah Hurst 2011. All rights reserved.