This document provides comprehensive API documentation for the Yuthukama platform, including all endpoints, request/response formats, authentication, and examples.
- Base URL
- Authentication
- Rate Limiting
- Error Handling
- Authentication Endpoints
- User Management Endpoints
- Posts Endpoints
- Chat Endpoints
- Notification Endpoints
- Admin Endpoints
- AI Chat Endpoints
- Response Formats
- Status Codes
- Development:
http://localhost:5000 - Production:
https://your-backend-url.com
The API uses JWT (JSON Web Tokens) for authentication. Tokens are sent via HTTP-only cookies or Authorization header.
// Cookies are automatically sent with requests
fetch('/api/users/profile', {
credentials: 'include'
});fetch('/api/users/profile', {
headers: {
'Authorization': `Bearer ${token}`
}
});// Login to get token
const response = await fetch('/api/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
credentials: 'include',
body: JSON.stringify({
email: 'user@example.com',
password: 'password123'
})
});
const data = await response.json();
// Token is automatically set in HTTP-only cookieThe API implements rate limiting to prevent abuse:
- General API: 100 requests per 15 minutes per IP
- Authentication: 5 requests per 15 minutes per IP
- Headers: Rate limit information is included in response headers
// Rate limit headers in response
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640995200{
"message": "Error description",
"errors": [
{
"field": "email",
"message": "Please provide a valid email address"
}
]
}| Status Code | Description |
|---|---|
| 400 | Bad Request - Invalid input data |
| 401 | Unauthorized - Authentication required |
| 403 | Forbidden - Insufficient permissions |
| 404 | Not Found - Resource not found |
| 409 | Conflict - Resource already exists |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Internal Server Error - Server error |
POST /api/auth/register
Register a new user account.
{
"username": "john_doe",
"email": "john@example.com",
"password": "securepassword123"
}username: Required, 3-30 characters, alphanumeric and underscores onlyemail: Required, valid email format, uniquepassword: Required, minimum 6 characters
Success (201 Created)
{
"success": true,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": "60f7b3b3b3b3b3b3b3b3b3b3",
"username": "john_doe",
"email": "john@example.com",
"role": "user",
"isEmailVerified": false,
"createdAt": "2023-07-20T10:30:00.000Z"
}
}Error (400 Bad Request)
{
"message": "Validation failed",
"errors": [
{
"field": "email",
"message": "Email already exists"
}
]
}POST /api/auth/login
Authenticate user and return JWT token.
{
"email": "john@example.com",
"password": "securepassword123"
}Success (200 OK)
{
"success": true,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": "60f7b3b3b3b3b3b3b3b3b3b3",
"username": "john_doe",
"email": "john@example.com",
"role": "user",
"profilePicture": "/uploads/profile-pics/default.jpg",
"isEmailVerified": true
}
}Error (401 Unauthorized)
{
"message": "Invalid credentials"
}POST /api/auth/logout
Logout user and clear authentication token.
Success (200 OK)
{
"message": "Logged out successfully"
}GET /api/auth/check
Check if user is authenticated and return user data.
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"user": {
"id": "60f7b3b3b3b3b3b3b3b3b3b3",
"username": "john_doe",
"email": "john@example.com",
"role": "user",
"profilePicture": "/uploads/profile-pics/default.jpg",
"isEmailVerified": true,
"createdAt": "2023-07-20T10:30:00.000Z"
}
}Error (401 Unauthorized)
{
"message": "Not authorized, no token provided"
}POST /api/auth/forgot-password
Request password reset email.
{
"email": "john@example.com"
}Success (200 OK)
{
"message": "Password reset email sent"
}POST /api/auth/reset-password/:resetToken
Reset password using token from email.
resetToken: Password reset token from email
{
"password": "newpassword123",
"confirmPassword": "newpassword123"
}Success (200 OK)
{
"message": "Password reset successfully"
}Error (400 Bad Request)
{
"message": "Invalid or expired reset token"
}PUT /api/auth/change-password
Change password for authenticated user.
Authorization: Bearer <token>
{
"currentPassword": "oldpassword123",
"newPassword": "newpassword123",
"confirmPassword": "newpassword123"
}Success (200 OK)
{
"message": "Password changed successfully"
}GET /api/users/profile
Get authenticated user's profile.
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"user": {
"id": "60f7b3b3b3b3b3b3b3b3b3b3",
"username": "john_doe",
"email": "john@example.com",
"role": "user",
"profilePicture": "/uploads/profile-pics/user123.jpg",
"isEmailVerified": true,
"followers": [],
"following": [],
"createdAt": "2023-07-20T10:30:00.000Z"
}
}GET /api/users/:id
Get user profile by ID.
id: User ID
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"user": {
"id": "60f7b3b3b3b3b3b3b3b3b3b3",
"username": "jane_doe",
"profilePicture": "/uploads/profile-pics/user456.jpg",
"followers": ["60f7b3b3b3b3b3b3b3b3b3b4"],
"following": ["60f7b3b3b3b3b3b3b3b3b3b5"],
"createdAt": "2023-07-19T15:20:00.000Z"
}
}PUT /api/users/username
Update authenticated user's username.
Authorization: Bearer <token>
{
"username": "new_username"
}Success (200 OK)
{
"success": true,
"user": {
"id": "60f7b3b3b3b3b3b3b3b3b3b3",
"username": "new_username",
"email": "john@example.com",
"role": "user"
}
}PUT /api/users/profile-pic
Update authenticated user's profile picture.
Authorization: Bearer <token>
Content-Type: multipart/form-data
Form data with profilePic file field.
Success (200 OK)
{
"success": true,
"user": {
"id": "60f7b3b3b3b3b3b3b3b3b3b3",
"username": "john_doe",
"profilePicture": "https://s3.amazonaws.com/bucket/profile-pics/user123.jpg"
}
}GET /api/users/search
Search for users by username or email.
query: Search query (required)role: Filter by role (optional)limit: Limit results (optional, default: 20)
GET /api/users/search?query=john&limit=10
Success (200 OK)
{
"success": true,
"users": [
{
"id": "60f7b3b3b3b3b3b3b3b3b3b3",
"username": "john_doe",
"profilePicture": "/uploads/profile-pics/user123.jpg",
"followers": 150,
"following": 75
}
],
"total": 1
}GET /api/users/recommended
Get recommended users to follow.
limit: Limit results (optional, default: 10)
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"users": [
{
"id": "60f7b3b3b3b3b3b3b3b3b3b4",
"username": "jane_doe",
"profilePicture": "/uploads/profile-pics/user456.jpg",
"followers": 200,
"mutualConnections": 5
}
]
}POST /api/users/:id/follow
Follow a user.
id: User ID to follow
Authorization: Bearer <token>
Success (200 OK)
{
"message": "Successfully followed user",
"followStatus": true
}DELETE /api/users/:id/follow
Unfollow a user.
id: User ID to unfollow
Authorization: Bearer <token>
Success (200 OK)
{
"message": "Successfully unfollowed user",
"followStatus": false
}GET /api/users/:id/followers
Get user's followers list.
id: User ID
limit: Limit results (optional, default: 20)offset: Offset for pagination (optional, default: 0)
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"followers": [
{
"id": "60f7b3b3b3b3b3b3b3b3b3b5",
"username": "follower_user",
"profilePicture": "/uploads/profile-pics/user789.jpg",
"followedAt": "2023-07-20T12:00:00.000Z"
}
],
"total": 150,
"hasMore": true
}GET /api/users/:id/following
Get user's following list.
id: User ID
limit: Limit results (optional, default: 20)offset: Offset for pagination (optional, default: 0)
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"following": [
{
"id": "60f7b3b3b3b3b3b3b3b3b3b6",
"username": "following_user",
"profilePicture": "/uploads/profile-pics/user101.jpg",
"followedAt": "2023-07-19T14:30:00.000Z"
}
],
"total": 75,
"hasMore": true
}GET /api/users/:id/follow-status
Check if current user is following a specific user.
id: User ID to check
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"isFollowing": true
}GET /api/users/:id/stats
Get user statistics (posts, likes, comments).
id: User ID
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"stats": {
"posts": 25,
"likes": 150,
"comments": 89,
"followers": 200,
"following": 75
}
}GET /api/posts
Get all posts with pagination.
page: Page number (optional, default: 1)limit: Posts per page (optional, default: 20)sortBy: Sort by field (optional: 'createdAt', 'likes', 'comments')
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"posts": [
{
"id": "60f7b3b3b3b3b3b3b3b3b3b7",
"title": "My First Post",
"description": "This is my first post on Yuthukama!",
"image": "https://s3.amazonaws.com/bucket/posts/post123.jpg",
"user": {
"id": "60f7b3b3b3b3b3b3b3b3b3b3",
"username": "john_doe",
"profilePicture": "/uploads/profile-pics/user123.jpg"
},
"likes": ["60f7b3b3b3b3b3b3b3b3b3b4"],
"comments": [
{
"id": "60f7b3b3b3b3b3b3b3b3b3b8",
"content": "Great post!",
"user": {
"id": "60f7b3b3b3b3b3b3b3b3b3b4",
"username": "jane_doe"
},
"createdAt": "2023-07-20T15:30:00.000Z"
}
],
"views": 45,
"createdAt": "2023-07-20T14:00:00.000Z",
"updatedAt": "2023-07-20T14:00:00.000Z"
}
],
"pagination": {
"currentPage": 1,
"totalPages": 5,
"totalPosts": 100,
"hasNext": true,
"hasPrev": false
}
}POST /api/posts
Create a new post.
Authorization: Bearer <token>
Content-Type: multipart/form-data
Form data with:
title: Post title (required)description: Post description (required)image: Image file (optional)
Success (201 Created)
{
"success": true,
"post": {
"id": "60f7b3b3b3b3b3b3b3b3b3b7",
"title": "My First Post",
"description": "This is my first post on Yuthukama!",
"image": "https://s3.amazonaws.com/bucket/posts/post123.jpg",
"user": "60f7b3b3b3b3b3b3b3b3b3b3",
"likes": [],
"comments": [],
"views": 0,
"createdAt": "2023-07-20T14:00:00.000Z"
}
}GET /api/posts/user/:userId
Get all posts by a specific user.
userId: User ID
page: Page number (optional, default: 1)limit: Posts per page (optional, default: 20)
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"posts": [
{
"id": "60f7b3b3b3b3b3b3b3b3b3b7",
"title": "User's Post",
"description": "Post content here",
"image": "https://s3.amazonaws.com/bucket/posts/post123.jpg",
"likes": ["60f7b3b3b3b3b3b3b3b3b3b4"],
"comments": [],
"views": 25,
"createdAt": "2023-07-20T14:00:00.000Z"
}
],
"pagination": {
"currentPage": 1,
"totalPages": 2,
"totalPosts": 25,
"hasNext": true,
"hasPrev": false
}
}PUT /api/posts/:id
Update a post (only by post owner).
id: Post ID
Authorization: Bearer <token>
Content-Type: application/json
{
"title": "Updated Post Title",
"description": "Updated post description"
}Success (200 OK)
{
"success": true,
"post": {
"id": "60f7b3b3b3b3b3b3b3b3b3b7",
"title": "Updated Post Title",
"description": "Updated post description",
"image": "https://s3.amazonaws.com/bucket/posts/post123.jpg",
"updatedAt": "2023-07-20T16:00:00.000Z"
}
}DELETE /api/posts/:id
Delete a post (only by post owner or admin).
id: Post ID
Authorization: Bearer <token>
Success (200 OK)
{
"message": "Post deleted successfully"
}PUT /api/posts/:id/like
Like or unlike a post.
id: Post ID
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"liked": true,
"likesCount": 15
}PUT /api/posts/:id/save
Save or unsave a post.
id: Post ID
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"saved": true,
"message": "Post saved successfully"
}POST /api/posts/:id/comments
Add a comment to a post.
id: Post ID
Authorization: Bearer <token>
Content-Type: application/json
{
"content": "This is a great post!"
}Success (201 Created)
{
"success": true,
"comment": {
"id": "60f7b3b3b3b3b3b3b3b3b3b8",
"content": "This is a great post!",
"user": {
"id": "60f7b3b3b3b3b3b3b3b3b3b3",
"username": "john_doe",
"profilePicture": "/uploads/profile-pics/user123.jpg"
},
"createdAt": "2023-07-20T15:30:00.000Z"
}
}DELETE /api/posts/:id/comments/:commentId
Delete a comment (only by comment owner or admin).
id: Post IDcommentId: Comment ID
Authorization: Bearer <token>
Success (200 OK)
{
"message": "Comment deleted successfully"
}GET /api/posts/search
Search posts by title, description, or content.
query: Search query (required)category: Filter by category (optional)sortBy: Sort by field (optional: 'createdAt', 'likes', 'comments')limit: Limit results (optional, default: 20)
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"posts": [
{
"id": "60f7b3b3b3b3b3b3b3b3b3b7",
"title": "Search Result Post",
"description": "This post matches your search query",
"user": {
"id": "60f7b3b3b3b3b3b3b3b3b3b3",
"username": "john_doe"
},
"createdAt": "2023-07-20T14:00:00.000Z"
}
],
"total": 5
}GET /api/posts/trending
Get trending/popular posts.
limit: Limit results (optional, default: 20)days: Consider posts from last N days (optional, default: 7)
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"posts": [
{
"id": "60f7b3b3b3b3b3b3b3b3b3b7",
"title": "Trending Post",
"description": "This post is trending!",
"likes": ["60f7b3b3b3b3b3b3b3b3b3b4", "60f7b3b3b3b3b3b3b3b3b3b5"],
"comments": [],
"views": 500,
"trendingScore": 85.5,
"createdAt": "2023-07-20T14:00:00.000Z"
}
]
}GET /api/posts/saved
Get user's saved posts.
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"posts": [
{
"id": "60f7b3b3b3b3b3b3b3b3b3b7",
"title": "Saved Post",
"description": "This is a saved post",
"user": {
"id": "60f7b3b3b3b3b3b3b3b3b3b3",
"username": "john_doe"
},
"savedAt": "2023-07-20T16:00:00.000Z",
"createdAt": "2023-07-20T14:00:00.000Z"
}
]
}GET /api/posts/following
Get posts from users that the current user follows.
limit: Limit results (optional, default: 20)page: Page number (optional, default: 1)
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"posts": [
{
"id": "60f7b3b3b3b3b3b3b3b3b3b7",
"title": "Post from Followed User",
"description": "Content from someone you follow",
"user": {
"id": "60f7b3b3b3b3b3b3b3b3b3b4",
"username": "jane_doe"
},
"createdAt": "2023-07-20T14:00:00.000Z"
}
],
"pagination": {
"currentPage": 1,
"totalPages": 3,
"totalPosts": 45,
"hasNext": true,
"hasPrev": false
}
}GET /api/posts/for-you
Get personalized "For You" feed with algorithmic recommendations.
limit: Limit results (optional, default: 20)page: Page number (optional, default: 1)
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"posts": [
{
"id": "60f7b3b3b3b3b3b3b3b3b3b7",
"title": "Recommended Post",
"description": "This post is recommended for you",
"user": {
"id": "60f7b3b3b3b3b3b3b3b3b3b6",
"username": "recommended_user"
},
"recommendationScore": 0.85,
"createdAt": "2023-07-20T14:00:00.000Z"
}
],
"pagination": {
"currentPage": 1,
"totalPages": 10,
"totalPosts": 200,
"hasNext": true,
"hasPrev": false
}
}POST /api/posts/:id/report
Report a post for inappropriate content.
id: Post ID
Authorization: Bearer <token>
Content-Type: application/json
{
"reason": "inappropriate",
"description": "This post contains inappropriate content"
}Success (200 OK)
{
"message": "Post reported successfully"
}GET /api/chat
Get all conversations for the authenticated user.
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"conversations": [
{
"id": "60f7b3b3b3b3b3b3b3b3b3b9",
"participants": [
{
"id": "60f7b3b3b3b3b3b3b3b3b3b3",
"username": "john_doe",
"profilePicture": "/uploads/profile-pics/user123.jpg"
},
{
"id": "60f7b3b3b3b3b3b3b3b3b3b4",
"username": "jane_doe",
"profilePicture": "/uploads/profile-pics/user456.jpg"
}
],
"lastMessage": "Hello! How are you?",
"lastMessageTimestamp": "2023-07-20T16:30:00.000Z",
"unreadCount": 2,
"createdAt": "2023-07-20T10:00:00.000Z"
}
]
}GET /api/chat/user/:receiverId
Get or create a conversation with another user.
receiverId: ID of the other user
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"conversation": {
"id": "60f7b3b3b3b3b3b3b3b3b3b9",
"participants": [
{
"id": "60f7b3b3b3b3b3b3b3b3b3b3",
"username": "john_doe",
"profilePicture": "/uploads/profile-pics/user123.jpg"
},
{
"id": "60f7b3b3b3b3b3b3b3b3b3b4",
"username": "jane_doe",
"profilePicture": "/uploads/profile-pics/user456.jpg"
}
],
"createdAt": "2023-07-20T10:00:00.000Z"
}
}GET /api/chat/:conversationId/messages
Get all messages in a conversation.
conversationId: Conversation ID
page: Page number (optional, default: 1)limit: Messages per page (optional, default: 50)
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"messages": [
{
"id": "60f7b3b3b3b3b3b3b3b3b3ba",
"text": "Hello! How are you?",
"sender": {
"id": "60f7b3b3b3b3b3b3b3b3b3b3",
"username": "john_doe",
"profilePicture": "/uploads/profile-pics/user123.jpg"
},
"read": false,
"readAt": null,
"reactions": [],
"createdAt": "2023-07-20T16:30:00.000Z"
}
],
"pagination": {
"currentPage": 1,
"totalPages": 2,
"totalMessages": 75,
"hasNext": true,
"hasPrev": false
}
}POST /api/chat/messages
Send a message with optional file attachment.
Authorization: Bearer <token>
Content-Type: multipart/form-data
Form data with:
conversationId: Conversation ID (required)text: Message text (required if no file)file: File attachment (optional)
Success (201 Created)
{
"success": true,
"message": {
"id": "60f7b3b3b3b3b3b3b3b3b3ba",
"text": "Hello! How are you?",
"sender": "60f7b3b3b3b3b3b3b3b3b3b3",
"conversationId": "60f7b3b3b3b3b3b3b3b3b3b9",
"read": false,
"attachment": null,
"createdAt": "2023-07-20T16:30:00.000Z"
}
}PUT /api/chat/messages/:messageId
Edit a message (only by message sender).
messageId: Message ID
Authorization: Bearer <token>
Content-Type: application/json
{
"text": "Updated message text"
}Success (200 OK)
{
"success": true,
"message": {
"id": "60f7b3b3b3b3b3b3b3b3b3ba",
"text": "Updated message text",
"edited": true,
"editedAt": "2023-07-20T16:35:00.000Z"
}
}DELETE /api/chat/messages/:messageId
Delete a message (only by message sender).
messageId: Message ID
Authorization: Bearer <token>
Success (200 OK)
{
"message": "Message deleted successfully"
}PUT /api/chat/:conversationId/read
Mark all messages in a conversation as read.
conversationId: Conversation ID
Authorization: Bearer <token>
Success (200 OK)
{
"message": "Messages marked as read"
}GET /api/chat/:conversationId/unread-count
Get unread message count for a conversation.
conversationId: Conversation ID
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"unreadCount": 5
}GET /api/notifications
Get user's notifications.
page: Page number (optional, default: 1)limit: Notifications per page (optional, default: 20)type: Filter by notification type (optional)
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"notifications": [
{
"id": "60f7b3b3b3b3b3b3b3b3b3bb",
"type": "like",
"content": "liked your post",
"sender": {
"id": "60f7b3b3b3b3b3b3b3b3b3b4",
"username": "jane_doe",
"profilePicture": "/uploads/profile-pics/user456.jpg"
},
"relatedPost": {
"id": "60f7b3b3b3b3b3b3b3b3b3b7",
"title": "My Post"
},
"isRead": false,
"createdAt": "2023-07-20T17:00:00.000Z"
}
],
"unreadCount": 5,
"pagination": {
"currentPage": 1,
"totalPages": 3,
"totalNotifications": 50,
"hasNext": true,
"hasPrev": false
}
}PATCH /api/notifications/:id/read
Mark a specific notification as read.
id: Notification ID
Authorization: Bearer <token>
Success (200 OK)
{
"message": "Notification marked as read"
}PATCH /api/notifications/mark-all-read
Mark all notifications as read.
Authorization: Bearer <token>
Success (200 OK)
{
"message": "All notifications marked as read"
}DELETE /api/notifications/:id
Delete a specific notification.
id: Notification ID
Authorization: Bearer <token>
Success (200 OK)
{
"message": "Notification deleted successfully"
}DELETE /api/notifications
Delete all notifications.
Authorization: Bearer <token>
Success (200 OK)
{
"message": "All notifications deleted successfully"
}GET /api/admin/dashboard-stats
Get comprehensive dashboard statistics.
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"stats": {
"users": {
"total": 1250,
"active": 1100,
"newThisMonth": 150
},
"posts": {
"total": 5000,
"thisMonth": 500,
"reported": 25
},
"messages": {
"total": 15000,
"today": 150
},
"system": {
"uptime": "99.9%",
"responseTime": "120ms",
"storage": "2.5GB"
}
}
}GET /api/admin/users
Get all users with pagination and filtering.
page: Page number (optional, default: 1)limit: Users per page (optional, default: 20)role: Filter by role (optional)search: Search by username or email (optional)
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"users": [
{
"id": "60f7b3b3b3b3b3b3b3b3b3b3",
"username": "john_doe",
"email": "john@example.com",
"role": "user",
"isEmailVerified": true,
"posts": 25,
"followers": 200,
"createdAt": "2023-07-20T10:30:00.000Z",
"lastActive": "2023-07-20T18:00:00.000Z"
}
],
"pagination": {
"currentPage": 1,
"totalPages": 10,
"totalUsers": 1250,
"hasNext": true,
"hasPrev": false
}
}PUT /api/admin/users/:userId
Update user information (admin only).
userId: User ID
Authorization: Bearer <token>
Content-Type: application/json
{
"role": "admin",
"isEmailVerified": true
}Success (200 OK)
{
"success": true,
"user": {
"id": "60f7b3b3b3b3b3b3b3b3b3b3",
"username": "john_doe",
"email": "john@example.com",
"role": "admin",
"isEmailVerified": true
}
}DELETE /api/admin/users/:userId
Delete a user (admin only).
userId: User ID
Authorization: Bearer <token>
Success (200 OK)
{
"message": "User deleted successfully"
}GET /api/admin/analytics
Get detailed analytics data.
period: Time period (optional: 'day', 'week', 'month', 'year')startDate: Start date (optional)endDate: End date (optional)
Authorization: Bearer <token>
Success (200 OK)
{
"success": true,
"analytics": {
"userGrowth": [
{
"date": "2023-07-20",
"newUsers": 15,
"totalUsers": 1250
}
],
"postActivity": [
{
"date": "2023-07-20",
"posts": 25,
"likes": 150,
"comments": 45
}
],
"engagement": {
"avgPostsPerUser": 4.2,
"avgLikesPerPost": 12.5,
"avgCommentsPerPost": 3.8
}
}
}POST /api/chat/ai-message
Send a message to the AI assistant.
Authorization: Bearer <token>
Content-Type: application/json
{
"message": "What is the best way to learn React?",
"conversationId": "60f7b3b3b3b3b3b3b3b3b3bc"
}Success (200 OK)
{
"success": true,
"response": "Learning React effectively involves several key steps:\n\n1. **Start with JavaScript fundamentals** - Make sure you understand ES6+ features like arrow functions, destructuring, and modules.\n\n2. **Learn React basics** - Start with components, JSX, props, and state.\n\n3. **Practice with projects** - Build small projects to apply what you learn.\n\n4. **Use official documentation** - The React docs are excellent and regularly updated.\n\n5. **Join the community** - Participate in forums, Discord servers, and local meetups.\n\nWould you like me to elaborate on any of these points?",
"conversationId": "60f7b3b3b3b3b3b3b3b3b3bc",
"timestamp": "2023-07-20T18:30:00.000Z"
}{
"success": true,
"data": { ... },
"message": "Operation completed successfully"
}{
"success": false,
"message": "Error description",
"errors": [
{
"field": "email",
"message": "Please provide a valid email address"
}
]
}{
"success": true,
"data": [ ... ],
"pagination": {
"currentPage": 1,
"totalPages": 10,
"totalItems": 200,
"hasNext": true,
"hasPrev": false,
"limit": 20
}
}| Code | Description |
|---|---|
| 200 | OK - Request successful |
| 201 | Created - Resource created successfully |
| 400 | Bad Request - Invalid input data |
| 401 | Unauthorized - Authentication required |
| 403 | Forbidden - Insufficient permissions |
| 404 | Not Found - Resource not found |
| 409 | Conflict - Resource already exists |
| 422 | Unprocessable Entity - Validation failed |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Internal Server Error - Server error |
For interactive API documentation, visit /api-docs when running the server locally or in production.