Ready to Learn?Ex Libris products all provide open APIs

Tech Blog

 

Simple Linked Data-Powered Author Card

Josh Weisman on July 12th, 2018

All bibliographic and local authority records managed in Alma are available in various linked data formats. Details on Alma’s linked data features are available in the documentation and this blog post. As this is an emerging area, we are exploring possible use cases that can be served well by linked data. A “classic” use of linked data is to enrich the presentation of records with data harvested from external linked sources.

An example of traversing linked data could be:

Linked Data Author Card Flow

A similar use case was described by the University of Wisconsin at Madison in their blog post. They have made available on Github a library called BibCard which assists in traversing the links and populates data retrieved from various sources.

In this blog post, we’ll show a short Ruby script which utilizes the BibCard library to build a simple author card.

JSON-LD

First we retrieve the JSON-LD URI for our BIB record in Alma. After activating the linked data integration profile, we can retrieve the JSON-LD using this URL template:

https://open-na.hosted.exlibrisgroup.com/alma/{INSTITUTION_CODE}/bibs/{MMS_ID}

We parse the JSON and look for a creator with an @id attribute pointing to an LC authority record. The URIs are automatically added by Alma to fields linked to Authority records in the Community Zone.

if jsonld[:creator].is_a?(Array)
  creator = jsonld[:creator].find {|i| i[:@id].include?(LCNAF_PREFIX)}
else
  creator = jsonld[:creator] if jsonld[:creator][:@id].include?(LCNAF_PREFIX)
end
lcnaf_uri = creator[:@id]

BibCard

We are now ready to create a new BibCard instance with the LC URI we retrieved from the JSON-LD. When we initialize the object, the BibCard library traverses the linked data tree to retrieve data from various sources. It returns an object with various properties containing the additional data.

person = BibCard.person(lcnaf_uri)

Render the template

The next step in our script is to populate a small hash with the data we’re interested in, and then render an ERB template using the data from the hash. The end result is a simple author card with a thumbnail image, dates of birth and death, and a description, all from the original LC URI!

Linked Data Author Card

We hope this blog post inspires you to think of use cases for linked data in your library. Feel free to leave a comment to let us know how you’re using the linked data features. The code from this blog post is available in this Github gist.

Github