Skip to main content
The 1.0 SDK exports generated operation functions for the complete Komga API surface. Pass endpoint parameters as a flat object, then pass { 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:
Do not use the removed grouped { 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:
The generated 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. These list operations use flat query parameters. library_id is the generated parameter name:
Check 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 returns 204 No Content, so the data branch is undefined:
Generated operation comments identify required roles such as 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:
For downloads, use the operation’s generated response type and an appropriate parser (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:
Successful void operations return 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:
Use 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