Skip to content

Latest commit

 

History

History
1695 lines (1345 loc) · 20.5 KB

api-documentation.md

File metadata and controls

1695 lines (1345 loc) · 20.5 KB

API Documentation of SpeakUp

Auth

This section contains API requests related to user authentication and management.

Register User

POST /auth/register 
// Sample Response
{
  "success": true,
  "data": {
    "user": {
      "id": 263,
      "handle": "ankitbhusal200"
    },
    "refreshToken": "...",
    "accessToken": "..."
  }  
}

Register a new user account.

Login

POST /auth/login
// Sample Response
{
  "success": true,
  "data": {
    "user": {
      "id": 239,
      "handle": "itsankitbhusal"
    },
    "accessToken": "...",
    "refreshToken": "..."
  }
}

Login with existing username and password.

Get New Access Token

GET /auth/token
// Sample Response
{
  "success": true,
  "data": {
    "accessToken": "..."
  }
}

Get a new access token using refresh token.

Get All Users

GET /auth/users
// Sample Response
{
  "success": true,
  "data": [
    {
      "id": 91,
      "handle": "Iva_Funk51",
      "role": "user" 
    },
    {
      "id": 150, 
      "handle": "Janelle.Moore",
      "role": "user"
    }
  ]
}

Get details of all users.

Get User By Handle

GET /auth/user/{handle} 
// Sample Response
{
  "success": true,
  "data": {
    "id": 239,
    "handle": "itsankitbhusal",
    "role": "admin"
  }
}

Get user details by handle.

Get Logged In User

GET /auth/me
// Sample Response
{
  "success": true,
  "data": {
    "id": 38,
    "handle": "itsankitbhusal",
    "role": "admin"
  }
}

Get details of logged in user.

Delete User

DELETE /auth/user/{id}
// Sample Response
{
  "success": true,
  "data": 1 
}

Delete user by id.

Change Password

PUT /auth/user/reset
// Sample Response
{
  "success": true,
  "data": "Email sent" 
}

Change password of logged in user.

Get details of logged in user | for profile

GET /auth/me
// Same as Get Logged In User response  

Get details of logged in user for profile.

Upgrade user to admin

PUT /auth/{id}/admin
// Sample Response
{
  "success": true,
  "data": [1]
}

Upgrade normal user to admin.

Reset password link after verification

POST /auth/reset
// Sample Response
{
  "success": true,
  "data": "Email sent"
}

Send reset password link after email verification.

Reset user password

GET /auth/reset/{token}
// Sample Response
{
  "success": true,
  "data": {
    "user": {
      "id": 251,
      "handle": "manay"  
    },
    "accessToken": "...",
    "refreshToken": "..."
  }
}

Reset user password using token.

Comment

This section contains API requests related to comments.

Create Comment

POST /comment/{confessionId}
// Sample Response
{
  "success": true,
  "data": {
    "id": 11130,
    "body": "comment",
    "user_id": 239
  }
}

Create a comment on a confession.

Get Comment By Id

GET /comment/{id}  
// Sample Response
{
  "success": true,
  "data": {
    "id": 4,
    "body": "Comment body...",
    "user": {
      "handle": "username" 
    }
  }
}

Get a comment by id.

Update Comment

PUT /comment/{id}
// Sample Response
{
  "success": true,
  "data": [1] 
}

Update comment body.

Delete Comment

DELETE /comment/{id}
// Sample Response
{
  "success": true,
  "data": 1
}

Delete a comment.

Get Comments With Confession Id | Pagination

GET /comment/confession/{id}?page={page}&size={size}
// Sample Response
{
  "success": true,
  "data": {
    "count": 5,
    "rows": [
      {
        "id": 10301,
        "body": "Comment body...",
        "user": {
           "handle": "username"
        }
      },
      {
        "id": 4820,
        "body": "Comment body...",
         "user": {
           "handle": "username"  
         }
      }
    ]
  }
}

Get comments for a confession with pagination.

CommentVote

This section contains API requests related to commenting voting.

Create Comment Up Vote

POST /comment-vote/up/{commentId}
// Sample Response
{
  "success": true,
  "data": "Comment vote created successfully." 
}

Upvote a comment.

Create Comment Down Vote

POST /comment-vote/down/{commentId} 
// Sample Response 
{
  "success": true,
  "data": "Comment vote created successfully."
}

Downvote a comment.

Update Down-> Up Vote

PUT /comment-vote/up/{commentId}
// Sample Response
{
  "success": true,
  "data": "Comment vote updated successfully."
}

Update downvote to upvote for a comment.

Update Up -> Down Vote

PUT /comment-vote/down/{commentId} 
// Sample Response
{
  "success": true,
  "data": "Comment vote updated successfully."
} 

Update upvote to downvote for a comment.

Delete Up Vote

