mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-05 07:25:08 +00:00
docs: give each dl and serve flag and the error envelope one owner page and tighten the cli-reference test
This commit is contained in:
@@ -72,18 +72,7 @@ unshackle serve --api-only
|
||||
|
||||
By default the server binds to `127.0.0.1:8786`. The `--api-only` flag serves only the REST API and omits the Widevine/PlayReady CDM HTTP endpoints. Drop it when you also want those endpoints.
|
||||
|
||||
Common options:
|
||||
|
||||
| Option | Default | Effect |
|
||||
| --- | --- | --- |
|
||||
| `-h, --host` | `127.0.0.1` | Address to bind to |
|
||||
| `-p, --port` | `8786` | Port to bind to |
|
||||
| `--api-only` | off | Serve only the REST API, no CDM endpoints |
|
||||
| `--no-key` | off | Disable API-key authentication (allow all requests) |
|
||||
| `--debug-api` | off | Include tracebacks and stderr in error responses |
|
||||
| `--debug` | off | Enable DEBUG-level logging |
|
||||
| `--remote-only` | off | Expose only the remote session routes: `/api/health`, `/api/services`, `/api/search`, `/api/session/*`, `/api/tunnel` and `/api/tunnel/check`, and the dashboard routes when `serve.dashboard.key` is set |
|
||||
| `--caddy` | off | Also launch Caddy as a reverse proxy (for HTTPS) |
|
||||
The [`serve` options](../../guide/cli-reference.md#serve) in the CLI reference give every flag.
|
||||
|
||||
Once it is up you will see the API mounted under `/api/` and, unless you started in remote-only mode, an interactive Swagger UI:
|
||||
|
||||
@@ -166,7 +155,7 @@ If the API key is missing or wrong, you get a `401` with a plain body:
|
||||
```
|
||||
|
||||
!!! warning "Two error shapes exist"
|
||||
The authentication middleware returns the short `{"status": 401, "message": "..."}` shape shown above. Every **other** error the API produces uses the richer structured shape (`error_code`, `timestamp`, `details`, ...) described in [Error handling](#error-handling). Parse both shapes in your client.
|
||||
The authentication middleware answers with the short shape above, and every other JSON error has the [standard error shape](errors.md#the-standard-error-shape). Parse both shapes in your client.
|
||||
|
||||
The `tag` value for the service you want is the identifier you pass as `service` in the calls below.
|
||||
|
||||
@@ -400,38 +389,7 @@ The interactive **Swagger UI at `/api/docs/`** documents every route and lets yo
|
||||
|
||||
## Error handling
|
||||
|
||||
Apart from the auth middleware's short form, every error the API returns uses a single structured envelope:
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "error",
|
||||
"error_code": "INVALID_PARAMETERS",
|
||||
"message": "Human-readable description",
|
||||
"timestamp": "2026-07-03T12:00:00Z",
|
||||
"details": { }
|
||||
}
|
||||
```
|
||||
|
||||
`details` appears only when the server has more to add. `retryable: true` appears only for transient failures. The server includes a `debug_info` block (exception type and traceback) only when it runs with `--debug-api`.
|
||||
|
||||
The `error_code` maps to an HTTP status. The ones you will meet most often:
|
||||
|
||||
| Error code | HTTP | Typical cause |
|
||||
| --- | --- | --- |
|
||||
| `INVALID_INPUT` | 400 | Malformed JSON body or missing required field |
|
||||
| `INVALID_SERVICE` | 400 | Unknown or disallowed service tag |
|
||||
| `INVALID_PARAMETERS` | 400 | A download field failed validation |
|
||||
| `AUTH_FAILED` | 401 | Service login/credential failure |
|
||||
| `FORBIDDEN` | 403 | A gated field was used without server opt-in |
|
||||
| `NOT_FOUND` | 404 | Title or resource does not exist |
|
||||
| `JOB_NOT_FOUND` | 404 | No job with that `job_id` |
|
||||
| `CONFLICT` | 409 | Illegal state transition (e.g. retry a running job) |
|
||||
| `SERVICE_ERROR` | 422 | The service raised an error |
|
||||
| `RATE_LIMITED` | 429 | Upstream throttling (retryable) |
|
||||
| `INTERNAL_ERROR` | 422 | Unexpected server-side failure |
|
||||
| `NETWORK_ERROR` | 424 | Connection/timeout reaching the service (retryable) |
|
||||
|
||||
The [error code catalogue](errors.md#error-code-catalogue) lists every code.
|
||||
|
||||
!!! tip "Retry politely"
|
||||
Codes marked retryable (`NETWORK_ERROR`, `RATE_LIMITED`, `SERVICE_UNAVAILABLE`) reflect transient conditions. Back off and retry rather than hammering the server.
|
||||
Every JSON error has one of two shapes: the [standard error shape](errors.md#the-standard-error-shape),
|
||||
or the [authentication error](errors.md#the-authentication-error-exception) of the API-key
|
||||
middleware. The [error code catalogue](errors.md#error-code-catalogue) gives the HTTP status of
|
||||
each code, and [the `retryable` hint](errors.md#the-retryable-hint) marks the errors to retry.
|
||||
|
||||
Reference in New Issue
Block a user