Ready to Learn?Ex Libris products all provide open APIs

Tech Blog

 

Build a Quick Catalog Form with the Enhanced BIB APIs

Josh Weisman on May 8th, 2018

In a recent blog post, we described the cataloging enhancements made to the BIB APIs. These enhancements include:

  • The ability to validate and run normalizations on added/updated records
  • Linking/unlinking a local BIB to a network zone record
  • Cataloger level, stale version check to ensure that records are not correctly overwritten
  • Warnings and override when deleting a BIB record

With these enhancements, it's easy to build a supplemental or quick catalog form. In this blog post, we’ll highlight how to use some of the new features in the world’s simplest cataloging tool.

We’ll be using the Update BIB API and include the querystring parameters which trigger the new features:

PUT /almaws/v1/bibs/{MMS_ID}?validate=true&cataloger_level=00&normalization=37xx00561

Form

We have a small Node.js application running the Express web framework. We’ve built a simple form which displays a BIB record’s title and author. When the user enters an MMS_ID and clicks the "Retrieve BIB" button, we retrieve the brief view of the BIB record and populate the author and title fields with the data returned from the API.

GET /almaws/v1/bibs/{MMS_ID}?view=brief

Quick Catalog Form

Validation

To trigger the validation, we can try to update the BIB record without a title. The validation routine specifies that the title field is required, so by providing the validate=true parameter we should receive an error when attempting to update the BIB.

The form submits a simple JSON object to the server. The server retrieves the full MARC XML record from Alma and uses the XPath and DOMParser libraries to update the relevant field (245 in this case). We then serialize the XML and send it back to the server using the PUT BIB API as shown above.

The server responds with a HTTP 400 status code and we extract the error message from the error object returned in the body of the response. We can then display the error message to the user which includes the specific validation rule that failed, in this case a missing 245 field.

Quick Catalog Form- Validation

Normalization

We’ve created a simple normalization rule which adds a local field indicating that the record was updated using the quick catalog form.

rule "Add field 900 when updated by the cataloging form"
when
  (TRUE)
then
  addField "900.a.Updated by the cataloging form"
end

We add the ID of the normalization process we wish to run to the querystring of the update BIB API request (see the blog post referenced above for more information on how to retrieve the ID of the normalization process). When the BIB is successfully updated the normalization process is applied and the resulting BIB has the additional field.

Quick Catalog Form- Normalization

In addition, we receive a list of warnings in the response from the update BIB API and can choose to display those warnings to the user.

Quick Catalog Form- Warnings

Cataloger Level

Those institutions that have implemented cataloging privileges in Alma can leverage them further with the BIB APIs. Since our simple cataloging form is open to the public to update BIB records, we want to specify a low cataloger level so that it can be locked if touched by a professional. To do that we pass a cataloger_level parameter of 00 in the querystring on the update BIB request. So now if we try to update a BIB that has cataloging level higher than 00 we receive an error message and the BIB is not updated.

Quick Catalog Form- Cataloger Level

Wrapping Up

This simple example shows off some of the new features of the BIB APIs. The code for this sample is available in this repository in Github.

Github