DELETE /comment-vote/up/{commentId} 
// Sample Response 
{
  "success": false,
  "message": "You cannot perform this action.",
  "status": 400
}

Delete upvote on a comment.

Delete Down Vote

DELETE /comment-vote/down/{commentId}
// Sample Response
{
  "success": true,
  "data": "Comment vote deleted successfully."
}

Delete downvote on a comment.

Get Comment Vote Count

GET /comment-vote/count/{commentId}
// Sample Response
{
  "success": true,
  "data": {
    "result": {
      "upvoteCount": 2,
      "downvoteCount": 1,
      "totalVoteCount": 1
    }
  }
}

Get upvote and downvote count for a comment.

Get Comment Vote By User Id For Comment

GET /comment-vote/comment/{commentId}
// Sample Response
{
  "success": true,
  "data": {
    "id": 21020,
    "user_id": 239,
    "comment_id": 11131,
    "vote_type": "up",
    "user": {
      "handle": "itsankitbhusal"
    }
  }
}

Get comment vote by logged in user for a comment.

Confession

This section contains API requests related to confessions.

Get All Confessions

GET /confession/?limit={limit}&page={page}
// Sample Response
{
  "success": true,
  "data": {
    "confessions": [
      {
        "id": 1332,
        "title": "Confession Title",
        "user": {
          "handle": "username"
        }
      },
      {
        "id": 72,
        "title": "Confession Title",
        "user": {
          "handle": "username"
        }
     }
    ],
    "page": 0,
    "limit": 10 
  }
}

Get all confessions with pagination.

Create Confession

POST /confession
// Sample Response
{
  "success": true,
  "data": {
    "id": 1333,
    "title": "Confession Title",
    "body": "Confession body...",
    "user_id": 239
  }
} 

Create a new confession.

Get Confession By Id

GET /confession/{id}
// Sample Response
{
  "success": true,
  "data": {
    "id": 2,
    "title": "Confession Title", 
    "body": "Confession body...",
    "user": {
      "handle": "username" 
    }
  }
}

Get a confession by id.

Update Confession

PUT /confession/{id}
// Sample Response
{
  "success": true,
  "data": [1]
}

Update confession title and body.

Delete Confession

DELETE /confession/{id}
// Sample Response
{
  "success": true,
  "data": 1
}

Delete a confession.

Approve

PUT /confession/{id}/approve
// Sample Response
{
  "success": true,
  "data": [1] 
}

Approve a pending confession.

Pending Confessions

GET /confession/pending
// Sample Response
{
  "success": true,
  "data": {
    "confessions": [
      {
        "id": 8,
        "title": "Pending Confession",
        "user": {
          "handle": "username" 
        }
      }
    ]
  }
}

Get all pending confessions.

Get All Confessions By User Id Or Logged In User

POST /confession/user/{userId} 
// Sample Response
{
  "success": true,
  "data": {
    "confessions": [
      {
        "id": 31,
        "title": "My Confession",
        "user": {
          "handle": "itsankitbhusal"
        }
      } 
    ]
  }
}

Get confessions by user id or logged in user if not provided.

Get Confession By Handle

POST /confession/user/handle/{handle}
// Sample Response
{
  "success": true,
  "data": {
    "confessions": [
      {
        "id": 1298,
        "title": "Confession Title",
        "user": {
          "handle": "username"
        }
      }
    ]
  }
}

Get confessions by user handle.

Search Confession By Title

GET /confession/search?title={title} 
// Sample Response
{
  "success": true,
  "data": {
    "confessions": [
      {
        "id": 1304,
        "title": "Matching Confession",
        "user": {
          "handle": "username"
        }
      }
    ]
  }
}

Search confessions by title.

ConfessionTag

This section contains API requests related to confession tags.

Create Confession Tag

POST /confession-tag/{confessionId}/{tagId} 
// Sample Response
{
  "success": true,
  "data": {
    "confession_id": "675",
    "tag_id": "111" 
  }
}

Create a confession tag.

Delete Confession Tag

DELETE /confession-tag/{confessionId}/{tagId}  
// Sample Response
{
  "success": true,
  "data": "Delete confession tag successfully"
}

Delete a confession tag.

Get Tags From Confession Id

GET /confession-tag/{confessionId}
// Sample Response
{
  "success": true,
  "data": [
    {
      "tag": {
        "name": "tag1"
      }
    },
    {
      "tag": { 
        "name": "tag2"
      }
    }
  ]
}

Get tags for a confession.

Get Confessions Related To Tags

GET /confession-tag/tag/{tagId}
// Sample Response
{
  "success": true,
  "data": [
    {
      "confession": {
        "title": "Related Confession",
        "user": {
          "handle": "username"
        }
      }
    }
  ]
}

Get confessions related to a tag.

ConfessionVote

This section contains API requests related to confession voting.

Upvote

