Skip to main content

pyfolioclient

A Python client for interacting with FOLIO's APIs.

Prerequisites

  • Python 3.9+
  • FOLIO Poppy release or newer (requires expiring tokens)

Configuration

The clients requires:

  • An URL to the FOLIO OKAPI (i.e. foliopath/okapi)
  • The username of the tenant in FOLIO
  • The username of a user with adequate permissions in FOLIO and the password for the user

Installation

Choose your preferred installation method:

pip install pyfolioclient
# or
pip3 install pyfolioclient
# or
uv add pyfolioclient

Features

FolioBaseClient

Features:

  • Authentication and token management
  • Re-authentication when token expires
  • Persistent connections using httpx Client
  • Support for all standard HTTP methods (GET, POST, PUT, DELETE)
  • Iterator implementation for paginated GET requests
  • Resource cleanup through context manager

FolioClient

Extends FolioBaseClient and provides useful methods for common operations in FOLIO. Provided for convencience. It contains convenience methods for:

  • Users
  • Inventory
    • Instances
    • Holdings
    • Items
  • Circulation
    • Loans
    • Requests
  • Data import

Usage Examples

FolioBaseClient

from pyfolioclient import FolioBaseClient

with FolioBaseClient(base_url, tenant, user, password) as folio:
    for user in folio.iter_data("/users", key="users", cql_query="username==bob*"):
        print(user)

FolioClient

from pyfolioclient import FolioClient, ItemNotFoundError

with FolioClient(base_url, tenant, user, password) as folio:
    for loan in folio.get_loans("status=Open"):
        print(loan.get("dueDate"))
    
    try:
        folio.delete_user_by_id("dcf1fabc-3165-4099-b5e6-aa74f95dee73")
    except ItemNotFoundError as err:
        print("No matching user")

A note on custom exceptions

A number of custom exceptions have been implemented:

  • BadRequestError (HTTP status code 400)
  • ItemNotFoundError (HTTP status code 404)
  • UnprocessableContentError (HTTP status code 422)

Through experience we have found these useful to be able to handle explicitly and separately, rather than being raised as a general HTTP error.

FOLIO API Notes

FOLIO provides two types of endpoints:

  1. Business Logic Modules (/inventory/items)
  2. Storage Modules (/item-storage/items)

For detailed information:

FOLIO API endpoints can be queried using the CQL query language. For an introduction refer to:

Note: Query capabilities may be limited to specific JSON response fields.

Credits

Release files for pyfolioclient 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyfolioclient 0.1.7
File Size Uploaded
pyfolioclient-0.1.7.tar.gz 23.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyfolioclient 0.1.7
File Interpreter ABI Platform
pyfolioclient-0.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 38.3 kB

Release files / pyfolioclient-0.1.7.tar.gz

Download URL pyfolioclient-0.1.7.tar.gz
Size 23.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ec27529930de975ec94fefe0a59f571619a9eff8a0fdef30ff81ff273381d387
BLAKE2b-256 checksum
How to use checksums
5d1473721a6aabdccbef70cef1ace0e7717c25c51024516fb6e9db794b654df4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / pyfolioclient-0.1.7-py3-none-any.whl

Download URL pyfolioclient-0.1.7-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e416cd1b0096eb5731fb58de48ef28fdbb8e892118c64a0afdfa858d8e00d189
BLAKE2b-256 checksum
How to use checksums
cf423a3995762861686f196979ec1659238b7e44819b6b661d762cf27c1f1601
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.1.7 This release

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page