Reference

REST API

Rust-Srec exposes a JSON REST API under /api. The running backend generates the authoritative OpenAPI document for its exact build.

The Swagger link belongs to the running Rust-Srec backend, not to docs.srec.rs.

Authentication

Most routes require an access token in the Authorization: Bearer <token> header. Login returns a short-lived access token and a longer-lived, rotating refresh token.

First Login

The initial account is admin / admin123! and must change its password before it can use other protected endpoints.

The desktop app's built-in backend refuses this password; create a key under API Keys in the desktop app instead (see API Keys & MCP).

bash
curl -X POST http://localhost:12555/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"admin123!","device_info":"API quickstart"}'

The response contains these fields:

json
{
  "access_token": "...",
  "refresh_token": "...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_expires_in": 604800,
  "roles": ["admin"],
  "must_change_password": true
}

Use the returned access token to replace the default password:

bash
curl -X POST http://localhost:12555/api/auth/change-password \
  -H "Authorization: Bearer <access-token>" \
  -H "Content-Type: application/json" \
  -d '{"current_password":"admin123!","new_password":"<unique-new-password>"}'

Sign in again with the new password and use the new access token. While must_change_password is true, other protected routes return 403 PASSWORD_CHANGE_REQUIRED.

Call a Protected Endpoint

bash
curl http://localhost:12555/api/streamers \
  -H "Authorization: Bearer <access-token>"

Refresh and Revoke

POST /api/auth/refresh accepts {"refresh_token":"..."} and rotates the token pair within the same login session. Store the replacement refresh token and serialize refresh requests, including requests from other tabs. Replaying a consumed token normally revokes all of the user's sessions; see reuse policy.

POST /api/auth/logout accepts the same body and revokes only that session's access and refresh tokens. You may also send the current session JWT in the Authorization header: if the refresh row has already been cleaned up, this lets the server revoke the JWT's own session. A supplied header must be valid; an API key cannot act as this optional session credential. Authenticated POST /api/auth/logout-all revokes every session for the user. Password changes revoke existing sessions atomically and require a new login; successful configuration imports also revoke login sessions and refresh tokens.

Access tokens that are not bound to a login session are rejected; use a valid refresh token to obtain a bound token pair, or sign in again. GET /api/auth/sessions lists active refresh-token records: IDs may change on rotation, and sessions whose refresh token has expired or been cleaned up may be absent even while their access token is valid.

Media, stream proxy, direct-download file and WebSocket (/api/direct-downloads/{id}/files/{index}, /api/direct-downloads/ws), and download, log, and live-danmu (/api/parse/danmu/ws) WebSocket routes use the Authorization: Bearer header first and accept ?token= only when it is absent; a malformed or invalid header never falls back to the query token. Read-only API keys may read health details and recorded media; direct downloads, download/log//api/direct-downloads/ws//api/parse/danmu/ws WebSockets (all of which revalidate credentials every five seconds), stream proxy, and logging configuration/archive routes require full access. See API Keys & MCP.

Treat access tokens, refresh tokens, cookies, and platform credentials as secrets. Do not place tokens in logs or source control.

Route Groups

PrefixPurposeAuthentication
/api/healthLiveness, readiness, idle state, and dependency statusMixed; /live and /idle are public
/api/authLogin, refresh, logout, password change, sessionsMixed; see Swagger
/api/streamersStreamer CRUD, checks, filters, and batch actionsBearer token
/api/configGlobal/platform configuration and backup import/exportBearer token
/api/templatesReusable configuration templatesBearer token
/api/enginesDownload engine instancesBearer token
/api/sessionsRecording sessionsBearer token
/api/pipelineWorkflows, jobs, pipeline presets, executions, and outputsBearer token
/api/jobJob presetsBearer token
/api/notificationsChannels, subscriptions, preferences, and eventsBearer token
/api/credentialsAccount profiles, selection status, validation, refresh and QR loginBearer token
/api/proxiesSaved proxies, reachability tests and effective proxy settingsBearer token; API keys need full access
/api/parseURL and metadata parsing (including direct FLV/M3U8 streams)Bearer token
/api/direct-downloadsOne-shot FLV and HLS (M3U8) probing, downloads, file serving, and live progress WebSocketBearer token; API keys need full access
/api/tools/baidupcsBaiduPCS-Go account status, login and logoutBearer token
/api/tools/aliyunpanAliyunpan account status, two-step OAuth login, drive switch and logoutBearer token
/api/mcpMCP server (Streamable HTTP)Bearer token; see API Keys & MCP
/api/downloads, /api/logging, /api/media, /api/stream-proxyRealtime or media accessRoute-specific; inspect Swagger

