Skip to content

Python API

Comprehensive guide to ebk's Python API for programmatic library management.

Overview

ebk provides a powerful SQLAlchemy-based API for working with ebook libraries programmatically. The API follows modern Python conventions and supports context managers, fluent queries, and async operations (for LLM features).

Basic Usage

Opening a Library

from pathlib import Path
from ebk.library_db import Library

# Open existing library
lib = Library.open(Path("~/my-library"))

# Use context manager (recommended)
with Library.open(Path("~/my-library")) as lib:
    # Work with library
    results = lib.search("Python")

# Library is automatically closed

See the API Guide for complete documentation.

Core Classes

  • Library - Main library class
  • Book - Book model (SQLAlchemy ORM)
  • Author - Author model
  • Subject - Subject/tag model
  • File - File model
  • Cover - Cover image model

Further Reading