Skip to main content

aioaudiobookshelf

Async python library to interact with Audiobookshelf (ABS).

This lib's primary goal is to be used within the Audiobookshelf music provider in Music Assistant, but it can be used independently. Calls to endpoints not needed for the provider will be added over time.

Not all endpoints are yet implemented.

Requires ABS 2.6.0 or newer, logging in to an older server raises UnsupportedServerVersionError.

Issues

If you are facing issues with this lib or the audiobookshelf provider, please use our support repository for reporting them.

Releases

Releases can be found on pypi, and are tagged.

Basic usage

ABS has a rest api, documented here and additionally uses socket.io, see here for some event driven functionality. Accessibility to the endpoints is determined by the user types, which may be root, admin, user, guest. This lib is not tested with a guest user.

As of 0.1.2 this lib has two different clients, the UserClient and the SocketClient. Admin endpoints are not yet implemented. The user client handles calls to the Rest API, the socket client allows to subscribe to certain events.

To authenticate the socket client, you always need the user's token, username and password are not enough. The user client can be authenticated by username and password, which yields the token.

Usage example:

import asyncio
import logging
import os

import aiohttp

from aioaudiobookshelf import SessionConfiguration, get_user_client
from aioaudiobookshelf.schema.library import LibraryItemMinifiedBook, LibraryItemMinifiedPodcast

ABS_HOST = os.environ.get("ABS_HOST")
ABS_USER = os.environ.get("ABS_USER")
ABS_PASSWORD = os.environ.get("ABS_PASSWORD")


async def abs_basics():
    assert ABS_HOST is not None
    assert ABS_USER is not None
    assert ABS_PASSWORD is not None

    logger = logging.getLogger()
    logger.setLevel(logging.INFO)

    async with aiohttp.ClientSession() as session:
        client = await get_user_client(
            session_config=SessionConfiguration(
                session=session, url=ABS_HOST, logger=logger, pagination_items_per_page=30
            ),
            username=ABS_USER,
            password=ABS_PASSWORD,
        )

        # get libraries
        libraries = await client.get_all_libraries()

        # get library items
        for library in libraries:
            async for response in client.get_library_items(library_id=library.id_):
                if not response.results:
                    break
                for lib_item_minified in response.results:
                    if isinstance(lib_item_minified, LibraryItemMinifiedPodcast):
                        ...
                    if isinstance(lib_item_minified, LibraryItemMinifiedBook):
                        ...

        # get a single podcast
        podcast_id = "dda96167-eaad-4012-83e1-149c6700d3e8"
        podcast_expanded = await client.get_library_item_podcast(podcast_id=podcast_id, expanded=True)


asyncio.run(abs_basics())

Have a look into aioaudiobookshelf/client/*.py to see which endpoints are currently implemented. And the provider implementation shows, how the lib can potentially be used.

Metadata

Release files for aioaudiobookshelf 0.2.1

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

Source distribution (sdist)

Source distribution for aioaudiobookshelf 0.2.1
File Size Uploaded Provenance
aioaudiobookshelf-0.2.1.tar.gz 56.9 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 108.9 kB

Release files / aioaudiobookshelf-0.2.1.tar.gz

Download URL aioaudiobookshelf-0.2.1.tar.gz
Size 56.9 kB
Tags Source
SHA-256 checksum
How to use checksums
43e07f564b5062e44ef7d98534d08443547319c97a2c89ec5e67561ba000a7f6
BLAKE2b-256 checksum
How to use checksums
00ab568513afb09c73e7bceecc9bc5b2cf9795ed20e63fe10a9bb8c555abdfa2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.8

Release files / aioaudiobookshelf-0.2.1-py3-none-any.whl

Download URL aioaudiobookshelf-0.2.1-py3-none-any.whl
Size 52.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b57668eba9e714c4c8de33c9e42acbc2da14ab830e30a3d84d1088737eb05eb7
BLAKE2b-256 checksum
How to use checksums
d0bb686e5da63e5291a6aa1c18e1a7b3f450dcd87a7880b1f3bf9caf28cd8a4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.8

Security for aioaudiobookshelf 0.2.1

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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