The User Connections API provides endpoints to fetch mutual followers between users and to suggest new users to follow based on various criteria.
Note: Ensure that all API requests include a valid JSON Web Token (JWT) in the x-token
header to authenticate users.
Retrieve mutual followers between the current user and another user specified by :id
.
Request Headers:
x-token: <JWT>
Response:
{
"mutualFollowers": [
{
"_id": "userId",
"firstName": "John",
"lastName": "Doe",
"profileImage": "imageUrl"
}
]
}
Retrieve a list of suggested users for the current user. These suggestions are based on mutual followers, follower count, and other criteria.
Request Headers:
x-token: <JWT>
Query Parameters:
page: <number> (optional, defaults to 1)
limit: <number> (optional, defaults to 10)
Response:
{
"suggestedUsers": [
{
"_id": "userId",
"firstName": "Jane",
"lastName": "Smith",
"profileImage": "imageUrl",
"followingCount": 15,
"followersCount": 20,
"mutualFollowers": 5
}
],
"currentPage": 1,
"totalPages": 3,
"totalUsers": 30,
"limit": 10
}
In case of errors, the API will return appropriate HTTP status codes and error messages. Common errors include 404 (User not found) and 500 (Server error). Handle these errors in the frontend to provide a smooth user experience.
Note: Ensure proper error handling in your application to manage scenarios like user not found, server errors, and unauthorized requests.