Skip to main content

API Reference

This document describes Questarr’s external software interfaces: the REST API exposed by the Express server, and the real-time events pushed over Socket.io. It complements docs/ARCHITECTURE.md (system actors and data flow) and docs/SECURITY_ASSESSMENT.md (risk assessment). Update policy: re-run documentation generation for the affected route group whenever server/routes.ts changes; manually update the Steam section when server/steam-routes.ts changes.

Overview

  • Base URL: all endpoints are served under /api on the same origin as the app (default http://localhost:5000).
  • Format: JSON request/response bodies throughout, except file uploads (multipart/form-data for SSL certificate upload) and the download bundle endpoint (application/zip response).
  • Authentication: a JWT bearer token obtained from POST /api/auth/login (or POST /api/auth/setup for the first account), sent as Authorization: Bearer <token> on subsequent requests. Verified by authenticateToken/optionalAuthenticateToken in server/auth.ts. The whole /api surface is default-deny: requireAuthenticationForApi (server/routes.ts) is mounted before any route and requires a valid JWT unless the request is in the PUBLIC_API_ROUTES allowlist or is the soft-auth POST /api/auth/logout (see the Authentication section below). The /api/integration subtree additionally accepts a long-lived integration API key (see the Integration API section), and keys with the admin scope can call a fixed allowlist of configuration routes; every other route, including key management, is JWT-only.
  • Rate limiting: generalApiLimiter (600 req/min/IP) applies to all /api routes; authRateLimiter additionally guards login; sensitiveEndpointLimiter additionally guards write-heavy/sensitive endpoints; igdbRateLimiter additionally guards IGDB proxy endpoints. See server/middleware.ts.

Authentication

/api/auth/setup and /api/auth/login are the two security-sensitive endpoints that rely on inline typeof checks plus manual length/if validation instead of an express-validator chain or a Zod schema (see the risk register in docs/SECURITY_ASSESSMENT.md). /api/auth/password uses a proper Zod schema (updatePasswordSchema). Every /api route requires a JWT unless it is listed in PUBLIC_API_ROUTES in server/routes.ts, is the soft-auth POST /api/auth/logout described below, or is one of the API-key exceptions at the end of this section. A route added without updating that list is protected by default, even when its handler does not call authenticateToken itself or a table row does not repeat it. The public routes are:
  • GET /api/auth/status, POST /api/auth/setup, POST /api/auth/setup/test-igdb and POST /api/auth/login: used before a token exists (setup wizard and login page).
  • GET /api/health: liveness probe.
  • GET /api/ready: readiness probe, with no sensitive data.
POST /api/auth/logout is a “soft” route: it accepts a missing or expired token so a user with a stale cookie can still clear it, but a valid token is still read so CSRF protection applies. Everything else, including /api/config, /api/system/filesystem, /api/settings/ssl and every resource group below, requires a JWT. The only exceptions are the /api/integration routes, which also accept an integration API key, and the admin-scope allowlist of configuration routes (see Configuration API for automation).

Games

Collections

User-defined groups of games. A manual collection holds an explicit list of games; a smart collection stores rules and its games are computed from the user’s library on every read. Hidden games and games excluded by the user’s content-filter settings are never included. All routes require JWT and only see the requester’s own collections (404 otherwise).

Downloads

Downloaders

Root Folders / Library Scan

Extra directories scanned (read-only discovery) for games already on disk outside the configured library root (e.g. an older library, a secondary drive). Separate from the library root used by the download-import pipeline — matched games get a libraryPath outside that root. Discovery itself never moves, renames, or deletes files there; the game-delete flow (DELETE /api/games/:id?deleteFiles=true) only touches files under a root folder when that folder’s allowDelete is explicitly turned on (off by default). The UI is Library → Library Import. Adding/enabling a folder or changing an enabled folder’s path starts an asynchronous scan. Enabling post-processing also scans enabled roots. Settings changes during an active scan queue a rescan. ScanProgress includes startedAt, optional finishedAt, status, candidate counts and match/review/error counts; updates also arrive as library-scan-progress. See LIBRARY_IMPORT.md for the operator workflow. POST /api/library/scan/unmatched/ignore skips a Needs Review folder for good. Body: { rootFolderId, folderName } (folderName is not trimmed and must match the scanned folder exactly). Returns { success: true }, 400 for invalid input, 404 when the folder is no longer awaiting review. Later scans skip an ignored folder before listing its files, unless it is already linked to a game. GET /api/library/scan/ignored lists the ignored folders, and DELETE /api/library/scan/ignored/:id restores one (404 when unknown) and queues a rescan of its root folder so it returns to Needs Review. POST /api/library/scan/unmatched/search requires authentication, CSRF for cookie sessions, and the IGDB rate limiter. Body: { rootFolderId, folderName, query } (trimmed strings, limits 200/1000/200 respectively). Returns an array of { igdbId, name, releaseYear } candidates; searching does not import a game. Returns 400 for invalid input, 404 when the folder is no longer awaiting review, or 500 if IGDB search fails. Confirm a candidate using the match endpoint below.

Import Settings

Mounted under /api/imports (JWT). See LIBRARY_IMPORT.md for naming tokens and rendering rules. Example preview request:

RomM Settings

Mounted under /api/settings/romm (JWT). See LIBRARY_IMPORT.md for what each setting does.

Indexers

IGDB

Formatted IGDB game responses normalize release timestamps to UTC calendar dates (YYYY-MM-DD) and derive releaseYear using UTC. The frontend preserves these calendar dates when formatting release dates for display, preventing date and year shifts caused by local timezone offsets.

Settings

Apprise settings

These authenticated endpoints configure the shared Apprise service. Cookie sessions require the usual CSRF header on POST requests. The optional API login is for Apprise API servers with APPRISE_AUTH_REQUIRED=yes. Usernames cannot contain a colon. The password is encrypted at rest; sending the masked placeholder keeps it, an empty string clears it, and omitting the field leaves it unchanged. HTTPS login requests reject plaintext or cross-origin redirects. An HTTP login sends credentials unencrypted and the UI warns about it; use HTTPS unless the connection is on a trusted network.

RSS

Enabled feeds refresh 10 seconds after startup and every hour. Manual full refreshes share a queued/running scheduled refresh; single-feed refreshes after creation run in the same serialized queue. Disabled feeds are skipped by full refreshes. The browser polls items every five minutes.

Notifications

PATCH /api/settings accepts notificationPreferences as a JSON-encoded string. Within gameUpdates, includeShelved and includeCompleted independently control update and pack/add-on notifications for those statuses, for both In-App and Apprise. Missing values mean true for compatibility with older preferences. Availability searches and badges still update when notifications are muted.

Error Telemetry

Backs the consent flow opened from an “error-detected” notification’s link (error-report:<reportId>). Reports are built server-side from recent, PII-scrubbed server.log lines when an unhandled server error is detected (uncaught exception, unhandled rejection, or a 5xx response); see server/error-telemetry.ts. Pending reports are held in memory only (not persisted), scoped to the user they were created for, and expire after 24h. reportId must be a UUID (validated via express-validator). For GET, a report owned by another user is indistinguishable from an unknown/expired one — both return 404 — so a caller can’t probe for the existence of another user’s report. POST folds the same “not available” cases (unknown, expired, or not owned) into the 422 it already uses for delivery failures, since sendPendingReport doesn’t distinguish them from the caller’s perspective. Whether an error triggers a notification at all is controlled by the errorDetected notification preference; whether it’s reported automatically (skipping the consent step above) is controlled by the per-user telemetryEnabled setting (Settings > System > Telemetry, off by default).

xREL

PATCH /api/settings/xrel (xREL API base URL and scene/P2P release preferences) is documented under Settings.

NexusMods

NexusMods API-key configuration (GET/POST /api/settings/nexusmods) is documented under Settings.

Stats

Play time

All routes need a JWT; game routes also check that the game belongs to the caller (404 otherwise). Details in Play time.

Health / Ready / Config

Dashboard Status

HowLongToBeat

Blacklist

Per-game blacklist management (POST/GET/DELETE /api/games/:gameId/blacklist*) is documented under Games.

Activity and System Tasks

Mounted under /api/activity and /api/system (JWT). Activity only sees the requester’s own downloads and games.

Release Scoring

Authenticated endpoints behind the Settings → Discovery & Downloads → Release Scoring card. Each user has one release profile and any number of custom formats; both are created with defaults (and the old preferred release groups converted) the first time they are read. A spec is { field: "title" or "group" or "uploader" or "category" or "protocol" or "indexer", mode: "contains" or "exact" or "regex", value (1–200 chars), negate?, required? }. Specs on the same field are alternatives unless marked required; every field used must be satisfied. Regexes run on RE2 (no lookarounds) and are case-insensitive. Required and ignored terms are case-insensitive words, or a regex written /pattern/. Locked built-in rules (a title that is a sequel of, or not, the wanted game, and an executable or disguised file) always apply and always reject, so enabled: false is ignored for them; the others can be re-weighted or disabled in builtInOverrides. Search results from GET /api/search carry an evaluation (score, score lines, rejections, matched formats and, when xREL is enabled, an xrel verdict of verified, nuked, not_found or unavailable, the last meaning the lookup failed or timed out, so it does not show the release is absent). Rejected releases stay in the manual results so the UI can say why. Manual results also carry a trust verdict, { level: "trusted" or "unverified" or "risky", reasons: [{ code, tone, label, detail? }] }, derived from the rejections, the xREL result and size, the preferred release group and the blacklist rather than from the score. The sortBy auto-download rule also accepts score. When the full query returns nothing on the first page, GET /api/search retries, only when no indexer errored, with up to three of its simpler variants, tried from the least to the most lossy (without a possessive publisher prefix, without edition words, without punctuation, without the subtitle; variants that do not apply to the title are skipped) and answers with the first variant that finds releases in queryUsed; the results are then scored against the game’s title without its possessive prefix and edition words (the subtitle is kept, so a release of another game of the series is not taken for the wanted one). The field is absent when the query itself found them. The optional title parameter lets a later page of such a search (offset > 0, sent with the variant as query) keep scoring against the original title.

Steam

server/steam-routes.ts — 2 routes, mounted directly on the app (no prefix router), both behind the global auth gate plus explicit authenticateToken.

Steam play time

server/steam-playtime-routes.ts — turns the Steam play-time sync on or off and runs it. See Play time. All routes require a JWT; responses are not cached.

Owned Steam library

server/steam-library-routes.ts — preview and import endpoints. These endpoints require the normal authenticated session/token. Cookie mutations require the usual CSRF header. Responses use Cache-Control: no-store.
  • GET /api/steam/library: read the linked account’s public Steam library. Returns { games: [{ steamAppId, title, alreadyTracked }] }; preview does not write to the library. Missing server Steam key or linked ID returns 400; Steam failure/private library returns 502 with an actionable generic error.
  • POST /api/steam/library/import: synchronous compatibility endpoint, body { appIds: [400, 620] }, 1–50 positive integer IDs. Ownership is checked again with Steam before any write. Returns { results: [{ steamAppId, title, outcome }] }, where outcome is added, duplicate, not_found (unmapped or content-filtered), or failed. New games are Owned/source steam; existing game states remain unchanged, with missing Steam App IDs linked on exact IGDB matches. Invalid/stale selections return 400, a concurrent import by the same account returns 409, and an upstream batch failure returns 502. Partial row failures return 200 with per-row outcomes so callers can retry explicitly.
  • POST /api/steam/library/import/jobs: body { appIds: [...] }, 1–20,000 positive integer IDs. Returns 202 { job } after durably queuing the selection. Duplicate IDs are collapsed. The worker rechecks ownership before game writes; invalid/stale ownership is reported as a failed job. A concurrent import start returns 409. A new start replaces the account’s previous terminal job.
  • GET /api/steam/library/import/jobs/current: returns { job: null } or the account’s latest job view. Available even if Steam configuration is removed. View fields: id, state (queued, running, completed, failed), total, processed, added, duplicates, skipped, failed, canRetry, completedAppIds, recentResults (last ten), and optional message. It does not return the saved Steam ID or pending selection. The browser polls every two seconds while active. A completed job may still contain skipped/failed rows.
  • POST /api/steam/library/import/jobs/retry: no body required. Queues failed and unprocessed IDs from the latest job; returns 202 { job }, 400 if nothing remains, or 409 if another import is running. The new job carries the earlier outcomes, so total and the counters continue; successful earlier writes are preserved. Retry revalidates current Steam ownership.
See Steam library import for prerequisites and limits.

Integration API (external clients)

server/routes/integration.ts — 5 routes, mounted at /api/integration, plus the SeerrNG provider routes under /api/integration/seerrng/v1 (server/routes/seerrng.ts, documented in SEERRNG.md). This is the one part of the API that accepts a long-lived integration API key in addition to a JWT, for machine clients that cannot run the interactive login flow — the Playnite extension, scripts, other self-hosted tools. The key is presented as X-Api-Key: <key> or Authorization: Bearer <key> (keys are recognised by their qsr_ prefix, so a Bearer header is unambiguous between a key and a JWT). Each key carries one scope and an optional expiry (see API Keys (management)). A route declares the scopes that may call it with requireScope(...); all satisfies every route, and a JWT session is never restricted by scope. A key outside a route’s scope gets 403 { error, code: "API_KEY_SCOPE_DENIED" }; an expired key gets 401 { error: "API key expired", code: "API_KEY_EXPIRED" }. Requests are limited to 300/min per key (integrationRateLimiter). Authentication is handled by authenticateApiKeyOrToken in server/auth.ts, selected by requireAuthenticationForApi for paths under /integration and for the admin-scope allowlist below. Every other protected route on /api — key management included — stays JWT-only, so a leaked key cannot escalate into minting or revoking other keys. IntegrationGame is a deliberately narrow projection of a library game — id, title, igdbId, steamAppId, status, releaseStatus, releaseDate, coverUrl, platforms, genres, libraryPath, addedAt. Internal fields (userId, notes, search-result bookkeeping) are never exposed. apiVersion (INTEGRATION_API_VERSION) describes the integration contract itself and is bumped only when a change would break an already-released client, so an extension can fail loudly on a mismatch instead of misbehaving mid-sync. Sync matching: an incoming entry is matched against the caller’s library by Steam App ID first, then by normalized title (normalizeTitle from shared/title-utils.ts). Unmatched entries are reported back rather than added — a sync never creates library entries on its own. markInstalledAsOwned promotes a matched game from wanted to owned only when the client reports it installed, and is off by default. Requesting a game: a requested game is added with status wanted, which is what hands it to the existing auto-search pipeline (checkAutoSearch in server/cron.ts) — that is how a request from the couch turns into a download.

Outbound webhooks

server/routes/webhooks.ts — mounted at /api/webhooks, JWT or an admin-scope API key. Events, payload, signature and retry rules are in Webhooks. All responses are Cache-Control: no-store; a user may hold at most 20 webhooks.

API Keys (management)

server/routes/api-keys.ts — 3 routes, mounted at /api/api-keys, JWT only. Keys are stored as a SHA-256 hash plus a short display prefix; the raw key is returned exactly once, in the 201 response that creates it, and is not recoverable afterwards. A user may hold at most 25 keys. last_used_at is written at most once per minute per key.

Error Format

Across handlers, error responses follow one of these consistent shapes:
  • Validation failures (express-validator chains): the shared validateRequest middleware (server/middleware.ts) runs after any sanitize* validator array. On failure it returns HTTP 400 with:
  • Validation failures (Zod schemas): handlers that call someSchema.parse(req.body) catch z.ZodError directly and return HTTP 400 with:
    (message text varies per handler, e.g. “Invalid game data”, “Invalid status data”, “Invalid settings data”)
  • Ad hoc business-logic errors: most handlers return a plain { "error": "<message>" } object directly for 400/401/403/404/409/502 cases (sometimes with an extra field attached, e.g. { error, game } on a duplicate-game 409), without going through shared middleware.
  • Uncaught/rethrown errors (global handler): routes that call next(error) fall through to errorHandler (server/middleware.ts), which returns:
    Status comes from err.status/err.statusCode, defaulting to 500. In production, 5xx messages are sanitized to "Internal Server Error" to avoid leaking internals; 4xx messages pass through as-is. All errors are logged via Pino with method/path context — error level for 5xx, warn otherwise.
  • No-content success: several DELETE endpoints return 204 No Content with an empty body rather than a JSON payload (e.g. DELETE /api/games/:id, DELETE /api/indexers/:id, DELETE /api/downloaders/:id, DELETE /api/rss/feeds/:id, DELETE /api/notifications).

Real-time interface (Socket.io)

Alongside the REST API, the server pushes real-time events over Socket.io (server/socket.ts). See docs/ARCHITECTURE.md §6 for the full actor/data-flow explanation. Summary: Every authenticated socket joins a per-user room, user:<id>, during the handshake. Delivery depends on whether the event has an owner:
  • notification events that carry a userId go only to that user’s sockets (io.to("user:<id>")). Other accounts on the same instance don’t receive them.
  • Ownerless notifications and app-wide events (downloadUpdate, importTaskUpdate, gameUpdated, library-scan-progress, logLine) are broadcast to every authenticated socket (io.emit).
Clients don’t need to join rooms themselves. Connect with the auth cookie (or a bearer token in auth.token) and the server assigns the room:

Configuration API for automation (admin scope)

A key with the admin scope can also call a fixed allowlist of configuration routes, so deployment tooling can set Questarr up without an interactive login. all does not imply admin, and an admin key is refused on the integration routes it was not granted. Any other key gets 403 API_KEY_SCOPE_DENIED here. The integration routes above are the only other place a key is accepted; every other protected route stays JWT-only — /api/api-keys in particular, so a key can never mint or revoke another key. Send the key in X-Api-Key or Authorization: Bearer. Treat an admin key like an administrator login: it can change download clients, indexers, notification delivery, settings and import paths. The allowlist lives in server/admin-api-routes.ts.