1.0.0 • Published 4 years ago

nlb-lib v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

nlb-lib

This library queries book information from NLB.

Installation

npm install --save nlb-lib

Usage

Operations

Two operations are supported, getTitleDetails and getAvailabilityInfo.

getTitleDetails(bid): given a book id, return its title details in this format:

{ titleName: ..., author: ... }

// Example
{ titleName: 'The annotated Alice : Alice\'s adventures in Wonderland & Through the looking-glass',
  author: 'Carroll, Lewis, 1832-1898' }

getAvailabilityInfo(bid): given a book id, return its availabilities in this format:

[ { branchName: ..., shelfLocation: ..., callNumber: ..., statusDesc: ... }, ... ]

// Example
[ { branchName: 'Central Public Library',
    shelfLocation: 'Adult Lending',
    callNumber: 'English CAR',
    statusDesc: 'Onloan - Due: 12 Mar 2020' },
  ... ]

The book id bid can be found from the URL of the catalogue's book page:

book id from URL

Configuration

All operations have a default timeout of 5000ms per HTTP request (each operation requires two requests). This default timeout can be changed.

const nlb = require('nlb-lib');
nlb.timeout = 1000;

Dependencies

axios is used for HTTP requests, and cheerio for parsing HTML DOM.

1.0.0

4 years ago