Package: pokapi
PokapiPokapi (Python Okapi Interface)  is a Python package for getting basic data from aFOLIOLSP server using theOkapi API.Table of contentsIntroductionInstallationUsageKnown issues and limitationsGetting helpContributingLicenseAuthors and historyAcknowledgmentsIntroductionTheFOLIOplatform is alibrary services platform.  The Caltech Library uses a hosted solution byEBSCOfor itslibrary catalog.   To make writing interfaces and automation scripts in Python easier, the Caltech LibraryDigital Library Development teamare developing Pokapi (Python Okapi Interface), a Python package that provides an object-oriented interface to accessing FOLIO data via theOkapi API. It currently provides a simple object structure based mostly on FOLIOinstancerecords.Incidentally,okapi(properly known asOkapia johnstoni) are real animals related to the giraffe. They are anendangered specieswhose population continues to decrease due to human activity andhunting by humans.InstallationThe instructions below assume you have a Python interpreter installed on your computer; if that's not the case, please firstinstall Python version 3and familiarize yourself with running Python programs on your system.OnLinux,macOS, andWindowsoperating systems, you should be able to installpokapiwithpip.  To installpokapifrom thePython package repository (PyPI), run the following command:python3-mpipinstallpokapiAs an alternative to getting it fromPyPI, you can usepipto installpokapidirectly from GitHub, like this:python3-mpipinstallgit+https://github.com/caltechlibrary/pokapi.gitUsageThe use of Pokapi is straightfoward. First, callers must create one instance of aFolioobject that defines various aspects of how to communicate with their FOLIO/Okapi system. Then, callers can use therecord(...)method on thatFolioobject 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.TheFoliointerface objectTo use Pokapi, first create aFolioobject 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 aFolioobject:frompokapiimportFoliofolio=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 theclcpart of an accession number such asclc.025d49d5.735a.4d79.8889.c5895ac65fd2.Therecord(...)methodTheFolioclass has only one method on it currently:record(...). This method contacts the FOLIO server to obtain data and returns aFolioRecordobject with the data stored in fields. The following fields are implemented at this time:FieldTypeMeaningidstringFOLIO instance record identifieraccession_numberstringThe accession number for the recordtitlestringTitle of the workauthorstringAuthor; multiple authors are separated by "and"publisherstringPublisheryearstringYear of publicationeditionstringthe edition of the work (if any)isbn_issnstringISBN or ISSNThe methodFolio.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 barcodeinstance_id: retrieve the record having the given FOLIO instance identifieraccession_number: retrieve the record corresponding to the accession numberHere is an example of using the method:r=folio.record(barcode="35047019531631")assertr.id=="1fedf5f3-b631-4d34-8d40-e022f70ab232"assertr.title=="The bad doctor"assertr.year=="2015"assertr.author=="Williams, Ian"assertr.isbn_issn=="9780271067544"assertr.publisher=="The Pennsylvania State University Press"Known issues and limitationsThe 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'stitlefield, 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 thetitlefield.Getting helpIf you find an issue, please submit it inthe GitHub issue trackerfor this repository.ContributingWe would be happy to receive your help and participation with enhancing Pokapi!  Please visit theguidelines for contributingfor some tips on getting started.LicenseSoftware produced by the Caltech Library is Copyright © 2021–2023 California Institute of Technology.  This software is freely distributed under a BSD/MIT type license.  Please see theLICENSEfile for more information.AcknowledgmentsThis work was funded by the California Institute of Technology Library.Thevector artworkof the face of anokapi, used as the icon for this project, was created byIcons Producerfrom the Noun Project.  It is licensed under the Creative CommonsCC-BY 3.0license.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 functionsipdb– the IPython debuggerlxml– an XML parsing library for PythonPython Decouple– a high-level configuration file interfacesetuptools– library forsetup.pySidetrack– simple debug logging/tracing packageuritemplate– URI template parsing per RFC 6570validators– Python data validation for Humans