Take me over?
NAME
WebService::Libris - Access book meta data from libris.kb.se
VERSION
Version 0.02
Note that this low version number actually reflects the immaturity of this module - no unit tests yet :(
SYNOPSIS
use WebService::Libris;
use 5.010;
binmode STDOUT, ':encoding(UTF-8)';
my $book = WebService::Libris->new(
type => 'book',
# Libris ID
id => '9604288',
);
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;
}
DESCRIPTION
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).
METHODS
new
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)
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.
direct_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).
search
my $collection = WebService::Libris->search(
term => 'Your Search Term Here',
page => 1,
);
while (my $book = $collection->next) {
say $book->title;
}
Searches the xsearch API for arbitrary search terms, and returns a WebService::Libris::Collection
of books.
See the direct_search
method above for a short discussion.
search_for_isbn
my $book = WebService::ISBN->search_for_isbn('9170370192');
Looks up a book by ISBN
Less interesting methods
The following methods aren't usually useful for the casual user, more for those who want to extend or subclass this module.
rdf_url
Returns the RDF resource URL for the current object. Mostly useful for internal purposes.
dom
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.
id
Returns the libris ID of the object. Only makes sense for subclasses.
type
Returns the short type name (bib
, auth
, library
). Only makes sense for subclasses.
fragments
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.
AUTHOR
Moritz Lenz, <moritz at faui2k3.org>
BUGS
Please report any bugs or feature requests at https://github.com/moritz/WebService-Libris/issues
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc WebService::Libris
You can also look for information at:
Bug tracker:
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
BUGS AND LIMITATIONS
Nearly no error checking is done. So beware!
ACKNOWLEDGEMENTS
Thanks go to the Kungliga biblioteket (National Library of Sweden) for providing the libris.kb.se service and API.
LICENSE AND COPYRIGHT
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.