{ client } as the operation options. The default response is a result object with data, error, request, and response fields.
Create a client
createKomgaClient also supports API-key authentication, no authentication, custom headers, cookie credentials, and a custom Fetch implementation. See Fetch configuration.
Understand the call shape
The first argument contains only endpoint inputs. The generator maps each known field to the correct path, query, or JSON body location:{ path, query, body } shape. The generated function signature and generated types are the source of truth for parameter names, required fields, and permissions.
Get a book
getBookById takes a flat bookId parameter. The generated client maps it to the path segment:
List books with search and pagination
getBooks combines its flat query parameters with the generated bookSearch body parameter:
BookSearch type currently exposes fullTextSearch and an optional condition. It does not use the former service-layer search object; use the generated type rather than guessing filter properties.
List collections, read lists, and related resources
These list operations use flat query parameters.library_id is the generated parameter name:
error on each result before reading page content. The generated page envelope has optional fields because the OpenAPI contract permits partial responses.
Mutations and permissions
Mutation bodies are named generated DTO properties. A successful mutation often returns204 No Content, so the data branch is undefined:
ADMIN or FILE_DOWNLOAD. A 403 means the authenticated user lacks permission; changing the body or retrying unchanged credentials will not grant access.
Binary and text responses
Use generated Fetch parser options for endpoints that return media rather than JSON:blob in a browser, arrayBuffer in a Node pipeline). Do not force JSON parsing on a file or page endpoint.
Use throwing results when needed
Generated calls remain non-throwing by default.unwrap is the explicit boundary that returns data or throws KomgaApiError:
undefined through unwrap, matching their generated type. An absent result is rejected as a malformed invocation; network and HTTP failures become KomgaApiError only at the unwrap boundary.
Per-call generated options
The second argument can override generated Fetch behavior for one operation:throwOnError only when you explicitly want generated-client throwing behavior; unwrap gives a typed KomgaApiError and is usually easier to standardize. Do not log the second argument when it may contain credentials.
No implicit validation
The generated TypeScript types describe the API at compile time. The core package does not parse responses with Zod or another runtime schema library. Add an application-owned validator only when your application needs one; see Runtime validation.Next steps
- Handle result branches and typed throwing: Result handling
- List and iterate page responses: Pagination
- Customize the underlying Fetch lifecycle: Request customization