Skip to main content

opds2.0

A Python library for generating OPDS (Open Publication Distribution System) 2.0 compliant feeds using Pydantic and type hints.

Based on the OPDS 2.0 specification.

Installation

This package is not yet on PyPI. Install directly from GitHub:

pip install git+https://github.com/ArchiveLabs/opds2.0.git

Running Tests

pytest tests/ -v

Developer's Guide

To use this library, you must implement two key classes:

  • DataProvider: Defines how to search and retrieve records. You must subclass and implement the search method.
  • DataProviderRecord: Defines the structure of a single record in your catalog. You must subclass and implement the metadata, links, and images methods.

Example

from pyopds2 import Catalog, DataProvider, DataProviderRecord, Metadata, Link

class MyRecord(DataProviderRecord):
    def metadata(self):
        return Metadata(title="Example Book")
    def links(self):
        return [Link(href="/books/1", rel="self", type="application/epub+zip")]
    def images(self):
            return None

class MyProvider(DataProvider):
    @staticmethod
    def search(query, limit=50, offset=0, sort=None):
        records = [MyRecord()]
        # Return a list of MyRecord instances and total count
        return MyProvider.SearchResponse(
            MyProvider,
            records=records,
            total=len(records),
            query=query,
            limit=limit,
            offset=offset,
            sort=sort
        )

catalog = Catalog.create(MyProvider.search("example"))
catalog.model_dump_json()

See examples/openlibrary.py for a real-world integration with OpenLibrary.

API Reference

Core Models

  • Catalog: Represents an OPDS 2.0 catalog/feed
  • Publication: Represents a publication (book, audiobook, etc.)
  • Metadata: Metadata for catalogs and publications
  • Link: Links to resources
  • Contributor: Authors, illustrators, publishers, etc.
  • Navigation: Navigation links for browsing

Catalog Functions

  • Catalog(): Create a basic catalog
  • Catalog.create(): Run a search and create a paginated Catalog from the search results

Similar Implementations

This library was inspired by The Palace Project's OPDS implementation.

License

AGPLv3 License. See LICENSE for details.

Metadata

Release files for pyopds2 0.1.0

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

Source distribution (sdist)

Source distribution for pyopds2 0.1.0
File Size Uploaded Provenance
pyopds2-0.1.0.tar.gz 22.4 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 41.5 kB

Release files / pyopds2-0.1.0.tar.gz

Download URL pyopds2-0.1.0.tar.gz
Size 22.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e6493c1ec6e0ca555ee27eae2f55a27982e430b701a16788913ad349a661ce23
BLAKE2b-256 checksum
How to use checksums
cd743f2430a6c84ddbdcd43c786a0401e004fd6072b4c8543fe2cce5b7edd451
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.1

Release files / pyopds2-0.1.0-py3-none-any.whl

Download URL pyopds2-0.1.0-py3-none-any.whl
Size 19.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7f1cac263050e2a349c6108fc695fe40dbf76f9c888f79cef052c2a51750ece6
BLAKE2b-256 checksum
How to use checksums
49c8e0bd66ce12b158e25a94e4d14a626675ac2c4eba6c6c501f10e9ed5961ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.1

Security for pyopds2 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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