Social
One of the more fundamental features in apps these days is the social feature - from adding a chat app feature to an existing app, to sharing information with your social circle, the Social API helps you quickly bootstrap friends feature so you can build your chat app, or new social media platform on that.
Get Friends
To retrieve the existing list of friends for a provided service-user token, make a GET request with the token to the endpoint below. This feature is especially useful when you want to display a friends or contacts list.
fetch('https://api.opencider.com/user/social/friends?token=service_user_token');
Add Friends
Open Cider makes it possible for users to form new connections from any app - meaning users' connections matter. The API is also implemented in a way where your service can interact with it like it is one of your micro-services. This approach allows services to add users from friend requests (which would typically be called first) as directed by the users.
fetch('https://api.opencider.com/user/social/friends/add', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
'friendId': 'a valid friend request user id',
'token': 'service_user_token'
})
});
Remove Friend
It is also possible to remove people from the friends list on behalf of the user. Here, we send this request from a valid friends list as specified by the user. As with every action on behalf of the user, it is recorded in an immutable blockchain-style format to prevent tampering and promote transparency and trust between your service and its users.
fetch('https://api.opencider.com/user/social/friends/remove', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
'friendId': 'a valid friend request user id',
'token': 'service_user_token'
})
});
Block Friend
Should a user decide they no longer wish to interact with a friend, they can summon the block function to remove and block them from being seen. This function is accessible via a simple POST call that includes the service user token and the friend id. Hint: you can view blocked friends by using the Get Friends call.
fetch('https://api.opencider.com/user/social/friends/block', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
'friendId': 'a valid friend request user id',
'token': 'service_user_token'
})
});
Unblock Friend
If a user decides to unblock a blocked friend, they can simply do so by instigating a call to this POST request that simply contains the blocked friend's id (as retrieved from the Get Friends endpoint), and the service user token.
fetch('https://api.opencider.com/user/social/friends/unblock', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
'friendId': 'a valid friend request user id',
'token': 'service_user_token'
})
});
Friend Requests
You can also integrate friend requests into your application. Here users can send friend requests (see Add Friend), view friend requests sent to them, and action those requests. With this, you can easily build a fully fledged social network with little to no extra work.
List Friend Requests
This request gets the list of friend requests that have been sent to the specified user.
fetch('https://api.opencider.com/user/social/friends/request?token=service_user_token');
Update Friend Request
The update friend request API is used when a user wants to take action on any of their received friend requests. It allows you to carry out a few actions on the request using the following keywords: 'Accept' for when you are accepting the friend request, 'Remove' for when you are rejecting the friend request, and, 'Block' for when you want to guarantee the request is not re-sent at a later point.
fetch('https://api.opencider.com/user/social/friends/request', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
'personId': 'valid_id_of_request_initiator',
'status': 'Accept',
'token': 'service_user_token'
})
});
Search People
The Social API also makes it convenient to find people on the platform using various search methods. This can be a useful feature to incorporate when building a social platform. Think of how you search for users on platforms like X (formerly "Twitter"), or Instagram. You're able to access this functionality with an API call. We've sectioned the search function into two types namely:
Search by Ids
You might need to get the profile info for data stored by different user accounts and you only have the ids available. This endpoint makes it possible for you to populate the user accounts with their details in such scenario. This call will consist of two parameters namely the ids, which is an array of the required user. The maximum permitted ids per request is 100 ids which should return 100 users. In case, duplicate ids are sent, it automatically picks out the unique ids and returns the profiles for those.
fetch('https://api.opencider.com/user/social/people/find', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
'ids': [
'valid_user_id'
],
'token': 'service_user_token'
})
});
Search by Query
This is the more familiar approach. Here users may type in a username into the search bar and you need to fetch the results of the typed query. It is a simple GET request with two parameters - the service user token, and the username queried. The specified username in this case must be of length equal to or greater than 3 to achieve a successful response. Also, the only accepted characters are letters and digits. It returns a list of users matching the query.
fetch('https://api.opencider.com/user/social/people/search?' + new URLSearchParams({
token: 'service_user_token',
q: 'John',
}).toString())
Last updated