Skip to main content

Comments API

The Comments API allows you to create, update, delete, and retrieve comments associated with content, enabling users to engage in discussions and share their thoughts on posts.

Endpoints

Creating a Comment

To allow users to comment on a post, use the POST api/v1/comments endpoint.

Request Body

FieldTypeDescription
profileIdstringThe ID of the profile creating the comment.
contentIdstringThe ID of the content being commented on.
textstringThe text content of the comment.

Response

{
"success": true,
"commentId": "comment-1234567890"
}

Update a Comment

If a user wants to edit their comment, use the PUT api/v1/comments/:commentId endpoint.

PUT api/v1/comments/:commentId

Request Body

FieldTypeDescription
textstringThe updated text of the comment.

Response

{
"success": true,
"commentId": "comment-1234567890"
}

Delete a Comment

To allow users to delete their comments, use the DELETE api/v1/comments/:commentId endpoint.

DELETE api/v1/comments/:commentId

Response

{
"success": true
}

Get Comments by Content

To retrieve comments about a specific post, use the GET api/v1/comments?contentId=:contentId endpoint.

GET api/v1/comments?contentId=:contentId

Query Parameters

ParameterTypeDescription
contentIdstringThe ID of the content to get comments for.

Response

[
{
"comment": {
"id": "comment-1234567890",
"text": "Great content!",
"createdAt": 1621234567890
},
"author": {
"id": "profile-1234567890",
"username": "johndoe"
}
}
]

Get Comments by Profile

To retrieve comments authored by a specific user, use the GET api/v1/comments?profileId=:profileId endpoint.

GET api/v1/comments?profileId=:profileId

Query Parameters

ParameterTypeDescription
profileIdstringThe ID of the profile to get comments from.

Response

[
{
"contentId": "content-1234567890",
"comment": {
"id": "comment-1234567890",
"text": "Great content!",
"createdAt": 1621234567890
}
}
]

Authentication

All comments endpoints require an API key to be provided in the apiKey query parameter for authentication.

Error Handling

In case of an error, the API will respond with an appropriate HTTP status code and an error message in the response body.

{
"success": false,
"error": "Error message"
}