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
- npm
- pnpm
- yarn
- bun
moduleResolution: "bundler"; TypeScript reference includes a minimal configuration.
Configure environment variables
Keep the server URL and credentials out of source control:.env
Create a client
createKomgaClient requires a baseUrl. Authentication is optional:
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
{ 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:Use unwrap when you want exceptions
unwrap is the explicit throwing boundary. It returns generated data or throws KomgaApiError:
Run the example
- tsx
- Bun
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.