Base URL: http://localhost:5000/api
Sessions are delivered as an httpOnly studyhub_token cookie (set on
login/register; invisible to JavaScript). The Authorization: Bearer <token>
header remains accepted for non-browser clients.
POST /auth/register
- Body:
{ username, email, password (min 8), fullName?, role: student|teacher } - Returns:
{ data: { user, token }, success, message }+ auth cookie - The account starts unverified — login is blocked (403
needsVerification) until the emailed verification link is used. - Rate Limit: 5 / hour per IP
POST /auth/login
- Body:
{ identifier, password }(identifier can be email or username) - Returns:
{ data: { user, token }, success, message }+ auth cookie - 403 with
data.needsVerification: truefor unverified accounts - Rate Limit: 10 / 15 min per IP
POST /auth/logout
- Clears the auth cookie. Public.
GET /auth/me
- Auth: cookie or
Authorization: Bearer <token> - Returns:
{ data: { user } }
POST /auth/resend-verification
- Body:
{ email }— always responds generically (no account enumeration) - Rate Limit: 3 / hour per IP
POST /auth/verify-email
- Body:
{ token } - Rate Limit: 20 req / 15 min
POST /auth/forgot-password
- Body:
{ email } - Rate Limit: 20 req / 15 min
POST /auth/reset-password
- Body:
{ token, newPassword } - Rate Limit: 20 req / 15 min
GET /users/:username
- Returns: Public user info (username, bio, join date, verify status)
GET /users/:username/uploads
- Query:
?page=1&limit=10 - Returns: Public uploads by user
POST /uploads
- Headers:
Authorization: Bearer <token>,Content-Type: multipart/form-data - Body:
file,title,description,subject,type,tags - Rate Limit: 100 req / hour
GET /uploads
- Query:
?page=1&limit=20&search=keyword&type=notes&subject=math
GET /uploads/:id
POST /uploads/:id/rate
- Body:
{ rating, comment }
DELETE /uploads/:id
- Soft deletes the file
GET /messages/conversations
POST /messages/send
- Body:
{ receiverId, content, attachmentUrl, attachmentType }
POST /messages/upload
- Body:
file - Rate Limit: 100 req / hour
GET /admin/stats
GET /admin/uploads
- Query:
?page=1&search=keyword&type=notes
DELETE /admin/uploads/:id
GET /admin/trends
- Returns:
{ labels: [], users: [], uploads: [] } - Period: Last 7 days
- Cache: 1 hour
GET /leaderboard
- Returns:
{ topContributors, topLearners, userRank } - Includes badges and rank metrics.
GET /recommendations
- Headers:
Authorization: Bearer <token> - Returns: Top 6 suggestions based on user download history.
GET /recommendations/trending
- Returns: Top 10 globally popular items.
POST /ai/summarize/:uploadId
- Headers:
Authorization: Bearer <token> - Returns:
{ summary }(Markdown format) - Requires: PDF or Text document.