📘
Blog API
  • Documentation
  • API References
  • Root
  • Authentication
  • Users
  • Blogs
  • Likes
  • Comments
  • Models
Powered by GitBook

© 2025 codewithsadee

On this page

Was this helpful?

Export as PDF

Comments

PreviousLikesNextModels

Was this helpful?

Comment management

Delete Comment

delete

Deletes a specific comment. Requires user to be author or admin. Decrements comments count.

Authorizations
Path parameters
commentIdstring · objectidRequired

ID of the comment.

Responses
204
Request successful, no response body.
401
Authentication information is missing or invalid (e.g., missing/expired token).
application/json
403
Access denied due to insufficient permissions.
application/json
404
The specified resource was not found.
application/json
500
An unexpected error occurred on the server.
application/json
delete
DELETE /api/v1/comments/{commentId} HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Accept: */*

No content

  • GETGet Comments by Blog
  • POSTCreate Comment
  • DELETEDelete Comment

Get Comments by Blog

get

Retrieves all comments associated with a specific blog post.

Authorizations
Path parameters
blogIdstring · objectidRequired

ID of the blog post.

Responses
200
A list of comments for the blog.
application/json
401
Authentication information is missing or invalid (e.g., missing/expired token).
application/json
404
The specified resource was not found.
application/json
500
An unexpected error occurred on the server.
application/json
get
GET /api/v1/comments/blog/{blogId} HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Accept: */*
{
  "comments": [
    {
      "_id": "text",
      "blogId": "text",
      "userId": "text",
      "content": "text",
      "likesCount": 0,
      "createdAt": "2025-06-07T13:13:26.275Z",
      "updatedAt": "2025-06-07T13:13:26.275Z"
    }
  ]
}

Create Comment

post

Adds a new comment to a specific blog post. Increments comments count.

Authorizations
Path parameters
blogIdstring · objectidRequired

ID of the blog post.

Body
contentstring · max: 1000Required

The comment text

Responses
201
Comment created successfully.
application/json
400
Invalid input data provided. See errors object for details.
application/json
401
Authentication information is missing or invalid (e.g., missing/expired token).
application/json
404
The specified resource was not found.
application/json
500
An unexpected error occurred on the server.
application/json
post
POST /api/v1/comments/blog/{blogId} HTTP/1.1
Host: blog-api.codewithsadee.com
Authorization: Bearer JWT
Content-Type: application/json
Accept: */*
Content-Length: 18

{
  "content": "text"
}
{
  "comment": {
    "_id": "text",
    "blogId": "text",
    "userId": "text",
    "content": "text",
    "likesCount": 0,
    "createdAt": "2025-06-07T13:13:26.275Z",
    "updatedAt": "2025-06-07T13:13:26.275Z"
  }
}