Friends API
Manage friend relationships. The backend uses api/Friendship for friend requests and lists, and api/friends for friend search.
Endpoints
Get friends
GET /api/Friendship/friends?page=1&pageSize=20
Authentication: Required
Send friend request
POST /api/Friendship/send-request
Content-Type: application/json
{ "toUserId": "user-guid", "message": "Optional message" }
Accept friend request
POST /api/Friendship/accept-request
Content-Type: application/json
{ "friendshipId": 123 }
Decline friend request
POST /api/Friendship/decline-request
Content-Type: application/json
{ "friendshipId": 123 }
Unfriend
POST /api/Friendship/unfriend
Content-Type: application/json
{ "userId2": "user-guid" }
Get pending requests
GET /api/Friendship/pending-requests?page=1&pageSize=20
Get mutual friends
GET /api/Friendship/mutual-friends?userId2={user-guid}&limit=10
Get friend suggestions
GET /api/Friendship/suggestions?limit=20
Get relationship status
GET /api/Friendship/relationship-status?userId2={user-guid}
Block / unblock
POST /api/Friendship/block
POST /api/Friendship/unblock
Content-Type: application/json
{ "toUserId": "user-guid" }
Friend search (api/friends)
GET /api/friends/search?q=...&page=1&pageSize=20
Authentication: Required
Response (friends list)
{
"success": true,
"message": "Friends retrieved successfully",
"data": {
"items": [
{
"id": "user-guid",
"userName": "johndoe",
"firstName": "John",
"lastName": "Doe",
"avatarUrl": "https://...",
"createdAt": "2024-01-01T00:00:00Z",
"lastActiveAt": "2024-01-15T10:00:00Z",
"isActive": true,
"location": "New York, USA"
}
],
"totalCount": 150,
"page": 1,
"pageSize": 20,
"totalPages": 8
}
}