nlbsg package

nlbsg.catalogue module

class nlbsg.catalogue.Client(wsdl, api_key)
get_availability_info(bid=None, isbn=None, sort=None, start=1, limit=10, set_id=None)

Check whether an item is available for loan. Either bid or isbn should be provided.

Parameters
  • bid (Optional[str]) –

  • isbn (Optional[str]) –

  • sort (Union[str, Sort, None]) – By default, results are sorted by published year in descending order. Use PUBDATE to sort in ascending order instead, or TITLE to sort by title in ascending order, ignoring articles like “a”, “an” or “the”. These values can also be found in constants.Sort.

  • start (int) – Start pointer for returned records.

  • limit (int) – Maximum records to be returned. This is capped at 100 records even if a number greater than 100 is specified.

  • set_id (Optional[str]) – For use in pagination. This can be used with start to return the index position of the next record in the backend system

Return type

GetAvailabilityInfoResponse

Returns

get_title_details(bid=None, isbn=None)

Get detailed information about an item. Either bid or isbn should be provided.

Parameters
  • bid (Optional[str]) –

  • isbn (Optional[str]) –

Return type

GetTitleDetailsResponse

Returns

search(keywords=None, author=None, subject=None, title=None, branch=None, media_code=None, language=None, sort=None, start=1, limit=10, set_id=None)

Searches content according to search criteria.

Parameters
  • keywords (Optional[str]) –

  • author (Optional[str]) –

  • subject (Optional[str]) –

  • title (Optional[str]) –

  • branch (Union[str, Branch, None]) – Include only results from a particular branch. See constants.Branch for possible values.

  • media_code (Union[str, MediaCode, None]) – Include only results of a particular media type. See constants.MediaCode for possible values.

  • language (Union[str, Language, None]) – Include only results in a particular language. See constants.Language for possible values.

  • sort (Union[str, Sort, None]) – By default, results are sorted by published year in descending order. Use PUBDATE to sort in ascending order instead, or TITLE to sort by title in ascending order, ignoring articles like “a”, “an” or “the”. These values can also be found in constants.Sort.

  • start (int) – Start pointer for returned records.

  • limit (int) – Maximum records to be returned. This is capped at 100 records even if a number greater than 100 is specified.

  • set_id (Optional[str]) – For use in pagination. This can be used with start to return the index position of the next record in the backend system

Return type

SearchResponse

Returns

nlbsg.constants module

class nlbsg.constants.Branch

Bases: enum.Enum

Branch Code and Branch Name Mapping

http://www.nlb.gov.sg/labs/technical-documentation/#BranchCodeandBranchNameMapping

ANG_MO_KIO_PUBLIC_LIBRARY = 'AMKPL'
BEDOK_PUBLIC_LIBRARY = 'BEPL'
BISHAN_PUBLIC_LIBRARY = 'BIPL'
BUKIT_BATOK_PUBLIC_LIBRARY = 'BBPL'
BUKIT_MERAH_PUBLIC_LIBRARY = 'BMPL'
BUKIT_PANJANG_PUBLIC_LIBRARY = 'BPPL'
CENTRAL_PUBLIC_LIBRARY = 'CLL'
CHENG_SAN_PUBLIC_LIBRARY = 'CSPL'
CHOA_CHU_KANG_PUBLIC_LIBRARY = 'CCKPL'
CLEMENTI_PUBLIC_LIBRARY = 'CMPL'
GEYLANG_EAST_PUBLIC_LIBRARY = 'GEPL'
JURONG_REGIONAL_LIBRARY = 'JRL'
JURONG_WEST_PUBLIC_LIBRARY = 'JWPL'
LEE_KONG_CHIAN_REFERENCE_LIBRARY = 'LKCRL'
LEE_KONG_CHIAN_REFERENCE_LIBRARY_LEVEL_11 = '11LKCRL'
LEE_KONG_CHIAN_REFERENCE_LIBRARY_LEVEL_7 = '07LKCRL'
LEE_KONG_CHIAN_REFERENCE_LIBRARY_LEVEL_8 = '08LKCRL'
LEE_KONG_CHIAN_REFERENCE_LIBRARY_LEVEL_9 = '09LKCRL'
LIBRARY_AT_CHINATOWN = 'CNPL'
LIBRARY_AT_ESPLANADE = 'EPPL'
LIBRARY_AT_HARBOURFRONT = 'HBPL'
LIBRARY_AT_ORCHARD = 'OCPL'
LIBRARY_SUPPLY_CENTRE = 'LSC'
LIBRARY_SUPPLY_CENTRE_FOR_AV = 'LSCAV'
MARINE_PARADE_PUBLIC_LIBRARY = 'MPPL'
MOBILE_BUS = 'MOLLEY'
NL_HERITAGE = 'LOLC'
PASIR_RIS_PUBLIC_LIBRARY = 'PRPL'
QUEENSTOWN_PUBLIC_LIBRARY = 'QUPL'
SEMBAWANG_PUBLIC_LIBRARY = 'SBPL'
SENGKANG_PUBLIC_LIBRARY = 'SKPL'
SERANGOON_PUBLIC_LIBRARY = 'SRPL'
TAMPINES_REGIONAL_LIBRARY = 'TRL'
TOA_PAYOH_PUBLIC_LIBRARY = 'TPPL'
WOODLANDS_REGIONAL_LIBRARY = 'WRL'
YISHUN_PUBLIC_LIBRARY = 'YIPL'
class nlbsg.constants.Language

