Skip to main content
Install komga-sdk and make a request against a Komga server.

Prerequisites

A Komga server that is reachable from your application. The default local server URL is http://localhost:25600.
Node.js 18 or newer, a modern browser, or another runtime with Fetch, Web Crypto, Headers, Request, and Response APIs.
A Komga username and password or an API key, unless your application supplies its own session headers.

Install

The package is ESM. In a TypeScript project, use a current ESM-capable runtime or compile with moduleResolution: "bundler"; TypeScript reference includes a minimal configuration.

Configure environment variables

Keep the server URL and credentials out of source control:
.env
Load these values through your runtime’s environment mechanism. Do not expose a long-lived API key or Basic password in a browser bundle; create a server-side boundary when the browser must access a private Komga server.

Create a client

createKomgaClient requires a baseUrl. Authentication is optional:
For a production integration, prefer https:// whenever credentials leave the local machine. The client uses native Fetch and does not configure retries, timeouts, caching, or response validation. Add those concerns in your application or through a custom Fetch implementation when you need them.

Make your first request

Generated operation parameters are flat. The client is passed in the optional second argument:
index.ts
A generated request resolves to { data, error, request, response } by default. It does not throw for an HTTP error. Check error before reading data; response can be absent for a network or request-construction failure.

Query a paginated endpoint

getBooks requires a bookSearch object and accepts pagination values in the same flat parameter object:

Browser session example

A browser application that already has a Komga session cookie can ask Fetch to include it:
The SDK does not implement a login page or token exchange. For cross-origin requests, Komga and the browser must agree on an allowed origin and credentialed CORS policy.

Use unwrap when you want exceptions

unwrap is the explicit throwing boundary. It returns generated data or throws KomgaApiError:

Run the example

Replace http://localhost:25600 with the URL of your Komga server. Keep credentials in environment variables or a secrets manager rather than source code.

What’s next?

Authentication

Configure Basic Auth, API keys, custom headers, sessions, and browser credentials.

Quick reference

Review flat operation signatures, result handling, and pagination.

Best practices

Decide where to add application-owned retries, caching, and validation.