WebService::Libris - Access book meta data from libris.kb.se
Version 0.08
Note that the API is still subject to change.
use WebService::Libris; use 5.010; binmode STDOUT, ':encoding(UTF-8)'; my $book = WebService::Libris->new( type => 'book', # Libris ID id => '9604288', # optional but recommended: cache_dir = '/tmp/webservice-libris/', ); print $book->title; my $books = WebService::Libris->search( term => 'Astrid Lindgren', page => 1, ); while (my $b = $books->next) { say $b->title; say ' isbn: ', $b->isbn; say ' date: ', $b->date; }
The Swedish public libraries and the national library of Sweden have a common catalogue containing meta data of the books they have available.
This includes many contemporary as well as historical books.
The catalogue is available online at http://libris.kb.se, and can be queried with a public API.
This module is a wrapper around two of their APIs (xsearch and RDF responses).
my $obj = WebService::Libris->new( type => 'author', id => '246603', );
Creates an object of the WebService::Libris class or a subclass thereof (denoted by type in the argument list). type can currently be one of (synonyms on one line)
WebService::Libris
type
auth author bib book library
The id argument is mandatory, and must contain the Libris ID of the object you want to retrieve. If you don't know the Libris ID, use one of the search functions instead.
id
search
my $hashref = WebService::Libris->direct_search( term => 'Your Searchterms Here', page => 1, # page size is 200 full => 1, # return all available information );
Returns a hashref directly from the JSON response of the xsearch API described at http://librishelp.libris.kb.se/help/xsearch_eng.jsp?open=tech.
This is more efficient than a WebService::Libris->search call, because it does only one query (whereas ->search does one additional request per result object), but it's not as convenient, and does not allow browsing of related entities (such as authors and libraries).
WebService::Libris->search
->search
my @books = WebService::Libris->search( term => 'Your Search Term Here', page => 1, ); for my $book (@books) { say $book->title; }
Searches the xsearch API for arbitrary search terms, and returns a WebService::Libris::Collection of books.
WebService::Libris::Collection
See the direct_search method above for a short discussion.
direct_search
my $book = WebService::Libris->search_for_isbn('9170370192');
Looks up a book by ISBN
The following methods aren't usually useful for the casual user, more for those who want to extend or subclass this module.
Returns the RDF resource URL for the current object. Mostly useful for internal purposes.
Returns the Mojo::DOM object from the web services response. Does a request to the web service if no DOM was stored previously.
Only useful for you if you want to extract more data from a response than the object itself provides.
Returns the libris ID of the object. Only makes sense for subclasses.
Returns the short type name (bib, auth, library). Only makes sense for subclasses.
bib
auth
library
Must be overridden in a subclass to return a list of the last two junks of the RDF resource URL, that is the short type name and the libris ID.
Moritz Lenz, <moritz at faui2k3.org>
<moritz at faui2k3.org>
Please report any bugs or feature requests at https://github.com/moritz/WebService-Libris/issues
You can find documentation for this module with the perldoc command.
perldoc WebService::Libris
You can also look for information at:
Bug tracker:
https://github.com/moritz/WebService-Libris/issues
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/WebService-Libris
CPAN Ratings
http://cpanratings.perl.org/d/WebService-Libris
Search CPAN
http://search.cpan.org/dist/WebService-Libris/
Nearly no error checking is done. So beware!
Thanks go to the Kungliga biblioteket (National Library of Sweden) for providing the libris.kb.se service and API.
Copyright 2011 Moritz Lenz.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install WebService::Libris, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WebService::Libris
CPAN shell
perl -MCPAN -e shell install WebService::Libris
For more information on module installation, please visit the detailed CPAN module installation guide.