Bases: enum.Enum

An enumeration.

CHINESE = 'Chinese'
ENGLISH = 'English'
MALAY = 'Malay'
TAMIL = 'Tamil'
class nlbsg.constants.MediaCode

Bases: enum.Enum

Title Level Media Code and Media Description Mapping

http://www.nlb.gov.sg/labs/technical-documentation/#TitleLevelMediaCodeandMediaDescriptionMapping

BOOKS = 'BK'
COMPUTER_FILE = 'CF'
MAPS = 'MP'
MIXED_MATERIALS = 'MX'
MUSIC = 'MU'
SERIALS = 'SE'
VISUAL_MATERIALS = 'VM'
class nlbsg.constants.Sort

Bases: enum.Enum

An enumeration.

PUBDATE = 'PUBDATE'
TITLE = 'TITLE'

nlbsg.types module

class nlbsg.types.GetAvailabilityInfoResponse(status, message, error_message, next_record_position, set_id, items)

Returned by Client.get_availability_info.

Variables
  • status (str) –

  • message (str) –

  • error_message (Optional[str]) –

  • next_record_position (Optional[int]) –

  • set_id (Optional[str]) –

  • items (Optional[Iterable[Item]]) –

Example GetAvailabilityInfoResponse:

GetAvailabilityInfoResponse(
    status='OK',
    message='Operation completed successfully',
    error_message=None,
    next_record_position=2,
    set_id='3709',
    items=tuple([
        Item(
            item_no='B33315114J',
            branch_id='AMKPL',
            branch_name='Ang Mo Kio Public Library',
            location_code='____',
            location_desc='Adult Lending',
            call_number='English      TOL -[FN]',
            status_code='S',
            status_desc='Not On Loan',
            media_code=None,
            media_desc='Book',
            status_date='06/09/2018',
            due_date=None,
            cluster_name=None,
            category_name=None,
            collection_code=None,
            collection_min_age_limit=None
        ),
        Item(
            item_no='B33315118C',
            branch_id='BBPL',
            branch_name='Bukit Batok Public Library',
            location_code='____',
            location_desc='Adult Lending',
            call_number='English      TOL -[FN]',
            status_code='C',
            status_desc='On Loan',
            media_code=None,
            media_desc='Book',
            status_date='08/11/2018',
            due_date='08/11/2018',
            cluster_name=None,
            category_name=None,
            collection_code=None,
            collection_min_age_limit=None
        )
    ])
)
class nlbsg.types.GetTitleDetailsResponse(status, message, error_message, title_detail)

Returned by Client.get_title_details.

Variables
  • status (str) –

  • message (str) –

  • error_message (Optional[str]) –

  • title_detail (Optional[TitleDetail]) –

Example GetTitleDetailsResponse:

