Skip to main content

Get Comments

Returns all comments and replies for a specific video, including like counts and the current user’s like status.

Parameters

videoId
string
required
The video ID to fetch comments for

Request

curl http://localhost:3001/api/videos/EFTA01683563/comments

Response

comments
array
Array of top-level comment objects (limit: 100 newest comments)
totalCount
integer
Total number of comments and replies returned

Example Response

{
  "comments": [
    {
      "id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
      "content": "Great video!",
      "createdAt": "2026-03-05T10:30:00.000Z",
      "user": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "username": "@user-a7f3b2"
      },
      "likes": 5,
      "userLike": null,
      "replies": [
        {
          "id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
          "content": "I agree!",
          "createdAt": "2026-03-05T10:35:00.000Z",
          "user": {
            "id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
            "username": "@user-k9m4x1"
          },
          "likes": 2,
          "userLike": true
        }
      ]
    }
  ],
  "totalCount": 2
}

Notes

Comments are sorted by creation date (newest first). Only the 100 most recent top-level comments are returned, but all replies are included.

Create Comment

Create a new comment or reply on a video. Requires reCAPTCHA verification.

Parameters

videoId
string
required
The video ID to comment on

Headers

X-Recaptcha-Token
string
required
reCAPTCHA token for verification (skipped in local dev without RECAPTCHA_SECRET_KEY)

Body

content
string
required
Comment text contentValidation:
  • Must not be empty or whitespace-only
  • Maximum 300 characters
  • Trimmed before storage
parentId
string
Parent comment UUID (for replies). Omit for top-level comments.

Request

curl -X POST http://localhost:3001/api/videos/EFTA01683563/comments \
  -H "Content-Type: application/json" \
  -H "X-Recaptcha-Token: your-token" \
  -d '{
    "content": "This is a great video!",
    "parentId": null
  }'

Response (201 Created)

id
string
New comment UUID
content
string
Comment text (trimmed)
createdAt
string
ISO 8601 timestamp
user
object
Author information
likes
integer
Initial like count (always 0)
userLike
null
Initial user like status (always null)
replies
array
Initial replies array (always empty)

Example Response

{
  "id": "a1b2c3d4-e5f6-4a5b-8c7d-9e8f7a6b5c4d",
  "content": "This is a great video!",
  "createdAt": "2026-03-05T12:00:00.000Z",
  "user": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "username": "@user-a7f3b2"
  },
  "likes": 0,
  "userLike": null,
  "replies": []
}

Rate Limiting

Comment Rate Limit: Maximum 10 comments per user per video per 24 hoursExceeding this limit returns:
{
  "error": "You have left too many comments already"
}
Status: 429 Too Many Requests

Error Responses

400
Bad Request
Validation failed:
  • {"error": "Content is required"} - Empty or whitespace-only content
  • {"error": "Comment must be 300 characters or less"} - Content too long
403
Forbidden
reCAPTCHA verification failed:
  • {"error": "Invalid request"} - Missing token
  • {"error": "reCAPTCHA verification failed"} - Token invalid or score < 0.5
429
Too Many Requests
Rate limit exceeded:
  • {"error": "You have left too many comments already"} - 10 comments in 24h

Like Comment

Like or unlike a comment. Requires reCAPTCHA verification. Liking a comment you’ve already liked will unlike it (toggle behavior).

Parameters

commentId
string
required
The comment UUID to like/unlike

Headers

X-Recaptcha-Token
string
required
reCAPTCHA token for verification

Request

curl -X POST http://localhost:3001/api/comments/d290f1ee-6c54-4b01-90e6-d701748f0851/like \
  -H "X-Recaptcha-Token: your-token"

Response

userLike
boolean | null
New like status for this comment:
  • true - Comment was liked (created like)
  • null - Comment was unliked (removed like)

Example Responses

Liking a comment:
{
  "userLike": true
}
Unliking a comment:
{
  "userLike": null
}

Behavior

Toggle Behavior:
  • If user has not liked the comment → Creates like
  • If user has already liked the comment → Removes like
There is no separate “unlike” endpoint. POST to like again to toggle it off.

Error Responses

403
Forbidden
reCAPTCHA verification failed:
  • {"error": "Invalid request"} - Missing token
  • {"error": "reCAPTCHA verification failed"} - Token invalid or score < 0.5

Notes

The like count is calculated dynamically when fetching comments. This endpoint only returns the user’s new like status, not the total like count.

Build docs developers (and LLMs) love