Quora-like Application API Specification
Overview
This API provides functionalities for a Q&A platform that allows users to ask questions, answer
them, comment on answers, and engage through likes and follows, while organizing content via
topic tags. Each request involving user actions will require a userId to be provided explicitly.
API Endpoints
User Actions
POST /users
Description: Registers a new user.
Body:
username : string (required)
email : string (required)
Response: 201 - Created
Returns: User object with user details including the userId .
GET /users/{userId}
Description: Retrieves user profile information by user ID.
Response: 200 - OK
Returns: User profile data
PUT /users/{userId}
Description: Updates user profile.
Body:
username : string (optional)
email : string (optional)
bio : string (optional)
Response: 200 - OK
Returns: Updated user object
Question Management
POST /questions
Description: Allows a user to post a new question.
Body:
userId : UUID (required)
title : string (required)
body : string (required)
topicTags : array of strings (optional)
Response: 201 - Created
Returns: Question object
GET /questions/search
Description: Search questions based on text and tags.
Query Params:
text : string (optional)
tag : string (optional)
Response: 200 - OK
Returns: Array of matched question objects
Answer Management
POST /questions/{questionId}/answers
Description: Post an answer to a question.
Body:
userId : UUID (required)
text : string (required)
Response: 201 - Created
Returns: Answer object
PUT /answers/{answerId}
Description: Edit an existing answer.
Body:
text : string (required)
Response: 200 - OK
Returns: Updated answer object
Comment Management
POST /answers/{answerId}/comments
Description: Comment on an answer.
Body:
userId : UUID (required)
text : string (required)
Response: 201 - Created
Returns: Comment object
POST /comments/{commentId}/comments
Description: Comment on another comment.
Body:
userId : UUID (required)
text : string (required)
Response: 201 - Created
Returns: Comment object
Like Management
POST /{type}/{id}/likes
Description: Like a question, answer, or comment.
Path Params:
type : “questions”, “answers”, “comments”
id : UUID
Body:
userId : UUID (required)
Response: 201 - Created
Returns: Success message
Follow Management
POST /users/{userId}/follow/{targetUserId}
Description: Follow another user.
Path Params:
userId : UUID (submitter’s ID, required)
targetUserId : UUID (the user to be followed, required)
Response: 201 - Created
Returns: Success message
Topic Management
POST /topics
Description: Create a new topic.
Body:
name : string (required)
Response: 201 - Created
Returns: Topic object
GET /topics
Description: Retrieve all topics.
Response: 200 - OK
Returns: Array of topic objects
Data Models
User
id : UUID
username : string
email : string
bio : string (optional)
Question
id : UUID
title : string
body : string
topics : array of Topic IDs
created_at : timestamp
user_id : UUID
Answer
id : UUID
question_id : UUID
text : string
created_at : timestamp
user_id : UUID
Comment
id : UUID
parent_id :
UUID (ID of the answer or another comment)
text : string
created_at : timestamp
user_id : UUID
Topic
id : UUID
name : string
Response and Error Handling
Success Responses: Return appropriate HTTP status codes along with data (if any).
Error Responses: Use standard HTTP status codes with error messages explaining the issue.