WorldCat Search API Updates How do I love thee
The last 2 months have brought a bunch of great changes to the WorldCat Search API that have me jumping for joy. The first of these occurred in late July when the OpenSearch response formats (Atom and XML) were modified to include ISBN and OCLC number. The addition of ISBN to this format is literally a godsend because it allows mashups to be built from the WorldCat Search API much more quickly. This is because most sources for data outside of libraryland use ISBN as the identifier of choice. So if you want to get cover data, reviews, tags or ratings you need an ISBN. Unfortunately, before the July upgrade the only way you could get an ISBN was to query the API using SRU and retrieving either Dublin Core or MARCXML records. Now while SRU and MARCXML have their strengths simplicity isn’t one of them. So the code would look something like this
$xml = simplexml_load_file($searchURL);
$xml->registerXPathNamespace(“marc”, “http://www.loc.gov/MARC21/slim”);
foreach($xml->xpath(‘//marc:record’) as $book ) {
$book['xmlns:marc'] = ‘http://www.loc.gov/MARC21/slim’;
$field = simplexml_load_string($book->asXML());
$title = $field->xpath(“marc:datafield[@tag='245']/marc:subfield[@code='a']“);
$publisher = $field->xpath(“marc:datafield[@tag='260']/marc:subfield[@code='b']“);
$publication_date = $field->xpath(“marc:datafield[@tag='260']/marc:subfield[@code='c']“);
$isbn = $field->xpath(“marc:datafield[@tag='020']/marc:subfield[@code='a']“);
$isbn_1 = substr($isbn[0], 0, strpos($isbn[0], ” “));
$author = $field->xpath(“marc:datafield[@tag='100']/marc:subfield[@code='a']“);
$oclcnumber = $field->xpath(“marc:controlfield[@tag='001']“);// if available from LibraryThing show book cover
if ( strlen($isbn_1) > 1 ) {
$image_url = ‘http://covers.librarything.com/devkey/’ . $librarything_key . ‘/small/isbn/’ . $isbn_1;
$headers = get_headers($image_url, 1);
if ($headers[0] == ‘HTTP/1.1 200 OK’) {
echo ‘<p style=”float:left;”><img src=”‘ . $image_url . ‘”/></p>’;
}
}
echo ‘<p><a href=”http://www.worldcat.org/oclc/’ . $oclcnumber[0] . ‘”><span>’ . $title[0] . ‘</span></a>’;
echo ‘</p>’;
}
After the upgrade however the same functionality can be created with the following code
$xml = simplexml_load_file($searchURL);
$xml->registerXPathNamespace(“dc”, “http://purl.org/dc/elements/1.1/”);
$xml->registerXPathNamespace(“oclcterms”, “http://purl.org/oclc/terms/”);foreach($xml->xpath(‘//entry’) as $book ) {
$field = simplexml_load_string($book->asXML());
$title = $field->title;
$isbn = $field->xpath(“dc:identifier”);
$isbn_1 = ltrim($isbn[0], “urn:ISBN:” );
$author = $field->author->name;
$oclcnumber = $field->xpath(“oclcterms:recordIdentifier”);// if available from LibraryThing show book cover
if ( strlen($isbn_1) > 1 ) {
$image_url = ‘http://covers.librarything.com/devkey/’ . $librarything_key . ‘/small/isbn/’ . $isbn_1;
$headers = get_headers($image_url, 1);
if ($headers[0] == ‘HTTP/1.1 200 OK’) {
echo ‘<p style=”float:left;”><img src=”‘ . $image_url . ‘”/></p>’;
}
}
echo ‘<p><a href=”http://www.worldcat.org/oclc/’ . $oclcnumber[0] . ‘”><span>’ . $title[0] . ‘</span></a>’;
echo ‘</p>’;
}
The fact that the update makes a simpler query format and response format able to provide all the relevant fields for a mashup, which is really great. Can’t wait to show this as part of my mashups workshop for LITA at Midwinter.
The second change that has me leaping in excitement is a change to the service levels. Libraries no longer need to restrict access to applications which use the library limit to known library users. This is a BIG, BIG deal. It means that applications can be contextualized for libraries without having to force users to authenticate. The upshot, if you’re library ILS doesn’t have an API, and all your holdings are in OCLC you can use the WorldCat Search API to search your holdings. There are SO many important ways this can be used by libraries that I think many libraries which may not have had complete holdings in OCLC in the past will do so now. For me this change create the opportunity to work on a mobile interface for catalog data, which I’m so looking forward to.
The last change is the forthcoming addition of a Basic WorldCat Search API which will make a select set of data from the API available to non-OCLC members. I’ve been advocating about this for a while because WorldCat is the best set of bibliographic data out there and if OCLC truly wants to help drive traffic to libraries then they need to make this data available. I hope that when its all said and done this will mean that a WorldCat driven version of the OpenBook Book Data plugin will get created for WordPress and add-ons will be created for other systems like CMSs (Drupal and Joomla for sure). Too much of this traffic is being driven to Amazon and it would be extremely advantageous for people to be able to add links to local libraries instead.
I am still waiting for a JSON response format which would be helpful and was thinking that now that I can limit to holdings without authenticating that it would be nice to have the holdings limit as part of the OpenSearch query. All in all though I’m really happy about the changes. Its great to see services involve to meet developer needs and I think OCLC’s Web Services will continue to grow and evolve over time.
Thanks Karen. We’ve been talking about JSON–thanks for the reminder. I’m working on putting together an online showcase of apps and mash-ups that use the WorldCat Search API and other OCLC Web Services. (Formatting the posters to be online, in other words.) Look forward to showing off your (and your team’s) new ideas.