POST /confession-vote/up/{confessionId}
// Sample Response
{
  "success": true,
  "data": "Confession vote created successfully."
}

Upvote a confession.

Down Vote

POST /confession-vote/down/{confessionId}  
// Sample Response
{
  "success": true,
  "data": "Confession vote created successfully."
}

Downvote a confession.

Update Vote Up

PUT /confession-vote/up/{confessionId}
// Sample Response
{
  "success": true,
  "data": "Confession vote updated successfully."
}

Update downvote to upvote for a confession.

Update Up -> Down Vote

PUT /confession-vote/down/{confessionId}
// Sample Response
{
  "success": true,
  "data": "Confession vote updated successfully."
}

Update upvote to downvote for a confession.

Delete Down Vote

DELETE /confession-vote/down/{confessionId} 
// Sample Response
{
  "success": true,
  "data": "Confession vote deleted successfully."
} 

Delete downvote on a confession.

Delete Up Vote

DELETE /confession-vote/up/{confessionId}
// Sample Response  
{
  "success": true,
  "data": "Confession vote deleted successfully." 
}

Delete upvote on a confession.

Get All Confession Votes

GET /confession-vote/
// Sample Response
{
  "success": true,
  "data": [
    {
      "id": 1,
      "confession_id": 304,
      "user": {
        "handle": "username" 
      }
    },
    {
      "id": 23266,
      "confession_id": 222,
      "user": {
        "handle": "username"
      }
    }
  ]
}

Get all confession votes.

Get Confession By Logged In User Or Logged In If Not Provided Id

GET /confession-vote/user/{userId}
// Sample Response
{
  "success": true,
  "data": [
    {
      "id": 23239,
      "confession_id": 909, 
      "user": {
        "handle": "itsankitbhusal"
      }
    }
  ]
}

Get confession votes by user id or logged in user.

Get Confession Vote With Confession Id

GET /confession-vote/confession/{confessionId} 
// Sample Response
{
  "success": true,
  "data": {
    "id": 23264,
    "confession_id": 1331,
    "vote_type": "down",
    "user": {
      "handle": "itsankitbhusal"
    }
  }
}

Get confession vote for a confession.

Get Confession Votes Count

GET {{url}}/confession-vote/count/1331
// sample response
{
    "success": true,
    "data": {
        "result": {
            "totalVoteCount": 3,
            "downvoteCount": 1,
            "upvoteCount": 4
        }
    }
}

Here are the remaining sections of the complete markdown documentation for the SpeakUp Postman collection:

Notification

This section contains API requests related to user notifications.

Create Notification

POST /notification
// Sample Response
{
  "success": true,
  "data": {
    "id": 12,
    "message": "Notification message"
  }
}

Create a notification.

Get All Notifications By User Id

GET /notification/user/{userId}
// Sample Response
{
  "success": true,
  "data": [
    {
      "id": 25,
      "message": "Notification message" 
    }
  ]
}

Get notifications for a user.

Get Notification By Id

GET /notification/{id}
// Sample Response
{
  "success": true,
  "data": {
    "id": 4,
    "message": "Notification message"
  }
}

Get a notification.

Update Notification Status

PUT /notification/{id}
// Sample Response
{
  "success": true,
  "data": "Notification updated successfully"
}

Mark notification as read.

Delete Notification

DELETE /notification/{id}
// Sample Response
{
  "success": true,
  "data": "Notification deleted successfully"
}

Delete a notification.

Reporting

This section contains API requests related to reporting confessions and comments.

Create Confession/Comment Report

POST /reporting 
// Sample Response
{
  "success": true,
  "data": {
    "id": 118,
    "reporter_id": 239,
    "reported_object_type": "confession"
  }
}

Report a confession or comment.

Get All Reporting

GET /reporting
// Sample Response
{
  "success": true,
  "data": [
    {
      "id": 118,
      "reporter_id": 239,
      "reported_object_type": "confession"
    }
  ]
} 

Get all reports.

Get Reporting By Id

GET /reporting/{id}
// Sample Response
{
  "success": true,
  "data": {
    "id": 8,
    "reporter_id": 219,
    "reported_object_type": "confession" 
  }
}

Get a report.

Delete Reporting By Id

DELETE /reporting/{id} 
// Sample Response
{
  "success": true,
  "data": 1
}

Delete a report.

Update Reporting Id

PUT /reporting/{id}
// Sample Response  
{
  "success": true,
  "data": [1] 
}

Update a report.

Get Reporting By Reporter

GET /reporting/user/{userId}
// Sample Response
{
  "success": true,
  "data": [
    {
      "id": 15,
      "reporter_id": 79,
      "reported_object_type": "comment"
    }
  ]
}

Get reports by a user.

Get By Reporting Object Type

GET /reporting/object/{type} 
// Sample Response
{
  "success": true,
  "data": [
    {
      "id": 15,
      "reported_object_type": "comment" 
    }
  ]
}

