Skip to content

Latest commit

 

History

History
165 lines (128 loc) · 3.19 KB

like-service-api-spec.md

File metadata and controls

165 lines (128 loc) · 3.19 KB

Mini Twitter API Documentation (Like Service)

Welcome to the Mini Twitter API documentation. This guide provides a comprehensive overview of the available API endpoints for the Like Service, including detailed descriptions, example requests, and responses.

Like a Post

Endpoint: POST /api/posts/{postId}/like

Description: Likes a specific post.

Request Parameters::

  • postId (Path Parameter): The unique identifier of the post to be liked.

Response Body (Success):

{
  "message": "Post liked successfully."
}

Response Body (Failed):

{
  "errors": "You have already liked this post."
}
Unlike a Post

Endpoint: DELETE /api/posts/{postId}/like

Description: Unlikes a specific post.

Request Parameters::

  • postId (Path Parameter): The unique identifier of the post to be unliked.

Response Body (Success):

{
  "message": "Post unliked successfully."
}

Response Body (Failed):

{
  "errors": "You have not liked this post."
}
Like a Comment

Endpoint: POST /api/comments/{commentId}/like

Description: Likes a specific comment.

Request Parameters::

  • commentId (Path Parameter): The unique identifier of the comment to be liked.

Response Body (Success):

{
  "message": "Comment liked successfully."
}

Response Body (Failed):

{
  "errors": "You have already liked this comment."
}
Unlike a Comment

Endpoint: DELETE /api/comments/{commentId}/like

Description: Unlikes a specific comment.

Request Parameters::

  • commentId (Path Parameter): The unique identifier of the comment to be unliked.

Response Body (Success):

{
  "message": "Comment unliked successfully."
}

Response Body (Failed):

{
  "errors": "You have not liked this comment."
}
Fetch the Number of Likes on a Post

Endpoint: GET /api/posts/{postId}/likes

Description: Fetches the total number of likes on a specific post.

Request Parameters::

  • postId (Path Parameter): The unique identifier of the post to fetch the number of likes for.

Response Body (Success):

{
  "data": {
    "postId": "post-123",
    "likeCount": 25
  }
}

Response Body (Failed):

{
  "errors": "Post not found."
}
Fetch the Number of Likes on a Comment

Endpoint: GET /api/comments/{commentId}/likes

Description: Fetches the total number of likes on a specific comment.

Request Parameters:

  • commentId (Path Parameter): The unique identifier of the comment to fetch the number of likes for.

Response Body (Success):

{
  "data": {
    "commentId": "comment-456",
    "likeCount": 10
  }
}

Response Body (Failed):

{
  "errors": "Comment not found."
}