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 Comments API lets viewers add text comments to any video, list existing comments with pagination, update their own comments, and delete them. Read operations are public; write operations require a valid access token.

GET /api/v1/comments/videoComments/:videoId

Retrieve all comments for a specific video, sorted newest first. Each comment includes the owner’s username and avatar.
videoId
string
required
MongoDB ObjectId of the video.
page
integer
Page number (1-indexed). Defaults to 1.
limit
integer
Comments per page. Defaults to 10.
curl "https://vidtube-ke5w.onrender.com/api/v1/comments/videoComments/664vid123...?page=1&limit=10"
Response (200)
{
  "statusCode": 200,
  "data": [
    {
      "_id": "664cmt456...",
      "content": "Great video!",
      "video": "664vid123...",
      "owner": { "_id": "664usr789...", "username": "johndoe", "avatar": "https://res.cloudinary.com/..." },
      "createdAt": "2024-05-01T12:00:00.000Z"
    }
  ],
  "message": "Comments fetched successfully.",
  "success": true
}
Error codes: 404 (video not found)

POST /api/v1/comments/addComment/:videoId

Protected — requires Authorization: Bearer <accessToken>
Add a new comment to a video.
videoId
string
required
MongoDB ObjectId of the video to comment on.
content
string
required
Comment text.
curl -X POST https://vidtube-ke5w.onrender.com/api/v1/comments/addComment/664vid123... \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"content":"Great video, very helpful!"}'
Response (200)
{
  "statusCode": 200,
  "data": {
    "_id": "664cmt999...",
    "content": "Great video, very helpful!",
    "video": "664vid123...",
    "owner": "664usr789...",
    "createdAt": "2024-05-02T09:30:00.000Z"
  },
  "message": "Comment Added successfully.",
  "success": true
}
Error codes: 400 (missing content), 401 (not authenticated)

PATCH /api/v1/comments/updateComment/:commentId

Protected — requires Authorization: Bearer <accessToken>
Edit an existing comment. You must be the comment’s owner.
commentId
string
required
MongoDB ObjectId of the comment to update.
content
string
required
Updated comment text.
curl -X PATCH https://vidtube-ke5w.onrender.com/api/v1/comments/updateComment/664cmt999... \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"content":"Updated: this tutorial is excellent!"}'
Error codes: 400 (missing commentId or content), 401, 404 (comment not found)

DELETE /api/v1/comments/deleteComment/:commentId

Protected — requires Authorization: Bearer <accessToken>
Delete a comment by its ID.
commentId
string
required
MongoDB ObjectId of the comment to delete.
curl -X DELETE https://vidtube-ke5w.onrender.com/api/v1/comments/deleteComment/664cmt999... \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Response (200) — returns the deleted comment document. Error codes: 400 (missing or invalid commentId)

Build docs developers (and LLMs) love