Get reports by object type - confession or comment.

Get Reporting By Resolved Status

GET /reporting/resolved/{boolean} 
// Sample Response
{
  "success": true,
  "data": [
    {
      "id": 1,
      "is_resolved": true 
    }
  ]
}

Get reports by resolved status.

Resolve Comment

PUT /reporting/resolve/comment/{id}  
// Sample Response
{
  "success": true,
  "data": [1]
}

Resolve a comment report.

Resolve Confession

PUT /reporting/resolve/confession/{id}
// Sample Response
{
  "success": true,
  "data": [1]  
}

Resolve a confession report.

Tag

This section contains API requests related to managing tags.

Get All Tags

GET /tag  
// Sample Response
{
  "success": true,
  "data": [
    {
      "id": 51,
      "name": "tag1"
    },
    {
      "id": 118, 
      "name": "tag2"
    }
  ]
}

Get all tags.

Create Tag

POST /tag
// Sample Response
{
  "success": true,
  "data": {
    "id": 119,
    "name": "newtag"
  }
}

Create a new tag.

Get Tag With Id

GET /tag/{id}
// Sample Response
{
  "success": true,
  "data": {
    "id": 1,
    "name": "tag"
  }
}

Get a tag.

Update Tag

PUT /tag/{id}
// Sample Response
{
  "success": true,
  "data": [1] 
}

Update tag name.

Delete Tag

DELETE /tag/{id}   
// Sample Response 
{
  "success": true,
  "data": "Tag deleted successfully"
}

Delete a tag.

Search Tags

GET /tag/search?name={name}
// Sample Response
{
  "success": true,
  "data": [
    {
      "id": 11,
      "name": "matchingtag"
    }
  ]
}

Search tags by name.

View

This section contains API requests related to confession views.

Create View

POST /view/{confessionId}  
// Sample Response
{
  "success": true,
  "data": [
    {
      "id": 201207,
      "confession_id": "6" 
    },
    true
  ]
} 

Create a view on a confession.

Get All Views By Confession Id

GET /view/{confessionId} 
// Sample Response
{
  "success": true,
  "data": [
    {
      "id": 433,
      "confession_id": 6 
    },
    {
      "id": 201207,
      "confession_id": 6
    }
  ]
}

Get views on a confession.

Get Total View Count By Confession Id

GET /view/count/{confessionId}  
// Sample Response
{
  "success": true,
  "data": 139
}

Get total views on a confession.

Get All Views By User Id

GET /view/user/{userId}
// Sample Response  
{
  "success": true,
  "data": [
    {
      "id": 422,
      "confession_id": 263,
      "user_id": 38
    }
  ]
}

Get views by a user.

Delete View By Id

DELETE /view/{id}
// Sample Response
{
  "success": true,
  "data": "View deleted successfully" 
}

Delete a view.

Get If Logged In User Has Viewed Confession

GET /view/user/confession/{confessionId} 
// Sample Response
{
  "success": true,
  "data": {
    "id": 200683,
    "confession_id": 1331,
    "user_id": 239
  }
}

Check if logged in user has viewed a confession.

Analytics

This section contains API requests related to analytics.

User Growth Rate Of 12 Weeks

GET /analytics/growth-rate
// Sample Response
{
  "success": true,
  "data": {
    "growthRate": [0, 1, 2, 3] 
  }
}

Get user growth rate for last 12 weeks.

User Role Distribution

GET /analytics/roles  
// Sample Response
{
  "success": true,
  "data": [
    {
      "role": "admin",
      "count": 5 
    },
    {
      "role": "user",
      "count": 10
    }
  ]
}

Get count of users by roles.

User Verification Distribution

GET /analytics/verification
// Sample Response
{
  "success": true,
  "data": [
    {
      "is_verified": false,
      "count": 20
    },
    {
      "is_verified": true, 
      "count": 10
    }
  ]
} 

Get count of verified and unverified users.

Confession Approval

GET /analytics/confession-approval 
// Sample Response
{
  "success": true,
  "data": [
    {
      "is_approved": false,
      "count": 10 
    },
    {
      "is_approved": true,
      "count": 20
    }
  ]
}

Get count of approved and pending confessions.

Up Down Count Of 12 Weeks

GET /analytics/up-down
// Sample Response
{
  "success": true,
  "data": {
    "upVoteCount": [1,2,3],
    "downVoteCount": [3,2,1]
  }
}

Get upvote and downvote count over 12 weeks.

Recommendation

This section contains API request related to getting confession recommendations.

GET /recommendation
// Sample Response
{
  "success": true,
  "data": [
    {
      "id": 1298,
      "title": "Recommended Confession" 
    },
    {  
      "id": 945,
      "title": "Another Recommended Confession"
    }
  ]
}