Skip to main content

Python package for getting basic data from a FOLIO LSP server

Project description

Pokapi

Pokapi (Python Okapi Interface) is a Python package for getting basic data from a FOLIO LSP server using the Okapi API.

License Latest release DOI Python PyPI

Table of contents

Introduction

The FOLIO platform is a library services platform. The Caltech Library uses a hosted solution by EBSCO for its library catalog. To make writing interfaces and automation scripts in Python easier, the Caltech Library Digital Library Development team are developing Pokapi (Python Okapi Interface), a Python package that provides an object-oriented interface to accessing FOLIO data via the Okapi API. It currently provides a simple object structure based mostly on FOLIO instance records.

Incidentally, okapi (properly known as Okapia johnstoni) are real animals related to the giraffe. They are an endangered species whose population continues to decrease due to human activity and hunting by humans.

Installation

The instructions below assume you have a Python interpreter installed on your computer; if that's not the case, please first install Python version 3 and familiarize yourself with running Python programs on your system.

On Linux, macOS, and Windows operating systems, you should be able to install pokapi with pip. To install pokapi from the Python package repository (PyPI), run the following command:

python3 -m pip install pokapi

As an alternative to getting it from PyPI, you can use pip to install pokapi directly from GitHub, like this:

python3 -m pip install git+https://github.com/caltechlibrary/pokapi.git

Usage

The use of Pokapi is straightfoward. First, callers must create one instance of a Folio object that defines various aspects of how to communicate with their FOLIO/Okapi system. Then, callers can use the record(...) method on that Folio object to get objects that represent records in their FOLIO system. The method only requires an identifier, which can be a FOLIO instance identifier, an item barcode, or an EDS accession number. More details about all of this are provided below.

The Folio interface object

To use Pokapi, first create a Folio object with parameters that define certain things Pokapi can't get on its own. These are: the the Okapi URL for your instance, an Okapi API token, a tenant id, and the prefix that appears in front of your accession numbers. Assuming that these values are stored in separate variables, the following code illustrates how to create a Folio object:

from pokapi import Folio

folio = Folio(okapi_url = the_okapi_url,
              okapi_token = the_okapi_token,
              tenant_id = the_tenant_id,
              an_prefix = the_accession_number_prefix)

As an example of a prefix for accession numbers, for Caltech the prefix is the clc part of an accession number such as clc.025d49d5.735a.4d79.8889.c5895ac65fd2.

The record(...) method

The Folio class has only one method on it currently: record(...). This method contacts the FOLIO server to obtain data and returns a FolioRecord object with the data stored in fields. The following fields are implemented at this time:

Field Type Meaning
id string FOLIO instance record identifier
accession_number string The accession number for the record
title string Title of the work
author string Author; multiple authors are separated by "and"
publisher string Publisher
year string Year of publication
edition string the edition of the work (if any)
isbn_issn string ISBN or ISSN

The method Folio.record(...) can take any one of the following mutually-exclusive keyword arguments to identify the record to be retrieved:

  • barcode: retrieve the record corresponding to the given item barcode
  • instance_id: retrieve the record having the given FOLIO instance identifier
  • accession_number: retrieve the record corresponding to the accession number

Here is an example of using the method:

r = folio.record(barcode = "35047019531631")
assert r.id == "1fedf5f3-b631-4d34-8d40-e022f70ab232"
assert r.title == "The bad doctor"
assert r.year == "2015"
assert r.author == "Williams, Ian"
assert r.isbn_issn == "9780271067544"
assert r.publisher == "The Pennsylvania State University Press"

Known issues and limitations

The following are known limitations at this time:

  • If a record has multiple publishers, only the first publisher name is retrieved.
  • The title is extracted from the instance record's title field, but because (at least in our catalog) the title contains both a title and author info, Pokapi has to use heuristics to extract out just the title from the string. The heuristics might fail in some cases, especially if your installation of FOLIO uses different conventions for formatting the title field.

Getting help

If you find an issue, please submit it in the GitHub issue tracker for this repository.

Contributing

We would be happy to receive your help and participation with enhancing Pokapi! Please visit the guidelines for contributing for some tips on getting started.

License

Software produced by the Caltech Library is Copyright © 2021 California Institute of Technology. This software is freely distributed under a BSD/MIT type license. Please see the LICENSE file for more information.

Acknowledgments

This work was funded by the California Institute of Technology Library.

The vector artwork of the face of an okapi, used as the icon for this project, was created by Icons Producer from the Noun Project. It is licensed under the Creative Commons CC-BY 3.0 license.

Pokapi makes use of numerous open-source packages, without which Pokapi could not have been developed. I want to acknowledge this debt. In alphabetical order, the packages are:

  • CommonPy – a collection of commonly-useful Python functions
  • ipdb – the IPython debugger
  • lxml – an XML parsing library for Python
  • Python Decouple – a high-level configuration file interface
  • setuptools – library for setup.py
  • Sidetrack – simple debug logging/tracing package
  • uritemplate – URI template parsing per RFC 6570
  • validators – Python data validation for Humans

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pokapi-0.3.1.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pokapi-0.3.1-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file pokapi-0.3.1.tar.gz.

File metadata

  • Download URL: pokapi-0.3.1.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/57.0.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.5

File hashes

Hashes for pokapi-0.3.1.tar.gz
Algorithm Hash digest
SHA256 b9de1319a455c2f3a19b78a41698d60297be68319fcaa9eaab41804dbc2b2a16
MD5 b4ec8fec283e6989aef49c3060403a30
BLAKE2b-256 c199ee3a5b1d948d348002609511a19602909ac645730fbffadb9316fb3dd2e8

See more details on using hashes here.

File details

Details for the file pokapi-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: pokapi-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/57.0.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.5

File hashes

Hashes for pokapi-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bf943908e882eb0823df43d2d11c13983b6d3e6eef13c133bf5921f2c63b9b1c
MD5 5453eecbe6e9c05524c4706958147f02
BLAKE2b-256 370991f52390a1a541e1d49d1cef0ebf4405c3360257643a3e302c45aafd5569

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page