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
Field | Type | Description |
---|---|---|
profileId | string | The ID of the profile creating the comment. |
contentId | string | The ID of the content being commented on. |
text | string | The 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
Field | Type | Description |
---|---|---|
text | string | The 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
Parameter | Type | Description |
---|---|---|
contentId | string | The 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
Parameter | Type | Description |
---|---|---|
profileId | string | The ID of the profile to get comments from. |