Browse docs

API Reference

HTTP API endpoints for interacting with Alex programmatically

Alex exposes a REST API for core operations. The UI is built on top of these endpoints.

Authentication

Authenticated endpoints require a valid session cookie (web) or a valid x-alex-desktop-auth header (Electron desktop mode).

Roles:

  • admin - Full access, including user management and admin settings.
  • user - Can read books, manage personal collections, and track progress.

Authenticated endpoints

Books

MethodEndpointDescription
GET/api/booksList books with pagination, search, and filters. Query params: q, type, status, sort, page, limit.
GET/api/books/now-readingList current user's in-progress books, ordered by most recently read.
GET/api/books/[id]Get metadata for a single book.
DELETE/api/books/[id]Delete a book.
PATCH/api/books/[id]Update book metadata.
GET/api/books/[id]/fileStream a book file (PDF or EPUB) with HTTP range support.
GET/api/books/[id]/book.epubServe an EPUB file at a .epub URL (required by some clients).
GET/api/books/[id]/coverServe a book cover image.
GET/api/books/[id]/progressGet current user's reading progress.
PUT/api/books/[id]/progressUpdate progress. Body: { currentPage, totalPages } (PDF) or { epubLocation } (EPUB).

Collections

MethodEndpointDescription
GET/api/collectionsList current user's collections with book counts.
POST/api/collectionsCreate a collection. Body: { name, description? }.
GET/api/collections/[id]Get a collection with its books.
PATCH/api/collections/[id]Update a collection. Body: { name?, description? }.
DELETE/api/collections/[id]Delete a collection (books are not deleted).
GET/api/collections/[id]/booksList books in a collection.
POST/api/collections/[id]/booksAdd a book to a collection.
DELETE/api/collections/[id]/books/[bookId]Remove a book from a collection.
GET/api/collections/[id]/now-readingList in-progress books inside a collection.
POST/api/collections/[id]/shareEnable sharing. Returns { shareToken, shareUrl }.
DELETE/api/collections/[id]/shareDisable sharing and revoke token.

Users (admin only)

MethodEndpointDescription
GET/api/usersList all users.
POST/api/usersCreate a user.
PATCH/api/users/[id]Update a user (role, password, display name).

Admin (admin only)

MethodEndpointDescription
POST/api/admin/library/clearClear all books from the library.
POST/api/electron/clear-booksClear books for Electron app reset (desktop only).

Real-time updates

MethodEndpointDescription
GET/api/library/eventsServer-Sent Events endpoint for library updates.

Public endpoints

These endpoints require no auth and are scoped by share token.

MethodEndpointDescription
GET/api/shared/[token]Get shared collection metadata and paginated books.
GET/api/shared/[token]/booksGet paginated book list for a shared collection.
GET/api/shared/[token]/covers/[bookId]Get cover image for a shared collection book.
GET/api/shared/[token]/books/[bookId]/fileStream a shared collection book file.
GET/api/shared/[token]/books/[bookId]/book.epubServe EPUB from shared collection.

Source-aware book streaming

The four file-serving routes (/file and /book.epub for authenticated and public access) all route through the same source-aware pipeline.

  • For source=local, bytes are streamed from disk.
  • For source=s3, bytes are streamed through watcher-rs from your configured bucket.

This keeps API behavior stable even when your ingestion backend changes.