2026-03-22 21:00:37 +08:00
# REST API
2026-03-27 12:43:16 +08:00
The API server runs on port 1349 by default and serves all endpoints under `/api` .
2026-03-27 17:36:58 +08:00
::: tip Full API Reference
2026-04-06 11:33:29 +08:00
Your Stirling Image instance includes a complete interactive API reference at `/api/docs` (e.g. `http://your-host:1349/api/docs` ) with all 67 endpoints, request/response schemas, and examples.
2026-03-27 12:43:16 +08:00
:::
2026-03-27 17:32:07 +08:00
::: info LLM-friendly docs
2026-04-06 11:27:17 +08:00
Need to feed these docs to an AI assistant? Use [`/llms.txt` ](/llms.txt ) for an index or [`/llms-full.txt` ](/llms-full.txt ) for the complete documentation in a single file. On a running instance, these are also available at `/llms.txt` and `/llms-full.txt` .
2026-03-27 17:32:07 +08:00
:::
2026-03-27 17:36:58 +08:00
This page covers the basics of using the API. For per-endpoint details (every parameter, schema, and response), see the interactive docs at `/api/docs` .
2026-03-22 21:00:37 +08:00
## Authentication
2026-03-27 17:36:58 +08:00
Two methods:
2026-03-22 21:00:37 +08:00
2026-03-27 17:36:58 +08:00
1. **Session token** -- `POST /api/auth/login` with `{ "username", "password" }` . Returns a `token` . Pass as `Authorization: Bearer <token>` .
2. **API key** -- Generate via Settings UI or `POST /api/v1/api-keys` . Prefixed with `si_` . Pass as `Authorization: Bearer si_...` .
2026-03-22 21:00:37 +08:00
2026-03-27 17:36:58 +08:00
Public endpoints (no auth required): health check, login, API docs, downloads, job progress.
2026-03-22 21:00:37 +08:00
2026-03-27 17:36:58 +08:00
## Using a tool
2026-03-22 21:00:37 +08:00
2026-03-27 17:36:58 +08:00
Every tool follows the same pattern:
2026-03-22 21:00:37 +08:00
```
POST /api/v1/tools/:toolId
Content-Type: multipart/form-data
```
Send a multipart request with:
2026-03-27 17:36:58 +08:00
- `file` -- the image
2026-03-22 21:00:37 +08:00
- `settings` -- JSON string with tool-specific options
```json
{
"jobId" : "abc123" ,
"downloadUrl" : "/api/v1/download/abc123/output.png" ,
"originalSize" : 245000 ,
"processedSize" : 180000
}
```
2026-03-27 17:36:58 +08:00
### Tool IDs
2026-03-22 21:00:37 +08:00
2026-03-27 17:36:58 +08:00
| Category | Tools |
|----------|-------|
| **Essentials** | `resize` , `crop` , `rotate` , `convert` , `compress` |
| **Optimization** | `strip-metadata` , `bulk-rename` , `image-to-pdf` , `favicon` |
| **Adjustments** | `brightness-contrast` , `saturation` , `color-channels` , `color-effects` , `replace-color` |
| **AI** | `remove-background` , `upscale` , `erase-object` , `ocr` , `blur-faces` , `smart-crop` |
| **Watermark** | `watermark-text` , `watermark-image` , `text-overlay` , `compose` |
| **Utilities** | `info` , `compare` , `find-duplicates` , `color-palette` , `qr-generate` , `barcode-read` |
| **Layout** | `collage` , `split` , `border` |
| **Format** | `svg-to-raster` , `vectorize` , `gif-tools` |
2026-03-22 21:00:37 +08:00
2026-04-06 11:33:29 +08:00
Each tool's specific settings are documented in the interactive API reference at `/api/docs` on your running instance.
2026-03-22 21:00:37 +08:00
2026-03-27 17:36:58 +08:00
## Batch processing
2026-03-22 21:00:37 +08:00
```
POST /api/v1/tools/:toolId/batch
```
2026-03-27 17:36:58 +08:00
Send multiple files with the same settings. Returns a ZIP. Use the `X-Job-Id` header to track progress.
2026-03-22 21:00:37 +08:00
## Pipelines
2026-03-27 17:36:58 +08:00
Chain tools into reusable workflows.
2026-03-22 21:00:37 +08:00
```
2026-03-27 17:36:58 +08:00
POST /api/v1/pipeline/execute -- Run a pipeline (multipart: file + steps JSON)
POST /api/v1/pipeline/save -- Save a named pipeline
GET /api/v1/pipeline/list -- List saved pipelines
DELETE /api/v1/pipeline/:id -- Delete a pipeline
2026-03-22 21:00:37 +08:00
```
2026-03-27 17:36:58 +08:00
Example steps:
2026-03-22 21:00:37 +08:00
```json
2026-03-27 17:36:58 +08:00
[
{ "toolId" : "resize" , "settings" : { "width" : 200 , "height" : 200 , "fit" : "cover" } },
{ "toolId" : "compress" , "settings" : { "quality" : 80 } },
{ "toolId" : "convert" , "settings" : { "format" : "webp" } }
]
2026-03-22 21:00:37 +08:00
```
2026-03-27 17:36:58 +08:00
## Progress tracking (SSE)
2026-03-22 21:00:37 +08:00
2026-03-27 17:36:58 +08:00
For long-running jobs (AI tools, batch processing):
2026-03-22 21:00:37 +08:00
```
GET /api/v1/jobs/:jobId/progress
```
2026-03-27 17:36:58 +08:00
Returns a Server-Sent Events stream with `{ status, progress, completedFiles, failedFiles }` .
2026-03-22 21:00:37 +08:00
## Error responses
```json
2026-03-27 17:36:58 +08:00
{ "statusCode" : 400 , "error" : "Bad Request" , "message" : "Invalid image format" }
2026-03-22 21:00:37 +08:00
```
2026-03-27 17:36:58 +08:00
Status codes: `400` invalid input, `401` not authenticated, `403` not authorized, `413` file too large, `429` rate limited, `500` server error.