RESTful API Documentation

This page documents the main RESTful API endpoints of KCTube/VideoStreamHub.

General Notes

Endpoints Overview

MethodEndpointDescription
GET/api/configGet current configuration
POST/api/configUpdate configuration
POST/api/config/resetReset configuration to default
GET/api/search?q=...Search YouTube videos
POST/api/video-infoGet video info by URL
GET/api/video/<video_id>Get video info and streaming URLs by ID
POST/api/downloadDownload video by URL
GET/api/local/videosList local videos (paginated)
GET/api/local/videos/<video_id>Get local video by ID
GET/api/local/videos/<video_id>/streamStream local video file
GET/api/local/videos/<video_id>/subtitleGet subtitle for local video
GET/api/movies/scenesList movie scenes/categories
GET/api/movies/scenes/<scene_name>/videosList videos in a movie scene
GET/api/movies/search?q=...Search movies
GET/api/movies/allList all movies
GET/api/movies/video/<video_id>Get movie video by ID
GET/api/movies/stream/<video_id>Stream movie video by ID
GET/api/playlistsList all playlists
POST/api/playlistsCreate a new playlist
GET/api/playlists/statsGet playlist statistics
GET/api/subtitles/<video_id>Get subtitles for a video
GET/api/update/yt-dlp/versionGet yt-dlp version
POST/api/update/yt-dlpUpdate yt-dlp
GET/api/update/checkCheck for available updates

Endpoint Details & Examples

1. Search YouTube Videos

GET /api/search?q=your+query[&max_results=24][&page=1] Example request:
curl "http://localhost:5000/api/search?q=music&max_results=5&page=1"
Example response:
{
  "videos": [
    {
      "id": "abc123",
      "title": "Music Video Title",
      "author": "Uploader Name",
      "thumbnail": "https://...jpg",
      "duration": "3:45",
      "stats": "1.2M lượt xem"
    },
    ...
  ],
  "total": 100,
  "has_more": true
}

2. Get Video Info by URL

POST /api/video-info Example request:
curl -X POST http://localhost:5000/api/video-info \
  -H "Content-Type: application/json" \
  -d '{"url": "https://youtube.com/watch?v=abc123"}'
Example response:
{
  "id": "abc123",
  "title": "Music Video Title",
  "description": "...",
  "thumbnail": "https://...jpg",
  "uploader": "Uploader Name",
  "upload_date": "20240101",
  "duration": 225,
  "duration_formatted": "3:45",
  "view_count": 1234567,
  "formats": [
    { "quality": "720p", "url": "...", ... }, ...
  ],
  "webpage_url": "https://youtube.com/watch?v=abc123",
  "video_url": "...",
  "audio_url": "..."
}

3. List Local Videos

GET /api/local/videos[?page=1][&per_page=24][&search=keyword] Example request:
curl "http://localhost:5000/api/local/videos?page=1&per_page=2"
Example response:
{
  "videos": [
    {
      "id": "local_1",
      "title": "My Local Video",
      "path": "/downloads/myvideo.mp4",
      ...
    },
    ...
  ],
  "total": 10,
  "page": 1,
  "per_page": 2,
  "total_pages": 5
}

Other Endpoints

See the table above for a full list. Most endpoints follow RESTful conventions and return JSON. For more details, see the source code or contact the maintainer.

RESTful API Docs