GetTitleDetailsResponse(
    status='OK',
    message='Operation completed successfully',
    error_message=None,
    title_detail=TitleDetail(
        bid='203125808',
        title_name='Beren and Lúthien / by  J.R.R. Tolkien ; edited by Christopher Tolkien ; with illustrations by  Alan Lee.',
        author='Tolkien, J. R. R.',
        other_authors='Tolkien, J. R. R. (John Ronald Reuel), 1892-1973|Tolkien, Christopher|Lee, Alan',
        publisher=None,
        physical_desc='288 pages (pages numbered 8-288) :chiefly color illustrations ;21 cm',
        subjects=(
            'Middle Earth (Imaginary place) Fiction',
            'Elves Fiction',
            'Fantasy fiction'
        ),
        summary="The epic tale of Beren and Lúthien became an essential element in the evolution of The Silmarillion, the myths and legends of J.R.R. Tolkien's First Age of the World. Always key to the story is the fate that shadowed their love: Beren was a mortal man, Lúthien an immortal Elf. Her father, a great Elvish lord, imposed on Beren an impossible task before he might wed Lúthien: to rob the greatest of all evil beings, Melkor, of a Silmaril.Painstakingly restored from Tolkien's manuscripts and presented for the first time as a continuous and standalone story, Beren and Lúthien reunites fans of The Hobbit and The Lord of the Rings with Elves and Men, along with the rich landscape and creatures unique to Tolkien's Middle-earth. Christopher Tolkien tells the story in his father's own words by giving its original form as well as prose and verse passages from later texts that illustrate the narrative as it changed. -- from back cover.",
        notes="First published by Harper Collins Publishers 2017.Includes abstractsThe epic tale of Beren and Lúthien became an essential element in the evolution of The Silmarillion, the myths and legends of J.R.R. Tolkien's First Age of the World. Always key to the story is the fate that shadowed their love: Beren was a mortal man, Lúthien an immortal Elf. Her father, a great Elvish lord, imposed on Beren an impossible task before he might wed Lúthien: to rob the greatest of all evil beings, Melkor, of a Silmaril.Painstakingly restored from Tolkien's manuscripts and presented for the first time as a continuous and standalone story, Beren and Lúthien reunites fans of The Hobbit and The Lord of the Rings with Elves and Men, along with the rich landscape and creatures unique to Tolkien's Middle-earth. Christopher Tolkien tells the story in his father's own words by giving its original form as well as prose and verse passages from later texts that illustrate the narrative as it changed. -- from back cover.",
        isbn='1328915336 (paperback)',
        issn=None,
        n_title_name=None,
        n_author=None,
        n_publisher=None
    )
)
class nlbsg.types.Item(item_no, branch_id, branch_name, location_code, location_desc, call_number, status_code, status_desc, media_code, media_desc, status_date, due_date, cluster_name, category_name, collection_code, collection_min_age_limit, available)

Part of GetAvailabilityInfoResponse.

Variables
  • item_no (str) –

  • branch_id (str) –

  • branch_name (str) –

  • location_code (str) –

  • location_desc (str) –

  • call_number (str) –

  • status_code (str) –

  • status_desc (str) –

  • media_code (Optional[str]) –

  • media_desc (str) –

  • status_date (str) –

  • due_date (Optional[str]) –

  • cluster_name (Optional[str]) –

  • category_name (Optional[str]) –

  • collection_code (Optional[str]) –

  • collection_min_age_limit (Optional[str]) –

  • available (bool) –

Example Item:

Item(
    item_no='B33315118C',
    branch_id='BBPL',
    branch_name='Bukit Batok Public Library',
    location_code='____',
    location_desc='Adult Lending',
    call_number='English      TOL -[FN]',
    status_code='C',
    status_desc='On Loan',
    media_code=None,
    media_desc='Book',
    status_date='08/11/2018',
    due_date='08/11/2018',
    cluster_name=None,
    category_name=None,
    collection_code=None,
    collection_min_age_limit=None,
    available=False,
)
class nlbsg.types.SearchResponse(status, message, error_message, total_records, next_record_position, set_id, titles)

Returned by Client.search.

Variables
  • status (str) –

  • message (str) –

  • error_message (Optional[str]) –

  • total_records (Optional[int]) –

  • next_record_position (Optional[int]) –

  • set_id (Optional[str]) –

  • titles (Optional[Iterable[Title]]) –

Example SearchResponse:

