Batch operations using DSpace 7 REST API

Submitted by Saiful on

Recently, a friend approached me seeking help with their DSpace for a couple of issues, namely:

  1. Restructuring the repository: it required moving a bunch of items from one collection to another, without changing the handle id or URL.
  2. Updating PDF files: splitting large PDF into smaller PDF files for easier loading in browsers.

I guess we can manually perform both tasks using the UI, but that process would be too cumbersome and not suitable for big collections. The number of items for them was inching closer to ten thousand. I suggested doing these in batch mode using the REST API of DSpace 7.

While looking for client tools for DSpace 7 REST APIs, I only found some Python examples. I didn't find any example in JavaScript/TypeScript, which is my favourite language these days. So I ended up writing my own DSpace 7 REST client in NodeJS. I have now published it in NPM:

https://www.npmjs.com/package/dspace7-node

The operations currently supported in the module covers only the use cases that I had to deal with in this project. They can, however, be extended with some experience in TypeScript.

Use Case 1
Moving a bunch of items (in a CSV file) to another collection you can write this:

https://gist.github.com/saiful-semantic/36599b3943eab4119282d9c88dec648d

Use Case 2
For replacing PDF files, here is the way using the same module:

https://gist.github.com/saiful-semantic/ba24d8a234b9c5aff17d7cba1bedff65

Blog tags