PageBookDto, PageCollectionDto, and PageReadListDto. Pagination state belongs in your application; the SDK does not keep a cursor or automatically fetch another page.
Page response fields
PageBookDto is generated as an object whose fields are optional because the OpenAPI response permits partial data:
?? when rendering or iterating so a missing field does not become an unchecked runtime access. getLibraries is not paginated: it returns LibraryDto[] directly.
Fetch a page of books
getBooks accepts page, size, sort, and unpaged alongside its generated bookSearch body parameter. Page indexes are zero-based:
page to 0 when the user changes a filter:
Sorting
Pass server sort expressions in the generatedsort array. The common Komga form is field,direction:
Search parameters
BookSearch is the generated body type for getBooks:
tags, readStatus, or libraryId unless the generated BookSearch type for your SDK version includes them. TypeScript will identify fields that are not in the generated contract.
Collections and read lists use query strings instead of BookSearch:
library_id is intentional. Arrays are serialized by the generated client according to the OpenAPI contract; pass an array rather than joining ids into a comma-delimited string yourself.
Unpaged requests
List operations exposeunpaged when the endpoint supports it:
Iterate through pages
This async generator stops on the generatedlast field and preserves the default non-throwing result contract:
last as a stop condition avoids an accidental unbounded loop. If you prefer typed API exceptions, replace the error branch with unwrap(await getBooks(...)) and catch KomgaApiError at the application boundary.
Parallel fetching and batch work
Parallel page fetching can reduce latency but increases load and can produce inconsistent snapshots while the library changes. First fetch page0, read totalPages, then bound concurrency and keep filters and sort fixed:
Next steps
Direct API functions
Learn the flat operation call shape.
Result handling
Handle generated errors or use unwrap.
Runtime validation
Add validation only when your application needs it.