Manage post comments
Learn how to list, add, reply to, edit, and delete Facebook post comments with Unipile API.
For endpoints requiring a post ID or comment ID, use the identifiers returned by Unipile.
List comments
To retrieve the comments of a post, use List all Post's Comments. Facebook sets the page size: each page holds up to 10 comments whatever the limit. Use next_cursor to get more.
const { data } = await postsApi.getPostCommentsList({
path: {
account_id: "acc_123456789",
post_id: "post_id",
},
});comments = posts_api.get_post_comments_list("post_id", "acc_123456789")curl --request GET \
--url https://api.unipile.com/v2/acc_123456789/posts/post_id/comments \
--header 'X-API-KEY: api-key' \
--header 'accept: application/json'List replies
To retrieve the replies to a comment, use List all Comment Replies. Each page holds up to 10 replies whatever the limit.
const { data } = await postsApi.getPostCommentRepliesList({
path: {
account_id: "acc_123456789",
post_id: "post_id",
comment_id: "comment_id",
},
});replies = posts_api.get_post_comment_replies_list(
"post_id",
"comment_id",
"acc_123456789",
)curl --request GET \
--url https://api.unipile.com/v2/acc_123456789/posts/post_id/comments/comment_id/replies \
--header 'X-API-KEY: api-key' \
--header 'accept: application/json'Add a comment
To comment on a post, use Add Comment to a Post. To comment as a Page, set comment_as to its Page ID. The Page must be activated on the account.
const { data } = await postsApi.addPostComment({
path: {
account_id: "acc_123456789",
post_id: "post_id",
},
body: {
text: "Nice post!",
comment_as: "1357020157484056",
},
});comment = posts_api.add_post_comment(
"post_id",
"acc_123456789",
{
"text": "Nice post!",
"comment_as": "1357020157484056",
},
)curl --request POST \
--url https://api.unipile.com/v2/acc_123456789/posts/post_id/comments \
--header 'X-API-KEY: api-key' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"text": "Nice post!",
"comment_as": "1357020157484056"
}
'A comment takes one image, in attachments, and can then have an empty text. An animated GIF file is published as a still image.
Reply to a comment
To reply to a comment, use Reply to a Comment. It accepts the same fields as a comment.
const { data } = await postsApi.replyToComment({
path: {
account_id: "acc_123456789",
post_id: "post_id",
comment_id: "comment_id",
},
body: {
text: "Thanks for your comment!",
},
});reply = posts_api.reply_to_comment(
"post_id",
"comment_id",
"acc_123456789",
{"text": "Thanks for your comment!"},
)curl --request POST \
--url https://api.unipile.com/v2/acc_123456789/posts/post_id/comments/comment_id \
--header 'X-API-KEY: api-key' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"text": "Thanks for your comment!"
}
'Edit a comment
To edit a comment, use Update a Comment. A comment written by one of the account's Pages is edited by that Page.
const { data } = await postsApi.updatePostComment({
path: {
account_id: "acc_123456789",
post_id: "post_id",
comment_id: "comment_id",
},
body: {
text: "Edited comment",
},
});comment = posts_api.update_post_comment(
"post_id",
"comment_id",
"acc_123456789",
{"text": "Edited comment"},
)curl --request PATCH \
--url https://api.unipile.com/v2/acc_123456789/posts/post_id/comments/comment_id \
--header 'X-API-KEY: api-key' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"text": "Edited comment"
}
'Delete a comment
To delete a comment, use Delete Comment from a Post. A comment written by one of the account's Pages is deleted by that Page, and a Page can delete what others wrote under its own posts.
await postsApi.deletePostComment({
path: {
account_id: "acc_123456789",
post_id: "post_id",
comment_id: "comment_id",
},
});posts_api.delete_post_comment(
"post_id",
"comment_id",
"acc_123456789",
)curl --request DELETE \
--url https://api.unipile.com/v2/acc_123456789/posts/post_id/comments/comment_id \
--header 'X-API-KEY: api-key' \
--header 'accept: application/json'Updated 2 days ago