The Books API is the core of ReadRealm. It exposes endpoints for managing the book catalog, fetching details from OpenLibrary, streaming books by genre via Server-Sent Events, toggling bookmarks, and submitting reviews with AI-powered sentiment analysis.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/aliammari1/readrealm/llms.txt
Use this file to discover all available pages before exploring further.
Endpoint summary
| Method | Path | Description |
|---|---|---|
GET | /book | List all books in the local database |
POST | /book | Create a book record |
GET | /book/search | Search books via OpenLibrary |
GET | /book/details/:id | Get enriched book details (OpenLibrary + AI summary) |
GET | /book/summary/:title | Get an AI-generated 5-line summary |
GET | /book/genre/:genre | Stream books by genre (SSE) |
GET | /book/:id | Get a book by numeric ID |
PATCH | /book/:id | Partially update a book |
DELETE | /book/:id | Delete a book |
PUT | /book/bookmark | Toggle a bookmark for a user |
GET | /book/bookmarks/:userId | List all bookmarked books for a user |
POST | /book/ebook | Generate TTS audio from book text |
GET | /book/tts/stream/:title | Stream TTS audio for a book by title |
POST | /book/reviews/:id | Submit a review for a book |
GET | /book/reviews/:id | Get all reviews for a book |
GET | /book/user-reviews/:userId | Get all reviews written by a user |
GET /book
Returns all book records stored in the local MongoDB database.Response
Array of book objects.
POST /book
Persists a new book record to the database. All fields fromCreateBookDto are accepted.
Request body
Numeric book ID. Must be unique.
Primary author name.
Book title.
Year of publication.
Page count.
URL to the cover image.
Primary genre or subject.
Raw plain-text content. Optional; used for TTS generation.
Initial bookmark list. Optional.
Response
Returns the persistedBook document.
GET /book/search
Searches for books using the OpenLibrary search API. Returns up to 12 results.Query parameters
Search query (title, author, ISBN, etc.).
Response
Array of lightweight book objects sourced from OpenLibrary:Book title.
Primary author name.
Year of first publication.
Median page count.
Cover image URL.
GET /book/details/:id
Fetches enriched book details. Checks the local database first; if not found, pulls data from the OpenLibrary Works API, generates an AI summary via Gemini, and upserts the result.Path parameters
OpenLibrary numeric work ID (e.g.
28520 for OL28520W).Response
FullBook document including description, link (EPUB), and populated reviews.
GET /book/summary/:title
Fetches the book text from Gutendex, then uses the Google Gemini API to produce a concise 5-line summary.Path parameters
URL-encoded book title (e.g.
alice%20in%20wonderland).Response
A plain-text string containing the AI-generated 5-line summary.GET /book/genre/:genre
Streams books belonging to a genre via Server-Sent Events (SSE). Results are sourced from OpenLibrary subjects and cached for 15 minutes. The response is paginated withoffset and limit.
Set an
Accept: text/event-stream header or use the EventSource API in the browser. The connection closes automatically after all books in the page have been emitted.Path parameters
Genre/subject slug (e.g.
fantasy, science_fiction, history). Use all to return an empty stream.Query parameters
Number of books to skip.
Number of books to return. Capped at
50.Response
Each SSE event contains a JSON-serialised book object:total, offset, and limit fields are included in every event so clients can implement pagination.
GET /book/:id
Retrieves a single book from the local database by numeric ID.Path parameters
Numeric book ID.
Response
A singleBook document. Returns 404 if not found.
PATCH /book/:id
Partially updates a book. Any subset ofCreateBookDto fields may be supplied.
Path parameters
Numeric book ID.
Request body
All fields are optional (partial update):Updated author name.
Updated title.
Updated publication year.
Updated page count.
Updated cover image URL.
Updated genre.
Updated plain-text content.
Response
The updatedBook document. Returns 404 if not found.
DELETE /book/:id
Permanently removes a book from the database.Path parameters
Numeric book ID.
Response
PUT /book/bookmark
Toggles a bookmark for a user on a given book. If the book does not yet exist in the local database, it is created automatically. If the user already has a bookmark, it is removed; otherwise it is added.Request body
The ID of the user toggling the bookmark.
A
CreateBookDto object representing the book to bookmark.Response
The updatedBook document with the modified bookmarks array.
GET /book/bookmarks/:userId
Returns all books that a given user has bookmarked. Review data is stripped from the response for performance.Path parameters
The user ID to look up bookmarks for.
Response
Array ofBook documents where the bookmarks array contains an entry for the given userId. The reviews field is returned as an empty array.
POST /book/ebook
Generates TTS (text-to-speech) audio using Azure OpenAI from thetextData field of the request body. Only the first 4,096 characters of the text are converted.
See Speech & Audio for full TTS documentation including the streaming endpoint.
Request body
Book ID.
Author name.
Book title.
Publication year.
Page count.
Cover image URL.
Genre.
Plain-text content to convert to speech. If empty, a default
CreateBookDto is substituted.Response
A binary audio stream (audio/mpeg). Use a media player or write the response to a .mp3 file.
GET /book/tts/stream/:title
Fetches the book text from Gutendex by title, then streams the TTS audio as a chunkedaudio/mpeg response.
See Speech & Audio for full documentation of this endpoint.
Path parameters
URL-encoded book title (e.g.
alice%20in%20wonderland).POST /book/reviews/:id
Submits a review for a book. If the book does not exist in the local database, it is fetched from OpenLibrary and created automatically. The book’saverageRating and totalReviews fields are recalculated after every submission.
Path parameters
Numeric book ID. Returns
400 if missing or NaN.Request body
ID of the user submitting the review.
Must match the
:id path parameter. Set automatically by the server from the path.Star rating between
1 and 5 (inclusive).Review text.
Response
ID of the reviewer.
Book ID the review belongs to.
Submitted star rating (1–5).
Review text.
Sentiment label:
positive, negative, or neutral. Derived from the comment text.ISO 8601 timestamp of when the review was created.
GET /book/reviews/:id
Returns all reviews for a book, populated from thereviews reference on the book document.
Path parameters
Numeric book ID.
Response
Array ofReview objects (see fields above). Returns an empty array [] if the book has no reviews or does not exist.
GET /book/user-reviews/:userId
Returns all reviews written by a specific user, sorted bycreatedAt descending. The emotion field is computed on retrieval using sentiment analysis.
Path parameters
User ID. Returns
400 if empty.Response
Array ofReview objects with the bookId field populated. Throws 404 if no reviews are found for the user.