Get Like Status
Returns the current user’s like status for a specific video.Parameters
The video ID to check like status for
Request
Response
Current user’s like status for this video:
true- User has liked this videonull- User has not liked this video
Example Responses
Video is liked:Notes
This endpoint automatically identifies the user by their IP address. No authentication headers are required.
Like Video
Like or unlike a video. Requires reCAPTCHA verification. Liking a video you’ve already liked will unlike it (toggle behavior).Parameters
The video ID to like/unlike
Headers
reCAPTCHA token for verification (skipped in local dev without
RECAPTCHA_SECRET_KEY)Request
Response
New like status for this video:
true- Video was liked (created like, incremented counter)null- Video was unliked (removed like, decremented counter)
Example Responses
Liking a video:Behavior
Toggle Behavior:
- If user has not liked the video → Creates like and increments
videos.likesby 1 - If user has already liked the video → Removes like and decrements
videos.likesby 1 (floor at 0)
Side Effects
This endpoint updates the denormalizedlikes counter in the videos table:
Error Responses
reCAPTCHA verification failed:
{"error": "Invalid request"}- Missing token{"error": "reCAPTCHA verification failed"}- Token invalid or score < 0.5
Server error:
{"error": "reCAPTCHA verification error"}- Error communicating with reCAPTCHA service
Database Schema
Video Likes Table
Each like is stored as a record with a unique constraint:Primary key (auto-generated)
Reference to
videos.id (cascade delete)Reference to
users.id (cascade delete)Always
true for video likes (boolean field exists for future dislike support)When the like was created
Unique Constraint
Notes
Currently, only “likes” are supported. There is no dislike functionality despite the
isLike boolean field in the schema (which may be used for future dislikes).The
/api/videos endpoint returns the current likes count for each video. This count is kept in sync by the like/unlike operations.