WorldCat Search API
A WorldCat API for Ruby to interact with WorldCat search webservices. www.worldcat.org
require 'worldcat' client = WorldCat.new '[api_key]'
Get Atom or RSS response from an OpenSearch
atom = client.open_search :query => "Civil War" puts atom.feed.title puts atom.entries.first.
Get MARC XML or Dublin Core from a SRU CQL query
cql = 'srw.kw="civil war" and (srw.su="antietam" or srw.su="sharpsburg")' records = client.sru_search :query => cql, :format => "marcxml" for record in records # print out field 245 subfield a puts record['245']['a'] end
If you'd like to use another implementation, the raw response is available:
A faster way?
rss = WorldCat.new.open_search :q => "Globalization", :format => "rss", :wskey => '[api_key]'
For more information, please have a look at the documentation or the test cases.
gem install worldcat
The 'wcapi' gem does not satisfy several points, so another version is justified for many reasons:
It is better to use a RSS Ruby implementation, actually SimpleRSS, to get Atom or RSS response.
It is better to use the MARC Ruby implementation to get MARC XML or Dublin Core response from a SRU CQL search or other search.
Unit testing is great.
What this API can do
Send searches in OpenSearch or SRU CQL syntax.
Receive OpenSearch responses in RSS or Atom format (both are a SimpleRSS object).
Receive SRU responses in an array of MARC::Record or Dublin Core (REXML::Document).
Receive a MARC::Record for a single OCLC record.
Receive a REXML::Document for geographically-sorted library holdings information.
Receive a HTML formatted String for standard bibliographic citation formats (APA, Chicago, Harvard, MLA, and Turabian).
Use SRU gem to get response from sru_search.
Feel free to fork and send me a pull request for changes, fixes or simply a message for any suggestion.
Vivien Didelot <email@example.com> github.com/v0n/worldcat