Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Pragyat-Nikunj/VidTube/llms.txt

Use this file to discover all available pages before exploring further.

The Videos API lets you publish videos with thumbnails, browse the full video library with pagination and search, and manage individual video records. Video files are stored on Cloudinary and duration is auto-detected via FFmpeg after upload.

GET /api/v1/videos/getAllVideos

List all published videos with optional filtering, sorting, and pagination.
page
integer
Page number (1-indexed). Defaults to 1.
limit
integer
Videos per page. Defaults to 10, maximum 100.
query
string
Search term. Matches against video title and description (case-insensitive).
sortBy
string
Field to sort by. One of createdAt, views, likes. Defaults to createdAt.
sortType
string
Sort direction. asc or desc. Defaults to desc.
userId
string
Filter videos by owner’s user ID.
curl "https://vidtube-ke5w.onrender.com/api/v1/videos/getAllVideos?page=1&limit=10&sortBy=views&sortType=desc&query=tutorial"
Response (200)
{
  "statusCode": 200,
  "data": {
    "videos": [
      {
        "_id": "664vid123...",
        "title": "Node.js Tutorial",
        "description": "Learn Node.js from scratch",
        "videoFile": "https://res.cloudinary.com/...",
        "thumbnail": "https://res.cloudinary.com/...",
        "duration": "12: 30 seconds",
        "views": 1500,
        "isPublished": 1,
        "owner": "664usr456..."
      }
    ],
    "totalVideos": 42,
    "totalPages": 5
  },
  "message": "Video fetched successfully.",
  "success": true
}
Error codes: 400 (invalid page or limit)

GET /api/v1/videos/getVideoById/:videoId

Fetch a single video by its ID.
videoId
string
required
MongoDB ObjectId of the video.
curl https://vidtube-ke5w.onrender.com/api/v1/videos/getVideoById/664vid123...
Error codes: 404 (video not found)

POST /api/v1/videos/publishVideo

Protected — requires Authorization: Bearer <accessToken>
Upload a new video. Send as multipart/form-data. Duration is extracted automatically from the video file using FFprobe before uploading to Cloudinary.
title
string
required
Video title.
description
string
Video description. Defaults to "No description provided" if omitted.
video
file
required
Video file to upload.
thumbnail
file
Thumbnail image file.
curl -X POST https://vidtube-ke5w.onrender.com/api/v1/videos/publishVideo \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -F "title=My First Video" \
  -F "description=A great tutorial" \
  -F "video=@/path/to/video.mp4" \
  -F "thumbnail=@/path/to/thumb.jpg"
Response (200)
{
  "statusCode": 200,
  "data": {
    "_id": "664vid789...",
    "title": "My First Video",
    "description": "A great tutorial",
    "videoFile": "https://res.cloudinary.com/...",
    "thumbnail": "https://res.cloudinary.com/...",
    "duration": "5: 23 seconds",
    "isPublished": 1,
    "owner": "664usr123..."
  },
  "message": "Video uploaded successfully",
  "success": true
}
If the Cloudinary upload fails, any already-uploaded files are automatically deleted to prevent orphaned assets.
Error codes: 400 (missing title or video file), 500 (upload failed)

PATCH /api/v1/videos/updateVideo/:videoId

Protected — requires Authorization: Bearer <accessToken>
Update a video’s title, description, video file, or thumbnail. At least one field is required.
videoId
string
required
MongoDB ObjectId of the video to update.
title
string
New video title.
description
string
New video description.
video
file
Replacement video file. Duration is re-detected automatically.
thumbnail
file
Replacement thumbnail image.
curl -X PATCH https://vidtube-ke5w.onrender.com/api/v1/videos/updateVideo/664vid789... \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -F "title=Updated Title" \
  -F "description=Updated description"
Error codes: 400 (invalid videoId, no fields provided), 401

DELETE /api/v1/videos/deleteVideo/:videoId

Protected — requires Authorization: Bearer <accessToken>
Delete a video by ID.
videoId
string
required
MongoDB ObjectId of the video to delete.
curl -X DELETE https://vidtube-ke5w.onrender.com/api/v1/videos/deleteVideo/664vid789... \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Error codes: 400 (missing videoId), 404 (video not found)

PATCH /api/v1/videos/togglePublish/:videoId

Protected — requires Authorization: Bearer <accessToken>
Toggle a video’s publish status. isPublished: 1 means public; isPublished: 0 means private. Each call flips the current value.
videoId
string
required
MongoDB ObjectId of the video.
curl -X PATCH https://vidtube-ke5w.onrender.com/api/v1/videos/togglePublish/664vid789... \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Response (200) — returns the updated video document with the new isPublished value. Error codes: 400 (invalid videoId), 404 (video not found)

Build docs developers (and LLMs) love