SearchResponse(
    status='OK',
    message='Operation completed successfully',
    error_message=None,
    total_records=52,
    next_record_position=4,
    set_id='PGE3676',
    titles=tuple([
        Title(
            bid='203125808',
            isbn='1328915336 (paperback)',
            title_name='Beren and Lúthien / by  J.R.R. Tolkien ; edited by Christopher Tolkien ; with illustrations by  Alan Lee.',
            author='Tolkien, J. R. R. (John Ronald Reuel), 1892-1973',
            publish_year='2018',
            media_code='BK',
            media_desc='Books'
        ),
        Title(
            bid='204576140',
            isbn='9780008214210 (electronic bk)',
            title_name='Beren and l℗♭©ʻthien [electronic resource]. J. R. R Tolkien.',
            author='Tolkien, J. R. R.',
            publish_year='2017',
            media_code='BK',
            media_desc='Books'
        )
    ])
)
class nlbsg.types.Title(bid, isbn, title_name, author, publish_year, media_code, media_desc)

Part of SearchResponse.

Variables
  • bid (str) –

  • isbn (str) –

  • title_name (str) –

  • author (str) –

  • publish_year (str) –

  • media_code (str) –

  • media_desc (str) –

Example Title:

Title(
    bid='203125808',
    isbn='1328915336 (paperback)',
    title_name='Beren and Lúthien / by  J.R.R. Tolkien ; edited by Christopher Tolkien ; with illustrations by  Alan Lee.',
    author='Tolkien, J. R. R. (John Ronald Reuel), 1892-1973',
    publish_year='2018',
    media_code='BK',
    media_desc='Books'
)
class nlbsg.types.TitleDetail(bid, title_name, author, other_authors, publisher, physical_desc, subjects, summary, notes, isbn, issn, n_title_name, n_author, n_publisher)

Part of GetTitleDetailsResponse.

Variables
  • bid (str) –

  • title_name (str) –

  • author (str) –

  • other_authors (str) –

  • publisher (Optional[str]) –

  • physical_desc (str) –

  • subjects (Iterable[str]) –

  • summary (str) –

  • notes (str) –

  • isbn (str) –

  • issn (Optional[str]) –

  • n_title_name (Optional[str]) –

  • n_author (Optional[str]) –

  • n_publisher (Optional[str]) –

Example TitleDetail:

TitleDetail(
    bid='203125808',
    title_name='Beren and Lúthien / by  J.R.R. Tolkien ; edited by Christopher Tolkien ; with illustrations by  Alan Lee.',
    author='Tolkien, J. R. R.',
    other_authors='Tolkien, J. R. R. (John Ronald Reuel), 1892-1973|Tolkien, Christopher|Lee, Alan',
    publisher=None,
    physical_desc='288 pages (pages numbered 8-288) :chiefly color illustrations ;21 cm',
    subjects=(
        'Middle Earth (Imaginary place) Fiction',
        'Elves Fiction',
        'Fantasy fiction'
    ),
    summary="The epic tale of Beren and Lúthien became an essential element in the evolution of The Silmarillion, the myths and legends of J.R.R. Tolkien's First Age of the World. Always key to the story is the fate that shadowed their love: Beren was a mortal man, Lúthien an immortal Elf. Her father, a great Elvish lord, imposed on Beren an impossible task before he might wed Lúthien: to rob the greatest of all evil beings, Melkor, of a Silmaril.Painstakingly restored from Tolkien's manuscripts and presented for the first time as a continuous and standalone story, Beren and Lúthien reunites fans of The Hobbit and The Lord of the Rings with Elves and Men, along with the rich landscape and creatures unique to Tolkien's Middle-earth. Christopher Tolkien tells the story in his father's own words by giving its original form as well as prose and verse passages from later texts that illustrate the narrative as it changed. -- from back cover.",
    notes="First published by Harper Collins Publishers 2017.Includes abstractsThe epic tale of Beren and Lúthien became an essential element in the evolution of The Silmarillion, the myths and legends of J.R.R. Tolkien's First Age of the World. Always key to the story is the fate that shadowed their love: Beren was a mortal man, Lúthien an immortal Elf. Her father, a great Elvish lord, imposed on Beren an impossible task before he might wed Lúthien: to rob the greatest of all evil beings, Melkor, of a Silmaril.Painstakingly restored from Tolkien's manuscripts and presented for the first time as a continuous and standalone story, Beren and Lúthien reunites fans of The Hobbit and The Lord of the Rings with Elves and Men, along with the rich landscape and creatures unique to Tolkien's Middle-earth. Christopher Tolkien tells the story in his father's own words by giving its original form as well as prose and verse passages from later texts that illustrate the narrative as it changed. -- from back cover.",
    isbn='1328915336 (paperback)',
    issn=None,
    n_title_name=None,
    n_author=None,
    n_publisher=None
)