Skip to content

API Documentation

J_Brns edited this page Oct 6, 2025 · 1 revision

API Documentation

NeXroll provides a comprehensive REST API for programmatic access. The API is built with FastAPI and includes interactive documentation at http://localhost:9393/docs.

Base URL

http://localhost:9393

Authentication

Most endpoints do not require authentication as NeXroll is designed for local use. Some endpoints may require API keys for external integrations.

Response Format

All responses are in JSON format. Successful responses return HTTP 200, errors return appropriate HTTP status codes with error details.

API Endpoints

Health & System

GET /health

Health check endpoint.

Response:

{
  "status": "healthy"
}

GET /system/version

Get API and installed version information.

Response:

{
  "api_version": "1.4.6",
  "registry_version": "1.4.6",
  "install_dir": "C:\\Program Files\\NeXroll"
}

GET /system/ffmpeg-info

Get FFmpeg installation status.

Response:

{
  "ffmpeg_present": true,
  "ffmpeg_version": "ffmpeg version 6.0",
  "ffprobe_present": true,
  "ffprobe_version": "ffprobe version 6.0"
}

Prerolls

GET /prerolls

List all prerolls with optional filtering.

Query Parameters:

  • category_id (optional): Filter by category ID
  • tags (optional): Filter by tags (comma-separated)

Response:

[
  {
    "id": 1,
    "filename": "intro.mp4",
    "display_name": null,
    "path": "/data/prerolls/Default/intro.mp4",
    "thumbnail": "prerolls/thumbnails/Default/1_intro.mp4.jpg",
    "tags": "holiday,christmas",
    "category_id": 1,
    "category": {"id": 1, "name": "Default"},
    "categories": [{"id": 1, "name": "Default"}],
    "description": "Christmas intro",
    "duration": 30.5,
    "file_size": 5242880,
    "managed": true,
    "upload_date": "2024-01-01T00:00:00Z"
  }
]

POST /prerolls/upload

Upload a single preroll file.

Form Data:

  • file: Video file
  • tags: Comma-separated tags
  • category_id: Primary category ID
  • category_ids: JSON array of category IDs
  • description: Description text

Response:

{
  "uploaded": true,
  "id": 1,
  "filename": "intro.mp4",
  "thumbnail": "prerolls/thumbnails/Default/1_intro.mp4.jpg",
  "duration": 30.5,
  "file_size": 5242880,
  "category_id": 1,
  "categories": [{"id": 1, "name": "Default"}]
}

POST /prerolls/upload-multiple

Upload multiple preroll files.

Form Data: Same as single upload, but files is an array.

Response:

{
  "total_files": 3,
  "successful_uploads": 3,
  "failed_uploads": 0,
  "results": [...]
}

PUT /prerolls/{preroll_id}

Update a preroll's metadata.

Request Body:

{
  "tags": ["holiday", "christmas"],
  "category_id": 2,
  "description": "Updated description",
  "display_name": "Christmas Intro",
  "new_filename": "christmas_intro.mp4"
}

DELETE /prerolls/{preroll_id}

Delete a preroll.

Categories

GET /categories

List all categories.

Response:

[
  {
    "id": 1,
    "name": "Default",
    "description": "Default category",
    "apply_to_plex": false,
    "plex_mode": "shuffle"
  }
]

POST /categories

Create a new category.

Request Body:

{
  "name": "Halloween",
  "description": "Halloween themed prerolls",
  "apply_to_plex": false,
  "plex_mode": "shuffle"
}

PUT /categories/{category_id}

Update a category.

DELETE /categories/{category_id}

Delete a category (if not in use).

POST /categories/{category_id}/apply-to-plex

Apply category prerolls to Plex.

Query Parameters:

  • rotation_hours: Rotation interval (default: 24)

POST /categories/{category_id}/prerolls/{preroll_id}

Add preroll to category.

Query Parameters:

  • set_primary: Set as primary category (default: false)

Schedules

GET /schedules

List all schedules.

Response:

[
  {
    "id": 1,
    "name": "Holiday Schedule",
    "type": "holiday",
    "start_date": "2024-12-01T00:00:00Z",
    "end_date": "2024-12-31T23:59:59Z",
    "category_id": 2,
    "shuffle": true,
    "playlist": false,
    "is_active": true,
    "last_run": "2024-12-01T12:00:00Z",
    "next_run": "2024-12-02T00:00:00Z",
    "recurrence_pattern": "0 0 * * *",
    "preroll_ids": "1,2,3",
    "fallback_category_id": 1
  }
]

