Skip to content

'Like Post' Documentation

Onur Can AVCI edited this page Jun 13, 2021 · 1 revision

Description

This API functionality likes the post likes of a given post id. The function for this endpoint is likePost(postId, username), existing in the file likes.py. This functionality utilizes POST requests in our API. It takes username and post id as a path parameter. It inserts the liked informations to likes database and update the number of likes field in posts database.

The URI of the API

If you try this API in our AWS EC2 instance,use
http://ec2-35-158-103-6.eu-central-1.compute.amazonaws.com:5000/api/post/{postId}/likes/{username}

example: http://ec2-35-158-103-6.eu-central-1.compute.amazonaws.com:5000/api/post/5/likes/onurcanavci

If you try this API on our local machine, use
http://localhost:5000/api/post/{postId}/likes/{username}

example: http://localhost:5000/api/post/5/likes/onurcanavci

Note that this functionality works only with GET requests. To test this API, you can use the following valid post ids and username (postId, username):

  • 1, onurcanavci
  • 2, atainan
  • 3, onurcanavci
  • 4, ryan

Parameters

Path Parameters

These parameters are taken in the URL.

postId -> post id of the post which user willing to see post likes

username -> username of the likes post which user willing to like post

Responses

HTTP_200_OK -> Returns ‘Post liked Successfully’ indicating that the post liked successfully.
  • Example Response

{
  message: "Post liked successfully",
  status: 200
}

HTTP_200_OK -> Returns ‘Like is reverted’ indicating that the post like reverted successfully.
  • Example Response

{
  message: "Like is reverted",
  status: 200
}

HTTP_404_NOT_FOUND -> Post with given post id does not found in the post database.
  • Example Response

{
  "error": "Post is not found"
}

{"error":"Post is not found"}

HTTP_404_NOT_FOUND -> User with given username does not found in user database.
  • Example Response

{
  "error": "User is not found"
}

{"error":"User is not found"}
Clone this wiki locally