Ready to Learn?Ex Libris products all provide open APIs

Tech Blog


Performing the Alma "scan-in" API on a file of barcodes

Tamar Fuches on May 17th, 2016

The Alma scan-in API is useful in order to put items back in place by the end of the day.
The following script can be used in order to perform a "bulk" scan-in on a list of barcodes in a single file.
As you can see in the below script, the scan-in API is working on item pid. So we first need to get this information based on the barcode, and only after this perform the scan-in operation.


set library   = LIBCODE
set circ_desk = CIRCDESKCODE

set prefix = ''
set api_key_header = 'Authorization: apikey XXXXX'

foreach barc (`cat scan_in_barcodes.txt`)
  echo __ processing barcode $barc __
  set item_by_barc_url = $prefix'almaws/v1/items?item_barcode='$barc
  echo __ Calling GET "$item_by_barc_url" ...
  curl --dump-header /tmp/item.$barc.tmp "$item_by_barc_url" -H "$api_key_header"
  set item_url = "`cat /tmp/item.$barc.tmp | grep Location | sed 's/.*almaws/almaws/' | sed 's/\r//g'`"
  set scan_in_url = $prefix"$item_url"'&op=scan&library='$library'&circ_desk='$circ_desk''
  echo __ Calling POST "$scan_in_url" ...
  curl -X POST "$scan_in_url" -H 'Content-Type: application/xml'