sierra-wrapper
A basic node wrapper for the III Sierra v3 API
The wrapper currently only supports:
- Authorizing
- Returning a single, multiple and range Bib records
- Returning a single, multiple and range Item records
- Returning item records beloning to a single Bib record
More endpoint will be added as the need arises.
To use make sure you have your credentials stored in a json file in the format:
{
"key": "YOURKEY",
"secret": "YOURSECRET",
"base": "https://your.domain.name.org/iii/sierra-api/v3/"
}
You then authorize and request by
var wrapper = require('sierra-wrapper')
var loadedConfig = wrapper.loadConfig('./path/to/config.json')
wrapper.auth((error, results) => {
if (error) console.log(error)
wrapper.requestSingleBib('14628261', (errorBibReq, results) => {
if (errorBibReq) console.log(errorBibReq)
console.log(results)
})
})
You can also set your credentials via enviorment variables: SIERRA_KEY
, SIERRA_SECRET
, SIERRA_BASE
Functions
-
loadConfig(configOrFile) ⇒
boolean
-
Loads a congig object, passed or from disk
- auth(cb)
-
Requests an auth token from the sierra API and stores it for future use, it also setups a time to renew the token
- requestSingleBib(bibId, cb)
-
Requests a single bib data from the API
Return format: { data: { total: 1, entries: [ [Object] ] }, url: 'https://catalog.library.org/iii/sierra-api/v3/bibs/17292415?fields=default,fixedFields,varFields,normTitle,normAuthor,orders,locations' }
- requestRangeBib(bibIdStart, bibIdEnd, cb)
-
Requests a bib range from the API
Return format: { data: { total: 1, entries: [ [Object] ] }, url: 'https://catalog.library.org/iii/sierra-api/v3/bibs/?limit=1&id=17292415&fields=default,fixedFields,varFields,normTitle,normAuthor,orders,locations' }
- requestRangeItem(itemIdStart, itemIdEnd, cb)
-
Requests an item range from the API
Return format: { data: { total: 1, entries: [ [Object] ] }, url: 'https://catalog.library.org/iii/sierra-api/v3/items/?limit=1&id=17292415&fields=default,fixedFields,varFields,normTitle,normAuthor,orders,locations' }
- requestBibItems(bibId, cb)
-
Requests all the items of a specified bib id Return format: { data: { total: 2, entries: [ [Object], [Object] ] }, url: [ 'https://catalog.library.org/iii/sierra-api/v3/items/?bibIds=17292415&fields=default,fixedFields,varFields&offset=0' ] }
- requestMultiBibBasic(bibsIds, cb)
-
Requests multiple bibs, but no orders or locations
Return format: { data: { total: 1, entries: [ [Object] ] }, url: 'https://catalog.library.org/iii/sierra-api/v3/bibs/?id=14628261,14628262,14628263,14628264,14628265,14628266,14628267,14628268,14628269,14628270&fields=default,fixedFields,varFields,normTitle,normAuthor' }
- requestMultiItemBasic(itemIds, cb)
-
Requests multiple items
Return format: { data: { total: 1, entries: [ [Object] ] }, url: 'https://catalog.library.org/iii/sierra-api/v3/items/?id=10000000,10000100,10000200,10000300,10000400,10000500,10000600,10000700,10000800,10000900,10001000&fields=default,fixedFields,varFields' }
boolean
loadConfig(configOrFile) ⇒ Loads a congig object, passed or from disk
Kind: global function
Returns: boolean
- did it load or not
Param | Type | Description |
---|---|---|
configOrFile |
object | string
|
The object with the credentials or a path to a json file with the credentials |
auth(cb)
Requests an auth token from the sierra API and stores it for future use, it also setups a time to renew the token
Kind: global function
Param | Type | Description |
---|---|---|
cb | function |
callback |
requestSingleBib(bibId, cb)
Requests a single bib data from the API
Return format: { data: { total: 1, entries: [ [Object] ] }, url: 'https://catalog.library.org/iii/sierra-api/v3/bibs/17292415?fields=default,fixedFields,varFields,normTitle,normAuthor,orders,locations' }
Kind: global function
Param | Type | Description |
---|---|---|
bibId | string |
the bnumber of the bib you want to request |
cb | function |
callback |
requestRangeBib(bibIdStart, bibIdEnd, cb)
Requests a bib range from the API
Return format: { data: { total: 1, entries: [ [Object] ] }, url: 'https://catalog.library.org/iii/sierra-api/v3/bibs/?limit=1&id=17292415&fields=default,fixedFields,varFields,normTitle,normAuthor,orders,locations' }
Kind: global function
Param | Type | Description |
---|---|---|
bibIdStart | string |
the bnumber of the bib you want to request |
bibIdEnd | string |
the bnumber of the bib you want to request |
cb | function |
callback |
requestRangeItem(itemIdStart, itemIdEnd, cb)
Requests an item range from the API
Return format: { data: { total: 1, entries: [ [Object] ] }, url: 'https://catalog.library.org/iii/sierra-api/v3/items/?limit=1&id=17292415&fields=default,fixedFields,varFields,normTitle,normAuthor,orders,locations' }
Kind: global function
Param | Type | Description |
---|---|---|
itemIdStart | string |
the bnumber of the bib you want to request |
itemIdEnd | string |
the bnumber of the bib you want to request |
cb | function |
callback |
requestBibItems(bibId, cb)
Requests all the items of a specified bib id Return format: { data: { total: 2, entries: [ [Object], [Object] ] }, url: [ 'https://catalog.library.org/iii/sierra-api/v3/items/?bibIds=17292415&fields=default,fixedFields,varFields&offset=0' ] }
Kind: global function
Param | Type | Description |
---|---|---|
bibId | string |
the bnumber of the bib you want to request |
cb | function |
callback |
requestMultiBibBasic(bibsIds, cb)
Requests multiple bibs, but no orders or locations
Return format: { data: { total: 1, entries: [ [Object] ] }, url: 'https://catalog.library.org/iii/sierra-api/v3/bibs/?id=14628261,14628262,14628263,14628264,14628265,14628266,14628267,14628268,14628269,14628270&fields=default,fixedFields,varFields,normTitle,normAuthor' }
Kind: global function
Param | Type | Description |
---|---|---|
bibsIds | array |
an array of bib id strings |
cb | function |
callback |
requestMultiItemBasic(itemIds, cb)
Requests multiple items
Return format: { data: { total: 1, entries: [ [Object] ] }, url: 'https://catalog.library.org/iii/sierra-api/v3/items/?id=10000000,10000100,10000200,10000300,10000400,10000500,10000600,10000700,10000800,10000900,10001000&fields=default,fixedFields,varFields' }
Kind: global function
Param | Type | Description |
---|---|---|
itemIds | array |
array of item ids |
cb | function |
callback |