Relaton::Isbn is a Ruby gem that implements the IsoBibliographicItem model.
You can use it to retrieve metadata of Standards from https://openlibrary.org, and
access such metadata through the Bibitem object.
Installation
Add this line to your application’s Gemfile:
gem 'relaton-isbn'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install relaton-isbn
Usage
Retrieving bibliographic items using OpenLibrary API
To retrieve bibliographic items, use Relaton::Isbn::OpenLibrary.get method with ISBN-10 or ISBN-13 as an argument. Allowed prefixes are ISBN, isbn:. Prefix and hyphens are optional. The method returns Relaton::Bib::Bibitem object.
require 'relaton/isbn'
=> true
# get document by ISBN-13
bibitem = Relaton::Isbn::OpenLibrary.get "ISBN 978-0-12-064481-0"
[relaton-isbn] INFO: (ISBN 978-0-12-064481-0) Fetching from OpenLibrary ...
[relaton-isbn] INFO: (ISBN 978-0-12-064481-0) Found: `9780120644810`
=> #<Relaton::Bib::Bibitem:0x0000000127ed25d8
...
# get document by ISBN-10
Relaton::Isbn::OpenLibrary.get "isbn:0120644819"
[relaton-isbn] INFO: (isbn:0120644819) Fetching from OpenLibrary ...
[relaton-isbn] INFO: (isbn:0120644819) Found: `9780120644810`
=> #<Relaton::Bib::Bibitem:0x0000000127f11698
...
Serializing bibliographic items
# serialize to XML
bibitem.to_xml
=> "<bibitem id="9780120644810" schema-version="v1.4.1">
<fetched>2026-03-04</fetched>
<title type="main">Graphics gems II</title>
<uri type="src">http://openlibrary.org/books/OL21119585M/Graphics_gems_II</uri>
<docidentifier type="ISBN" primary="true">9780120644810</docidentifier>
...
</bibitem>"
# serialize to bibdata XML
bibitem.to_xml bibdata: true
=> "<bibdata schema-version="v1.4.1">
<fetched>2026-03-04</fetched>
<title type="main">Graphics gems II</title>
<uri type="src">http://openlibrary.org/books/OL21119585M/Graphics_gems_II</uri>
<docidentifier type="ISBN" primary="true">9780120644810</docidentifier>
...
<ext>
<flavor>isbn</flavor>
</ext>
</bibdata>"
# serialize to hash
puts bibitem.to_yaml
=> "---
id: '9780120644810'
schema_version: v1.4.1
..."
Logging
Relaton::Isbn uses the relaton-logger gem for logging. By default, it logs to STDOUT. To change the log levels and add other loggers, read the relaton-logger documentation.
Development
After checking out the repo, run bin/setup to install dependencies. Then, run
rake spec to run the tests. You can also run bin/console for an interactive
prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To
release a new version, update the version number in version.rb, and then run
bundle exec rake release, which will create a git tag for the version, push
git commits and the created tag, and push the .gem file to
rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/relaton/relaton-isbn.
License
The gem is available as open source under the terms of the MIT License.