Skip to content

Library API

Manage library roots, browse files, edit metadata, and trigger scans.

Library roots

List library roots

http
GET /api/library/roots
Authorization: Bearer <token>

Response:

json
[
  {
    "id": 1,
    "path": "/data/movies",
    "name": "Movies",
    "mediaType": "movie",
    "fileCount": 342,
    "totalSizeBytes": 2748779069440,
    "lastScanAt": "2024-01-01T12:00:00Z"
  }
]

Add library root

http
POST /api/library/roots
Authorization: Bearer <admin-token>
Content-Type: application/json

{
  "path": "/data/tv",
  "name": "TV Shows",
  "mediaType": "tv"
}

Response: The created library root object.

Remove library root

http
DELETE /api/library/roots/:id
Authorization: Bearer <admin-token>

Removes the library root and its metadata from the database. Files on disk are not deleted.

Library files

List files

http
GET /api/library/files
Authorization: Bearer <token>

Query parameters:

ParameterTypeDescription
mediaTypestringFilter by media type: movie, tv, music, book, audiobook, comic, game
rootIdnumberFilter by library root ID
searchstringFull-text search on title and metadata
sortstringSort field: title, addedAt, year, size
orderstringasc or desc
limitnumberMax results (default: 50)
offsetnumberPagination offset

Response:

json
{
  "items": [
    {
      "id": 1,
      "path": "/data/movies/Inception (2010)/Inception (2010).mkv",
      "title": "Inception",
      "year": 2010,
      "mediaType": "movie",
      "sizeBytes": 4294967296,
      "duration": 8880,
      "codec": "h265",
      "resolution": "2160p",
      "hdr": true,
      "container": "mkv",
      "addedAt": "2024-01-01T12:00:00Z",
      "metadata": {
        "tmdbId": 27205,
        "overview": "A thief who steals corporate secrets...",
        "genres": ["Action", "Science Fiction"],
        "posterUrl": "/artwork/movies/27205/poster.jpg",
        "rating": 8.4
      }
    }
  ],
  "total": 342,
  "limit": 50,
  "offset": 0
}

Get file detail

http
GET /api/library/files/:id
Authorization: Bearer <token>

Returns full file detail including all metadata, embedded tracks (audio, subtitle, video), and external subtitle files.

Edit metadata

http
PUT /api/library/files/:id/metadata
Authorization: Bearer <admin-token>
Content-Type: application/json

{
  "title": "Corrected Title",
  "year": 2010,
  "tmdbId": 27205,
  "overview": "Custom overview text"
}

Scanning

Trigger scan

http
POST /api/library/scan
Authorization: Bearer <admin-token>
Content-Type: application/json

{
  "rootId": 1
}

Omit rootId to scan all library roots. The scan runs asynchronously in the background.

Response:

json
{
  "jobId": "scan-1704067200",
  "status": "started"
}

Storage analytics

Get stats

http
GET /api/library/stats
Authorization: Bearer <token>

Response:

json
{
  "totalFiles": 1250,
  "totalSizeBytes": 10995116277760,
  "byMediaType": {
    "movie": { "count": 342, "sizeBytes": 4398046511104 },
    "tv": { "count": 580, "sizeBytes": 5497558138880 },
    "music": { "count": 328, "sizeBytes": 1099511627776 }
  },
  "byCodec": {
    "h265": 420,
    "h264": 502
  },
  "byResolution": {
    "2160p": 120,
    "1080p": 680,
    "720p": 122
  }
}

Use OmniLux, run your own server, or build on the platform.