-
Notifications
You must be signed in to change notification settings - Fork 0
API Design
Create a new user account in the system.
{
"username": "string (required, 3-30 chars)"
}Success (201 Created)
{
"user_id": 12345,
"username": "alice_smith",
"created_at": "2024-01-15T10:30:00Z"
}Error (400 Bad Request)
{
"error": "Username already exists"
}Retrieve a list of all users in the system.
GET /api/users
Success (200 OK)
{
"users": [
{
"user_id": "12345",
"username": "alice_smith",
"created_at": "2024-01-15T10:30:00Z"
},
{
"user_id": "12346",
"username": "bob_jones",
"created_at": "2024-01-14T09:15:00Z"
}
],
"total_count": 25000
}Create a follow relationship between two users.
{
"follower_user_id": "12345",
"target_user_id": "12346",
"action": "follow"
}Success (201 Created) 201 Created
{
"follower_id": 12345,
"following_id": 12346,
"created_at": "2024-01-15T11:45:00Z"
}400 Bad Request
{
"error": "Cannot follow yourself"
}409 Conflict
{
"error": "Already following this user"
}Error (400 Bad Request)
{
"success": false,
"error": "Cannot follow yourself",
"error_code": "SELF_FOLLOW_NOT_ALLOWED"
}Error (409 Conflict)
{
"success": false,
"error": "Already following this user",
"error_code": "ALREADY_FOLLOWING"
}Get user's followers list
GET /api/{user_id}/followers
GET /api/12345/followers?limit=50
Success (200 OK)
{
"followers": [
{
"user_id": 101,
"username": "happy_runner_456"
},
{
"user_id": 102,
"username": "creative_builder_789"
}
],
"total_count": 150,
"next_cursor": "eyJsYXN0X2lkIjoxMDJ9",
"has_more": true
}Error (404 Not Found)
{
"error": "User not found",
"error_code": "USER_NOT_FOUND"
}Error (500 Internal Server Error)
{
"error": "Failed to get followers",
"error_code": "INTERNAL_ERROR"
}Get user's following list
GET /api/{user_id}/following
GET /api/12345/following?limit=50
Success (200 OK)
{
"following": [
{
"user_id": 201,
"username": "brilliant_artist_111"
},
{
"user_id": 202,
"username": "super_developer_222"
},
{
"user_id": 203,
"username": "excellent_designer_333"
}
],
"total_count": 75,
"next_cursor": "eyJsYXN0X2lkIjoyMDN9",
"has_more": true
}Error (404 Not Found)
{
"error": "User not found",
"error_code": "USER_NOT_FOUND"
}Error (500 Internal Server Error)
{
"error": "Failed to get following",
"error_code": "INTERNAL_ERROR"
}Create a new post and trigger fan-out to followers' timelines.
{
"user_id": 123456,
"content": "string (required, 1-280 chars)",
"visibility": "public|private (optional, default: public)"
}Success (201 Created)
{
"post_id": "post_789",
"user_id": 12345,
"content": "Beautiful sunset today! π
",
"created_at": "2024-01-15T18:30:00Z"
}Error (400 Bad Request)
{
"error": "Content cannot be empty"
}Retrieve the timeline for a specific user (posts from users they follow).
-
user_id(required): ID of the user whose timeline to fetch
Success (200 OK)
{
"timeline": [
{
"post_id": "post_789",
"user_id": 12346,
"username": "bob_jones",
"content": "Just finished a great workout! πͺ",
"created_at": "2024-01-15T17:45:00Z"
},
{
"post_id": "post_790",
"user_id": 12345,
"username": "alice_smith",
"content": "Working on an exciting new project",
"created_at": "2024-01-15T16:30:00Z"
}
],
"total_count": 156
}Error (404 Not Found)
{
"error": "User not found"
}