Ready to Learn?Ex Libris products all provide open APIs

Tech Blog

 

Bulk Export Titles from Primo Using Primo Search Api

Blake Galbreath on December 4th, 2018

In this example, I use the Primo Search Api to collect all of the database titles from Primo and then export them to a local file.

 

Method: Windows Powershell
 
Pre-requisites: Primo Search Api Key
 
Primo Search API Doc: https://developers.exlibrisgroup.com/primo/apis/search/GET/AnSF56/p3aKzRujr9pj8qtyT3YiaSYVA/f5643222-bb88-4f3d-b2d6-5029e527c515
 

Steps taken within Powershell:

1.) Define Api Url:

$api = '{apiServer}/primo/v1/search?vid={vid}&tab={tab}&scope={scope}&pcAvailability={true/false]&q=any,contains,{query}&qInclude=facet_rtype,exact,{facet}&limit={limit}&apikey={apiKey}'

2.) Convert data from JSON:

$results = Invoke-WebRequest -Uri $api | ConvertFrom-Json

3.) Define source of database titles in pnx:

$dbTitles = $results.docs.pnx.display.title

4.) Output data to a file:

foreach ($dbTitle in $dbTitles) {
$o = new-object PSObject
$o | add-member NoteProperty DatabaseTitles $dbTitle
$o | Export-Csv "C:\file_path\file_name.csv" -append -NoType
}

Blake