Comments

Comments are collection of comment. On this page, we'll dive into the different comment endpoints you can use to manage comments programmatically. We'll look at how to query, comments.

The comment model

The comment model contains all the information about your comments, including tags, the comment's name, description, and avatar.

Properties

  • Name
    id
    Type
    string
    Description

    Unique identifier for the comment.

  • Name
    publication_id
    Type
    number
    Description

    The id of the publication.

  • Name
    post_id
    Type
    number
    Description

    The id of the post.

  • Name
    user_id
    Type
    string
    Description

    The ID of the user, if logged in.

  • Name
    name
    Type
    string
    Description

    The name of the user.

  • Name
    email
    Type
    string
    Description

    The email of the user.

  • Name
    content
    Type
    string
    Description

    The text content of the comment.

  • Name
    parent_id
    Type
    string
    Description

    The ID of the parent, if its a reply.

  • Name
    status
    Type
    string
    Description

    The status of the comment.

  • Name
    created_at
    Type
    timestamp
    Description

    The timestamp of comment create time.

  • Name
    updated_at
    Type
    timestamp
    Description

    The timestamp of comment update time.


GET/comments/{post_id}

Get post comments

This endpoint allows you to retrieve all comments of a single post.

Request

curl -G https://api.bloghunch.com/app/{subdomain}/comments/{post_id} \
  -H "Authorization: Bearer {token}"

Response

[
  {
      "id": 24,
      "publication_id": 3719,
      "post_id": 406856,
      "user_id": null,
      "name": "Team BlogHunch",
      "email": "team@bloghunch.com",
      "content": "Hi, this is a comment. To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard. Commenter avatars come from Gravatar.",
      "parent_id": null,
      "status": "approved",
      "created_at": "2023-02-10T13:59:50.000+05:30",
      "updated_at": "2023-02-10T13:59:50.000+05:30"
  }
  ...
]

POST/comments

Create a comment

This endpoint allows you to create a new comment on a specific post.

Required attributes

  • Name
    postId
    Type
    number
    Description

    The ID of the post.

  • Name
    content
    Type
    string
    Description

    The text content of the comment.

Optional attributes

  • Name
    parentId
    Type
    number
    Description

    The ID of the parent comment, if this is a reply.

Request

curl -X POST https://api.bloghunch.com/app/{subdomain}/comments \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{
    "postId": 406856,
    "content": "This is a great post!"
  }'

Response

{
  "status": "success",
  "message": "Comment created",
  "comment": {
      "id": 25,
      "publication_id": 3719,
      "post_id": 406856,
      "user_id": 1,
      "content": "This is a great post!",
      "parent_id": null,
      "status": "approved",
      "created_at": "2023-02-10T14:00:00.000+05:30",
      "updated_at": "2023-02-10T14:00:00.000+05:30"
  }
}

PUT/comments/{id}/moderate

Moderate a comment

This endpoint allows you to approve or moderate an existing comment.

Request

curl -X PUT https://api.bloghunch.com/app/{subdomain}/comments/{id}/moderate \
  -H "Authorization: Bearer {token}"

Response

{
  "status": "success",
  "message": "Comment approved"
}

DELETE/comments/{id}

Delete a comment

This endpoint allows you to delete an existing comment.

Request

curl -X DELETE https://api.bloghunch.com/app/{subdomain}/comments/{id} \
  -H "Authorization: Bearer {token}"

Response

{
  "status": "success",
  "message": "Comment deleted"
}