POST /schedules

Create a new schedule.

Request Body:

{
  "name": "Daily Rotation",
  "type": "recurring",
  "start_date": "2024-01-01T00:00:00Z",
  "category_id": 1,
  "shuffle": true,
  "recurrence_pattern": "0 0 * * *",
  "fallback_category_id": 1
}

PUT /schedules/{schedule_id}

Update a schedule.

DELETE /schedules/{schedule_id}

Delete a schedule.

Plex Integration

POST /plex/connect

Connect to Plex server.

Request Body:

{
  "url": "http://192.168.1.100:32400",
  "token": "your-plex-token"
}

GET /plex/status

Get Plex connection status.

Response:

{
  "connected": true,
  "url": "http://192.168.1.100:32400",
  "server_name": "My Plex Server",
  "version": "1.32.0"
}

POST /plex/auto-connect

Auto-discover and connect to Plex server.

Request Body:

{
  "token": "your-token",
  "urls": ["http://192.168.1.100:32400"],
  "prefer_local": true
}

GET /plex/probe

Probe Plex server connectivity.

Query Parameters:

  • url: Plex server URL
  • token: Optional token
  • verify: TLS verification (default: true)

Jellyfin Integration

POST /jellyfin/connect

Connect to Jellyfin server.

Request Body:

{
  "url": "http://192.168.1.100:8096",
  "api_key": "your-api-key"
}

GET /jellyfin/status

Get Jellyfin connection status.

Genre-Based Prerolls

POST /genres/map

Create genre-to-category mapping.

Request Body:

{
  "genre": "Horror",
  "category_id": 3
}

GET /genres/map

List all genre mappings.

POST /genres/apply

Apply preroll by genre list.

Request Body:

{
  "genres": ["Horror", "Thriller"]
}

Query Parameters:

  • ttl: Override TTL in minutes (default: 15)

GET /genres/apply-by-key

Apply preroll by Plex rating key (for webhooks).

Query Parameters:

  • key: Plex rating key
  • ttl: Override TTL in minutes
  • intercept: Enable aggressive intercept (default: false)

Settings & Configuration

GET /settings/path-mappings

Get path mappings for Plex.

Response:

{
  "mappings": [
    {
      "local": "\\\\NAS\\PreRolls",
      "plex": "Z:\\PreRolls"
    }
  ]
}

PUT /settings/path-mappings

Update path mappings.

Query Parameters:

  • merge: Merge with existing (default: false)

Request Body:

{
  "mappings": [
    {
      "local": "\\\\NAS\\PreRolls",
      "plex": "Z:\\PreRolls"
    }
  ]
}

POST /settings/path-mappings/test

Test path translations.

Request Body:

{
  "paths": ["\\\\NAS\\PreRolls\\intro.mp4"]
}

Scheduler Control

GET /scheduler/status

Get scheduler status.

Response:

{
  "running": true,
  "active_schedules": 2
}

POST /scheduler/start

Start the scheduler.

POST /scheduler/stop

Stop the scheduler.

POST /scheduler/run-now

Trigger immediate scheduler execution.

Backup & Restore

GET /backup/database

Export database to JSON.

POST /backup/files

Create ZIP archive of preroll files.

POST /restore/database

Import database from JSON backup.

POST /restore/files

Import preroll files from ZIP.

Webhooks

POST /plex/webhook

Plex webhook receiver for automatic preroll application.

Headers:

  • X-Plex-Signature: Optional signature verification

Query Parameters:

  • ttl: Override TTL in minutes
  • intercept: Enable aggressive intercept

Static Files

GET /static/prerolls/thumbnails/{category}/{thumb_name}

Serve preroll thumbnail (generates on-demand if missing).

GET /static/prerolls/{category}/{filename}

Serve preroll video file.

Error Responses

All errors follow this format:

{
  "detail": "Error description"
}

Common HTTP status codes:

  • 400: Bad Request
  • 404: Not Found
  • 409: Conflict (duplicate)
  • 422: Validation Error
  • 500: Internal Server Error

Rate Limiting

The API includes built-in rate limiting for most endpoints to prevent abuse.

Interactive Documentation

Visit http://localhost:9393/docs for interactive API documentation with testing capabilities.

Clone this wiki locally