Skip to content

Server Overview

unshackle serve starts an HTTP server. The server can give the download engine of the command-line tool as a REST API, and your CDM devices to other machines. The server modes select which of the two it gives.

This page is for the operator of the server. The other pages of this section tell you how to set the API keys, how to watch the server from the dashboard, and how a dl --remote client connects to it.

Pages for client developers

To write a client for the REST API, start with the REST API Quick Start. Where to go next lists the other client pages. To download a title, you do not need the server: the command-line tool is simpler.

What the API is for

The server exposes the same capabilities as the dl command, but as discrete HTTP calls you can script against:

  • Discovery: show the services available on the server, use a service's search, and enumerate the titles and tracks behind a title ID.
  • Downloading: submit a download as a background job, then follow its status and live progress (by polling, or by subscribing to its Server-Sent Events stream), cancel it, retry it, or bump it to the front of the queue.
  • History and housekeeping: read the log of finished jobs, inspect the server's effective (redacted) configuration, examine external tool versions, and clear caches or temp files.
  • Remote sessions: a thin local client can authenticate against a service on the server, then pull titles, tracks, and segment info back, and relay DRM licensing. This is how one machine with the credentials and CDMs can serve downloads to another. See the remote session protocol.

Because every download runs as a queued job in a separate job worker process, the API is well suited to running unattended: submit work, come back later, and read the result.

Running the server

Start the server with the serve command:

Start the REST API on the default host and port
unshackle serve

By default the server binds to 127.0.0.1:8786 and requires an API key on every request. It also serves the local Widevine and PlayReady CDM endpoints (for pywidevine / pyplayready clients) in addition to the REST API.

An API key is required by default

Unless you pass --no-key, the server needs an API secret configured under the serve section of your config. If none is set, unshackle serve refuses to start. See Authentication for how to set api_secret and how the X-Secret-Key header works.

Common options

The serve options in the CLI reference give each flag, its default and the flags that you cannot use together.

Serve the REST API only, on all interfaces
unshackle serve --api-only --host 0.0.0.0 --port 8786

Binding to a public interface

--no-key disables authentication completely. Anyone who can reach the port can find titles, download them, and read your configuration. Only combine it with a host like 127.0.0.1, or keep the default key-based auth when binding to 0.0.0.0. Put a TLS-terminating reverse proxy (Caddy, nginx) in front for anything internet-facing.

Server modes

The routes the server mounts depend on how you start the server:

The server mounts both the pywidevine/pyplayready CDM endpoints and the full REST API. This is the mode you get when you operate unshackle serve with no mode flags.

The server mounts only the REST API. It does not mount the CDM HTTP endpoints. Authentication uses the single configured API key (or none, with --no-key).

The server mounts only the remote session routes. This mode implies --api-only, and the interactive Swagger UI is not mounted.

The server mounts only the pywidevine and pyplayready CDM endpoints. Under /api/ it answers /api/health and, when serve.dashboard.key is set, the dashboard. It does not start the remote session store, the service refresh loop or the Swagger UI. Use it for a CDM backend that a proxy reaches on its own hostname.

Base URL

All REST endpoints live under the /api prefix. With the default bind address the base URL is:

http://127.0.0.1:8786/api

Every path in this documentation is relative to the host and port. For example, the health check is GET http://127.0.0.1:8786/api/health.

Interactive API docs

Unless you started the server with --remote-only, an interactive Swagger UI is available at /api/docs/. The server generates it from the same route table it serves, so it always matches the version you operate. Note that in --api-only mode the docs page is itself behind the API key, like every other route.

A quick smoke test:

Confirm the server is up
curl -H "X-Secret-Key: your-api-secret" http://127.0.0.1:8786/api/health
Response
{
  "status": "ok",
  "version": "5.3.0",
  "update_check": {
    "update_available": false,
    "current_version": "5.3.0",
    "latest_version": "5.3.0"
  }
}

Endpoint map

Every REST path uses JSON request and response bodies and lives under /api. The table below is a map of the surface. The Endpoints page gives each request and response in full.

Discovery

Method Path Purpose
GET /api/health Liveness and version check.
GET /api/services List the services available on this server.
POST /api/search Run a service's search for a query.
POST /api/list-titles List the titles behind a service title ID.
POST /api/list-tracks List the video, audio, and subtitle tracks for a title.

Downloads and jobs

Method Path Purpose
POST /api/download Queue a download; returns a job_id.
GET /api/download/jobs List jobs, with filtering and sorting.
POST /api/download/jobs/clear-finished Remove all finished jobs.
GET /api/download/jobs/{job_id} Full detail for one job.
GET /api/download/jobs/{job_id}/events Stream one job's progress as Server-Sent Events.
DELETE /api/download/jobs/{job_id} Cancel a running job, or remove a finished one.
POST /api/download/jobs/{job_id}/retry Re-queue a finished job's parameters as a new job.
POST /api/download/jobs/{job_id}/priority Move a queued job to the front.
POST /api/download/jobs/{job_id}/input Answer the prompt that a running job waits on.

History and server info

Method Path Purpose
GET /api/history Read the persisted log of finished jobs.
DELETE /api/history/{job_id} Delete a history entry.
GET /api/profiles Named credential profiles per service.
GET /api/config The server's effective, redacted configuration.
GET /api/env/check Presence and versions of external tools.

Maintenance

Method Path Purpose
POST /api/maintenance/clear-cache Clear the cache directory.
POST /api/maintenance/clear-temp Clear the temp directory.
POST /api/maintenance/refresh-services git pull each configured service repository and re-import the services that changed.

Remote sessions

The /api/session/*, /api/tunnel and /api/tunnel/check routes carry the remote sessions of dl --remote. The remote session protocol lists each route.

Method Path Purpose
GET /api/remote/logins The logins of a relayed list call that wait on you.
POST /api/remote/logins/{login_id}/input Answer the prompt of such a login.

Remote-only routes

A server that runs with --remote-only exposes only the remote session routes and the dashboard routes. Everything else (downloads, jobs, history, config, maintenance) is only available in the full or --api-only modes.

Authentication in one line

With the default configuration, send your API secret in the X-Secret-Key header on every request:

An authenticated request
curl -X POST http://127.0.0.1:8786/api/search \
  -H "X-Secret-Key: your-api-secret" \
  -H "Content-Type: application/json" \
  -d '{"service": "EXAMPLE", "query": "example"}'

A missing or unknown API key returns 401. Authentication gives the full model, including per-key service allowlists.

Where to go next

  • REST API Quick Start: start the server, set an API key, and operate your first end-to-end download over the API.
  • Authentication: the X-Secret-Key header, --no-key, per-key service allowlists, and CORS.
  • Endpoints: every request body, query parameter, and response shape, endpoint by endpoint.
  • Job Lifecycle: how a download moves from queued to a terminal state, live progress, cancellation, and retries.
  • Remote Session Protocol: the routes, login states, licensing modes and message shapes of a remote session.
  • Error Responses: the standard error envelope, error codes, and their HTTP statuses.