Why use domain services?
Automatic Validation
All responses are validated against Zod schemas. Invalid data throws immediately.
Type Safety
Full TypeScript support with proper return types. No manual casting.
Simplified API
Intuitive method names and parameters. Less boilerplate code.
Error Handling
Consistent error types across all operations. Easy to catch and handle.
Available services
| Service | Domain | Key Operations |
|---|---|---|
BookService | Individual books | List, get, update metadata, pages, thumbnails |
SeriesService | Series (grouped books) | List, get, update metadata, get books |
LibraryService | Libraries (file locations) | List, get, create, update, scan, delete |
For Collections and Read Lists, use Direct API functions as they’re not yet wrapped in domain services. See the Collections and Read Lists guides.
BookService
Manage individual books in your library.Methods
list(options)
list(options)
List books with pagination and search.Parameters:
search- Search filters (fullTextSearch, tags, etc.)page- Page index (0-based)size- Items per pagesort- Sort fields and directionsunpaged- Return all results (use carefully)
getById(bookId)
getById(bookId)
Get a single book by ID.
updateMetadata(bookId, updates)
updateMetadata(bookId, updates)
Update book metadata.
getPages(bookId)
getPages(bookId)
Get all pages in a book.
getThumbnailUrl(bookId)
getThumbnailUrl(bookId)
Get the thumbnail URL for a book.
deleteReadProgress(bookId)
deleteReadProgress(bookId)
Clear read progress for a book.
SeriesService
Manage series (collections of books).Methods
list(options)
list(options)
List series with pagination and search.
getById(seriesId)
getById(seriesId)
Get a single series by ID.
updateMetadata(seriesId, updates)
updateMetadata(seriesId, updates)
Update series metadata.
getBooks(seriesId, options)
getBooks(seriesId, options)
Get books in a series.
getCollections(seriesId)
getCollections(seriesId)
Get collections containing this series.
LibraryService
Manage libraries (root folders where Komga scans for content).Methods
getAll()
getAll()
Get all libraries.
getById(libraryId)
getById(libraryId)
Get a single library by ID.
create(payload)
create(payload)
update(libraryId, updates)
update(libraryId, updates)
Update library settings.
scan(libraryId)
scan(libraryId)
Trigger a library scan.
delete(libraryId)
delete(libraryId)
Delete a library.
Domain services vs direct API
- When to use services
- When to use direct API
Use domain services when:
- Building application features
- You want automatic validation
- You prefer a cleaner API
- The endpoint is supported by a service
Comparison table
| Aspect | Domain Services | Direct API |
|---|---|---|
| Validation | Automatic | Manual |
| Return type | BookDto | { data?, error? } |
| Error handling | Throws | Returns error object |
| Coverage | ~60% of API | 100% of API |
| Boilerplate | Minimal | More verbose |
Next steps
Books Guide
Deep dive into book operations.
Direct API
Use low-level API functions.
Validation
Understand response validation.