Use the generated OpenAPI document for request and response schemas instead of guessing fields from this summary.

Platform, template and streamer writes choose accounts with a credential_selection object naming profiles from /api/credentials. The former cookies field of platform and template configuration is rejected with 422 COOKIES_REPLACED.

Proxies

/api/proxies manages the saved proxies that proxy settings name. API keys need full access for every request, reads included. Responses show a proxy's username and whether a password is saved (has_password), never the password.

RequestPurpose
GET /api/proxiesList saved proxies with usage_count, the number of settings choosing each
GET /api/proxies/{id}One proxy and its references: global, platforms, templates, streamers, accounts, notification_channels, job_presets, and pipelines that choose it
POST /api/proxiesCreate from name, url (http, https, socks5 or socks5h, as scheme://host[:port]) and an optional username with password
PATCH /api/proxies/{id}Edit with expected_version. An omitted password keeps the saved one; "username": null removes the login.
DELETE /api/proxies/{id}Delete, with an optional expected_version query parameter
POST /api/proxies/testRequest a platform's home page or a target_url once through a saved proxy (proxy_id, optionally with edited fields) or an unsaved url. Returns ok, status, latency_ms and an error kind; the limit is 10 seconds.
GET /api/proxies/systemThe environment proxy detected when the server started, without its login
GET /api/proxies/effectiveHow a scope connects now and which setting decided it: scope_type (global, platform, template, streamer or account), scope_id, and for a template an optional platform_id

Conflicts return 409 with PROXY_NAME_TAKEN, PROXY_DUPLICATE (another proxy has the same address and username), PROXY_STALE_VERSION, or PROXY_REFERENCED when deleting a proxy still in use, with details.references listing its users. An invalid address or login returns 422 PROXY_INVALID.

Global, platform, template, streamer, account, notification-channel (except email), and upload-step (rclone, rship, baidupcs, aliyunpan) writes choose a proxy with a proxy_route object. The former proxy_config field is rejected with 422 PROXY_CONFIG_REPLACED.

Direct Downloads

/api/direct-downloads manages one-shot FLV and HLS (M3U8) downloads. Every route—reads, WebSocket, and file serving included—requires full access when using an API key. Responses expose configured header names (header_names, has_custom_headers) and never return stored custom header values.

RequestPurpose
POST /api/direct-downloadsStart a single direct download (returns 201 Created); supports url, optional name, format (auto, flv, hls), headers, proxy_route, engine_id (Mesio or FFmpeg), output overrides, segment limits, and pipeline_preset_id
POST /api/direct-downloads/batchStart up to 50 direct downloads in one request and receive per-item outcomes
POST /api/direct-downloads/probeProbe a stream URL for format (flv / hls), live vs. VOD status, content metadata, suggested name, and master HLS variants
GET /api/direct-downloadsPaginated list filtered by status and literal substring search
GET /api/direct-downloads/statsAggregate counts by status and active combined throughput
GET /api/direct-downloads/{id}Single download with live progress metrics overlaid while active
POST /api/direct-downloads/{id}/cancelCleanly stop an active download and finalise written output
POST /api/direct-downloads/{id}/retryRetry a FAILED or CANCELLED download with optional replacement url, format, headers, proxy_route, or engine_id (omitted headers reuses stored headers; {} clears them)
DELETE /api/direct-downloads/{id}Remove a non-active download record; pass ?delete_files=true to also delete its saved output files from disk
GET /api/direct-downloads/{id}/files/{index}Stream a completed output file with Range support; pass ?download=1 for Content-Disposition: attachment
GET /api/direct-downloads/wsJSON WebSocket streaming snapshot, created, updated, progress, and deleted events

POST /api/parse and POST /api/parse/batch also accept optional headers and format (auto, flv, hls) fields for playing direct FLV and M3U8 streams (headers cannot be combined with credential_id).

Creation responses and job progress

Creating streamers, templates, engines, filters, notification channels, saved proxies (POST /api/proxies), job presets, pipeline presets and pipelines returns 201 Created with the created resource's JSON body. Cloning templates and job presets also returns 201 with the new resource. Clients should accept successful 2xx statuses rather than requiring 200 for every JSON response.

Use GET /api/pipeline/jobs/{id}/progress for a job's latest processor-specific progress snapshot; it returns 404 when no snapshot is available. The snapshot's optional phase is finalizing while FFmpeg rewrites its output after the last frame and while an rclone or rship upload that sent every byte waits for the destination to confirm its files, retrying while an upload waits to retry, and preparing for a BaiduPCS, rclone or rship upload while none of the files it is working on has sent data yet, including listing the destination before its first transfer (treat values you do not know as plain work), and current_file names the file in progress without its directories. After an upload's first failed attempt, attempt and max_attempts give its attempt within the current job run, which is unrelated to the job's retry count.

Per-step progress is returned on GET /api/pipeline/dag/{id} (alongside job_status, started_at, and retry_after in epoch milliseconds), not on job list, job detail, or pipeline-creation summaries. retry_after is null when no automatic retry will run, including for cancelled or failed workflows. Each step's progress is its running job's snapshot as returned by GET /api/pipeline/jobs/{id}/progress, except that raw is always null. A step's progress is null unless its job is running and has reported progress, so null does not mean zero percent complete.

progress_percent on GET /api/pipeline/dag/{id}, GET /api/pipeline/dags and GET /api/pipeline/dag/{id}/stats counts each completed step fully and each running step by its reported progress. Failed, cancelled and waiting steps count nothing, so a failed or cancelled workflow shows how much of it completed. GET /api/pipeline/dag/{id}/stats returns 404 for an unknown workflow.

Search filters

The search filters for pipeline jobs, recording sessions, media outputs, notification events, job presets and pipeline presets match literal substrings. %, _ and \ are ordinary characters, not search wildcards or escape syntax. For example, audio_extract does not match audioXextract, and % finds only values containing a percent sign. Send the text as entered, with normal URL encoding for query parameters; no extra search escaping is needed.

ASCII letters match without regard to case. Non-ASCII characters retain SQLite's case-sensitive behavior, so Ä and ä remain distinct. Session-title and notification-payload searches still inspect the stored JSON text, including its keys and JSON escaping. Search combines with the endpoint's other filters, and result counts and media size summaries use the same matching rules as list pages.

Errors

API errors use one stable envelope:

json
{
  "code": "VALIDATION_ERROR",
  "message": "A human-readable explanation",
  "details": {}
}

details is omitted when unavailable. Common statuses are 400 invalid input, 401 missing/expired credentials, 403 disabled account or required password change, 404 missing resource, 409 conflict, 422 validation failure, 429 too many failed login attempts, 500 internal failure, and 503 unavailable dependency.

POST /api/auth/login returns 429 (TOO_MANY_REQUESTS) with a Retry-After header once its per-account or per-source-address failure budget is spent; see Login throttling for budget defaults, window configuration, and proxy attribution. Usernames longer than 128 characters — counted as characters, not bytes, so non-Latin names are not penalised — are rejected with 400 before either budget is consulted; configuration imports apply the same limit.

Deleting a template that streamers still use returns 409 TEMPLATE_IN_USE with details.streamer_count; 0 means only streamers that are still being removed use it. Deleting or renaming a job preset or workflow that a stored pipeline names returns 409 PRESET_IN_USE with details.references, one entry per user with its kind (global, platform, template, streamer or workflow), id, name and whether it is removing.

Clients should branch on HTTP status and code, not parse the human-readable message.

Compatibility and Deployment

POST /api/parse/batch accepts at most 100 URLs; DELETE /api/sessions/batch accepts at most 100 session IDs. Larger arrays receive 422 before any item is processed. Split larger work into separate requests; empty arrays remain valid. Login device descriptions are limited to 256 Unicode characters in logs and newly stored tokens, including descriptions a refreshed token inherits.

Internal database, filesystem, stored-JSON and credential errors use generic responses rather than embedding backend diagnostics. Safe request-validation messages stay descriptive. A credential refresh that needs a new login returns 422 with code PLATFORM_AUTHENTICATION_REQUIRED; a platform rate limit returns 429 with Retry-After; other provider failures return a generic error.

API paths are not prefixed with a version. Pin the backend image or binary version, keep the matching OpenAPI JSON with generated clients, and test before upgrading. Breaking behavior is described in the Release Notes.

For network deployments, terminate TLS at a reverse proxy, restrict the API to intended clients, and do not expose Swagger publicly unless it is needed. See Security and Production Deployment.