VideoHub provides a dashboard endpoint for channel analytics and a dedicated view tracking endpoint for recording when users watch videos. Together these two endpoints power real-time channel growth metrics and accurate per-video view counts across the platform.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/barcode8/VideoHub/llms.txt
Use this file to discover all available pages before exploring further.
GET /api/v1/dashboard/stats/:channelId
Returns aggregate statistics for a channel — total subscribers, published video count, cumulative views, and total likes. This endpoint requires no authentication and is safe to call from a public channel page. The controller queries theSubscription collection for subscriber count, then runs a MongoDB aggregation pipeline across the channel’s published Video documents. Each video is joined with the likes collection so that per-video like counts can be summed into a single channel-wide total. All four counters default to 0 when the channel has no published videos.
Path Parameters
The MongoDB ObjectId of the channel owner whose stats you want to retrieve. Must be a valid 24-character hex ObjectId.
Example Request
Example Response
Response Fields
Number of users currently subscribed to this channel. Counted directly from the
Subscription collection using the channelId.Number of videos owned by this channel that have
isPublished: true. Draft or unpublished videos are excluded.Sum of the
views field across all published videos. This is the authoritative view count as stored on each Video document — it is incremented by the view tracking endpoint below.Total number of likes across all published videos owned by this channel. Computed by joining each video with the
likes collection inside the aggregation pipeline.Errors
| Status | Condition |
|---|---|
400 | channelId is missing from the path. |
400 | channelId is present but is not a valid MongoDB ObjectId. |
View Tracking
VideoHub records individual video views through a dedicated endpoint that deduplicates views per user ID or IP address within a 24-hour window. When a new unique view is recorded, theviews counter on the Video document is atomically incremented, which is the value surfaced by the dashboard stats endpoint above.
POST /api/v1/view/:videoId
Records that the currently authenticated user has watched a video. The endpoint builds a query onvideoId plus an $or condition matching either the authenticated user’s ID or the request’s IP address against existing View documents. If any matching view is found (view documents are TTL-indexed to expire after 86,400 seconds), the existing record is returned without incrementing the counter. Otherwise a new View document is created, the video’s views field is incremented by 1, and the updated count is returned.
Authentication required. Include the access token in the Authorization header.
Path Parameters
The MongoDB ObjectId of the video being watched. Must be a valid 24-character hex ObjectId.
Example Request
Example Response — New View
Example Response — Duplicate View (within 24 h)
Errors
| Status | Condition |
|---|---|
400 | videoId is missing from the path. |
400 | videoId is present but is not a valid MongoDB ObjectId. |
404 | No video found with the given videoId. |
401 | Access token is missing or invalid. |
The frontend calls this endpoint automatically when a video starts playing — you do not need to trigger it manually in normal playback flows. View deduplication is enforced per user ID or IP address: if either matches an existing
View document for the same video within 24 hours, no additional count is recorded. The views field on the Video model is the authoritative counter and is the same value aggregated by GET /api/v1/dashboard/stats/:channelId.