Skip to content

'View Likes' Documentation

Onur Can AVCI edited this page Jun 13, 2021 · 4 revisions

Description

This API functionality views all the post likes of a given post id. The function for this endpoint is getLikes(postId), existing in the file likes.py. This functionality utilizes GET requests in our API.

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

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

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

example: http://localhost:5000/api/post/2/likes

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

  • 1
  • 2
  • 3
  • 4
  • 5

Parameters

Path Parameters

This parameter is specified in the URI route.

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

Responses

HTTP_200_OK -> Likes of the post are retrieved and returned as response successfully. Response contains liked informations which are date, post id and username.
  • Example Response

{
  "items": [
    {
      "date": "Sun, 13 Jun 2021 18:56:08 GMT",
      "postId": 1,
      "username": "onurcan"
    },
    {
      "date": "Sun, 13 Jun 2021 18:56:08 GMT",
      "postId": 1,
      "username": "merverabia"
    },
    {
      "date": "Sun, 13 Jun 2021 18:56:08 GMT",
      "postId": 1,
      "username": "atainan"
    }
  ],
  "totalCount": 3
}

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

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

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

HTTP_404_NOT_FOUND -> Post with given post id does not not liked before.
  • Example Response

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

{"error":"Post is not liked"}
Clone this wiki locally