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 Subscriptions API manages channel follow relationships. Subscribing and unsubscribing use the same endpoint with a toggle pattern. You cannot subscribe to your own channel. The public subscriber count endpoint requires no authentication.

POST /api/v1/subscription/subscribe/:channelId

Protected — requires Authorization: Bearer <accessToken>
Subscribe to a channel. If you’re already subscribed, this call unsubscribes you (toggle). You cannot subscribe to your own channel.
channelId
string
required
MongoDB ObjectId of the channel (user) to subscribe to.
# Subscribe
curl -X POST https://vidtube-ke5w.onrender.com/api/v1/subscription/subscribe/664usr456... \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

# Call again to unsubscribe
curl -X POST https://vidtube-ke5w.onrender.com/api/v1/subscription/subscribe/664usr456... \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Response — subscribed (201)
{
  "statusCode": 201,
  "data": { "_id": "664sub001...", "subscriber": "664usr789...", "channel": "664usr456..." },
  "message": "Channel subscribed successfully.",
  "success": true
}
Response — unsubscribed (200)
{
  "statusCode": 200,
  "data": { "acknowledged": true, "deletedCount": 1 },
  "message": "Channel unsubscribed successfully.",
  "success": true
}
Error codes: 400 (missing channelId, self-subscription attempt), 404 (channel not found)

GET /api/v1/subscription/channelSubscriberCount/:channelId

Get the total number of subscribers for a channel. This endpoint is public — no authentication required.
channelId
string
required
MongoDB ObjectId of the channel.
curl https://vidtube-ke5w.onrender.com/api/v1/subscription/channelSubscriberCount/664usr456...
Response (200)
{
  "statusCode": 200,
  "data": { "subscriberCount": 1234 },
  "message": "Subscriber count fetched successfully.",
  "success": true
}
Error codes: 400 (missing channelId), 404 (channel not found)

GET /api/v1/subscription/subscribedChannels/:subscriberId

Protected — requires Authorization: Bearer <accessToken>. You can only view your own subscriptions.
List all channels that the authenticated user is subscribed to. Results are paginated.
subscriberId
string
required
Your user ID (must match the authenticated user).
page
integer
Page number. Defaults to 1.
limit
integer
Items per page. Defaults to 20, maximum 100.
curl "https://vidtube-ke5w.onrender.com/api/v1/subscription/subscribedChannels/664usr789...?page=1&limit=20" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Response (200)
{
  "statusCode": 200,
  "data": {
    "totalCount": 5,
    "page": 1,
    "limit": 20,
    "subscribers": [
      { "_id": "664sub002...", "channel": { "name": "Tech Channel", "avatar": "https://..." } }
    ]
  },
  "message": "Subscribed Channels fetched successfully.",
  "success": true
}
Error codes: 400 (missing subscriberId), 403 (subscriberId doesn’t match authenticated user)

GET /api/v1/subscription/channelSubscribers/:channelId

Protected — requires Authorization: Bearer <accessToken>. You can only view subscribers of your own channel.
List all users subscribed to a channel. Results are paginated.
channelId
string
required
Your channel’s user ID (must match the authenticated user).
page
integer
Page number. Defaults to 1.
limit
integer
Items per page. Defaults to 20, maximum 100.
curl "https://vidtube-ke5w.onrender.com/api/v1/subscription/channelSubscribers/664usr456...?page=1&limit=20" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Response (200)
{
  "statusCode": 200,
  "data": {
    "totalCount": 1234,
    "page": 1,
    "limit": 20,
    "subscribers": [
      { "_id": "664sub001...", "subscriber": { "name": "John Doe", "email": "john@example.com", "avatar": "https://..." } }
    ]
  },
  "message": "Channel Subscribers fetched successfully.",
  "success": true
}
Error codes: 400 (missing channelId), 403 (channelId doesn’t match authenticated user), 404 (channel not found)

Build docs developers (and LLMs) love