Base URL
https://api.forum.gutsylab.com/api
Authentication
This API uses Laravel Sanctum for authentication. After login/register, include the token in the header:
Authorization: Bearer {your_token}
🔐 Authentication
Register a new user account
Request Body:
{
"name": "John Doe",
"username": "johndoe",
"email": "john@example.com",
"password": "password123",
"password_confirmation": "password123"
}
Response (201):
{
"success": true,
"message": "User registered successfully",
"data": {
"user": {
"id": 1,
"name": "John Doe",
"username": "johndoe",
"email": "john@example.com"
},
"access_token": "1|abc123..."
}
}
Login to existing account
Request Body:
{
"email": "john@example.com",
"password": "password123"
}
Response (200):
{
"success": true,
"message": "Login successful",
"data": {
"user": {
"id": 1,
"name": "John Doe",
"username": "johndoe",
"email": "john@example.com"
},
"access_token": "2|xyz789..."
}
}
Logout from current session
Headers:
Authorization: Bearer {token}
Response (200):
{
"success": true,
"message": "Logout successful"
}
📝 Topics
Get all topics with pagination
Query Parameters:
page (optional): Page number for pagination
Response (200):
{
"success": true,
"data": {
"current_page": 1,
"data": [
{
"id": 1,
"title": "Laravel Best Practices",
"body": "What are the best practices...",
"user": {
"id": 1,
"name": "John Doe"
},
"category": {
"id": 1,
"name": "Laravel"
},
"comments_count": 5,
"likes_count": 10
}
],
"per_page": 20,
"total": 50
}
}
Create a new topic. Category will be created automatically if not exists.
Request Body:
{
"title": "Laravel Best Practices",
"body": "What are the best practices when using Laravel?",
"category_name": "Laravel"
}
Response (201):
{
"success": true,
"message": "Topic created successfully",
"data": {
"id": 1,
"title": "Laravel Best Practices",
"body": "What are the best practices...",
"user_id": 1,
"topic_category_id": 1
}
}
Get detailed information about a specific topic
Response (200):
{
"success": true,
"data": {
"id": 1,
"title": "Laravel Best Practices",
"body": "What are the best practices...",
"user": {...},
"category": {...},
"comments": [...],
"comments_count": 5,
"likes_count": 10
}
}
Update a topic. Only the owner can update their topic.
Request Body:
{
"title": "Updated Title",
"body": "Updated body content",
"category_name": "PHP"
}
Response (200):
{
"success": true,
"message": "Topic updated successfully",
"data": {...}
}
Delete a topic. Only the owner can delete their topic.
Response (200):
{
"success": true,
"message": "Topic deleted successfully"
}
💬 Comments
Get all comments for a specific topic
Response (200):
{
"success": true,
"data": {
"current_page": 1,
"data": [
{
"id": 1,
"topic_id": 1,
"user_id": 2,
"body": "Great question!",
"user": {
"id": 2,
"name": "Jane Doe"
}
}
]
}
}
Create a new comment on a topic
Request Body:
{
"body": "This is a great topic!"
}
Response (201):
{
"success": true,
"message": "Comment created successfully",
"data": {
"id": 1,
"topic_id": 1,
"body": "This is a great topic!",
"user": {...}
}
}
Update a comment. Only the owner can update their comment.
Request Body:
{
"body": "Updated comment text"
}
Delete a comment. Only the owner can delete their comment.
❤️ Likes
Toggle like/unlike on a topic
Response (200):
{
"success": true,
"message": "Topic liked successfully",
"data": {
"liked": true,
"likes_count": 11
}
}
Get list of users who liked a topic
Response (200):
{
"success": true,
"data": {
"data": [
{
"id": 2,
"name": "Jane Doe",
"username": "janedoe"
}
]
}
}
👥 Users
Search users by username, email, or name
Query Parameters:
query (required): Search term page (optional): Page number
Example:
GET /users/search?query=john
Get user profile with stats
Response (200):
{
"success": true,
"data": {
"id": 1,
"name": "John Doe",
"username": "johndoe",
"topics_count": 15,
"followers_count": 20,
"following_count": 10,
"is_following": false
}
}
Follow a user
Response (200):
{
"success": true,
"message": "User followed successfully"
}
Unfollow a user
Get list of user's followers
Get list of users that this user is following
📌 Important Notes
- All endpoints requiring authentication must include
Authorization: Bearer {token}header - Default pagination is 20 items per page
- Only topic/comment owners can update or delete their content
- Categories are automatically created when creating a topic
- Like endpoint uses toggle mechanism (same endpoint for like/unlike)
- Users cannot follow themselves
- Search excludes the currently logged-in user