Ready to Learn?Ex Libris products all provide open APIs

Tech Blog

 

Using Alma BIB API in order to retrieve and update call numbers

Nazzareno Bedini on November 15th, 2017

we use the Alma BIB API in order to retrieve and update call numbers.

Input csv file structure: barcode, old call number, new call number. The PHP script work as following:

  1. Read CSV file line by line and for each line:
  2. Retrieve MMSid and Holding id using GET /almaws/v1/items?item_barcode={item_barcode}
  3. Retrieve XML holding record using method GET /almaws/v1/bibs/{mms_id}/holdings/{holding_id}
  4. Convert XML in array (to simplify the update)
  5. Check if barcode item exists and if the call number in the holding record is the same as the old call number in the csv file (to avoid mistakes and typos)
  6. Replace in the array the call number stored in subfield h in the 852 field with the new call number form the csv file;
  7. Re-convert the array in xml object
  8. Update the holding record with method PUT /almaws/v1/bibs/{mms_id}/holdings/{holding_id} and the xml object updated;
  9. Repeat step 1  until the end of csv file.

The full script and classes are available here.

Note that the php script (change_callnumber_en.php) needs a web server environment (we use is Apache2.4 +PHP 5), apart from that it is an out of the box application.

The zip includes two additional classes to transform XML in array and viceversa, deleveloped by Lalit Patel (http://www.lalit.org/lab/) and available with Apache License 2.0 as best solution.