Social Media
A Social Media is a web app that connects users and enables to share their content to the web similar to what Twitter and Instagram does. This API has features such as create post, react to posts, view and update user details, follow other users , bookmark your favourite posts, etc.
#
Auth RoutesIn Social Media App
, the authentication is done with username
and password
credential fields.
You can refer documentation related to Authentication here
#
User RoutesThe following Routes are Public Routes related to User.
/api/users
#
1. GET Request URL:
/api/users
HTTP Method: GET
Response Body:
{ data: { users: Array; }}
Functionality: This API call gets all users in the db.
/api/users/:userId
#
2. GET Request URL:
/api/users/:userId
HTTP Method: GET
Response Body:
{ data: { user: Object; }}
Functionality: This API call gets a user from the db.
The following Routes are Private Routes related to User.
/api/users/edit
#
3. POST Request URL:
/api/users/edit
HTTP Method: POST
Request Headers:
authorization: encodedToken
Request Body:
{ userData;}
Response Body:
{ data: { user: Object; }}
Functionality: This API call is responsible for editing details of the user.
#
Post RoutesThe following Routes are relating to Posts. These are Publicly accessible routes.
/api/posts
#
1. GET Request URL:
/api/posts
HTTP Method: GET
Response Body:
{ data: { posts: Array; }}
Functionality: This API call gets all posts from the db.
/api/posts/:postId
#
2. GET Request URL:
/api/posts/:postId
HTTP Method: GET
Response Body:
{ data: { post: Object; }}
Functionality: This API call gets post by postId from the db.
/api/posts/user/:username
#
3. GET Request URL:
/api/posts/user/:username
HTTP Method: GET
Response Body:
{ data: { posts: Array; }}
Functionality: This API call gets posts by username from the db.
The following Routes are Private Routes related to Posts.
/api/posts
#
4. POST Request URL:
/api/posts
HTTP Method: POST
Request Headers:
authorization: encodedToken
Request Body:
{ postData: post;}
Response Body:
{ data: { posts: Array; }}
Functionality: This API call creates a new post to the user's db.
/api/posts/:postId
#
5. DELETE Request URL:
/api/posts/:postId
HTTP Method: DELETE
Request Headers:
authorization: encodedToken
Response Body:
{ data: { posts: Array; }}
Functionality: This API call deletes a post from the user's db.
/api/posts/edit/:postId
#
6. POST Request URL:
/api/posts/edit/:postId
HTTP Method: POST
Request Headers:
authorization: encodedToken
Request Body:
{ postData;}
Response Body:
{ data: { posts: Array; }}
Functionality: This API call edits a post of the user.
#
Like/Dislike Post RoutesThe following Routes are Private Routes related to Liking and Disliking Posts.
/api/posts/like/:postId
#
1. POST Request URL:
/api/posts/like/:postId
HTTP Method: POST
Request Headers:
authorization: encodedToken
Request Body: {}
Response Body:
{ data: { posts: Array; }}
Functionality: This API call likes a post of the user.
/api/posts/dislike/:postId
#
2. POST Request URL:
/api/posts/dislike/:postId
HTTP Method: POST
Request Headers:
authorization: encodedToken
Request Body: {}
Response Body:
{ data: { posts: Array; }}
Functionality: This API call dislikes/unlikes a liked post of the user.
#
Bookmark RoutesThe following Routes are Private Routes related to Bookmarking Posts of User.
/api/users/bookmark/:postId
#
1. POST Request URL:
/api/users/bookmark/:postId
HTTP Method: POST
Request Headers:
authorization: encodedToken
Request Body: {}
Response Body:
{ data: { bookmarks: Array; }}
Functionality: This API call adds a post to user bookmarks.
/api/users/remove-bookmark/:postId
#
2. POST Request URL:
/api/users/remove-bookmark/:postId
HTTP Method: POST
Request Headers:
authorization: encodedToken
Request Body: {}
Response Body:
{ data: { bookmarks: Array; }}
Functionality: This API call removes a post from user bookmarks.
/api/users/bookmark
#
3. GET Request URL:
/api/users/bookmark/
HTTP Method: GET
Request Headers:
authorization: encodedToken
Response Body:
{ data: { bookmarks: Array; }}
Functionality: This API call gets all user bookmarked posts from the db.
#
Follow/Unfollow RoutesThe following Routes are Private Routes related to Follow/Unfollow action of User.
/api/users/follow/:followUserId
#
1. POST Request URL:
/api/users/follow/:followUserId
HTTP Method: POST
Request Headers:
authorization: encodedToken
Request Body: {}
Response Body:
{ data: { user: Object, followUser: Object }}
Functionality: This API call is responsible for follow action by the user.
/api/users/unfollow/:followUserId
#
2. POST Request URL:
/api/users/unfollow/:followUserId
HTTP Method: POST
Request Headers:
authorization: encodedToken
Request Body: {}
Response Body:
{ data: { user: Object, followUser: Object }}
Functionality: This API call is responsible for unfollow action by the user.