Introduction

The Comments API allows you to manage a customized commenting program that lets site visitors share feedback or engage in discussions around different types of resources, including blog posts, forum threads, or other site content.

With the Wix Comments API, you can:

  • Allow commenting on any page of your site.
  • Mark specific comments to highlight and feature to your readers.
  • Engage with visitors who are not site members through guest commenting.

Integrations

The Comments API is fully integrated with several Wix solutions. Each integration uses a slightly different configuration to work with Comments.

The following table details the currently supported integrations:

Wix AppappIdcontextIdresourceId
Wix Blog14bcded7-0066-7c35-14d7-466cb3f09103internalIdinternalId
Wix Comments91c9d6a7-6667-41fb-b0b4-7d3b3ff0b02econtentIdcontentId
Wix Forum14724f35-6794-cd1a-0244-25fd138f9242forumPostIdforumPostId
Wix Groups148c2287-c669-d849-d153-463c7486a694groupIdfeedItemId

Terminology

  • Marked comments: When a comment's marked field is set to TRUE, it indicates that the comment has been flagged or marked for special attention. No additional automated behavior or action is taken with the comment. However, you can manually filter for comments marked as such with the queryComments() function and highlight them to your visitors as needed.
  • Parent comments: Parent comments refer to comments that have subsequent comments directly responding to them. They serve as the original or initial comments in a conversation thread. The parent comment's unique identifier is stored in the parentComment.id field of the corresponding reply comment.
  • Replies: Replies are comments that are made in direct response to earlier comments within a discussion. They are specifically intended as responses to a particular parent comment and contribute to the ongoing conversation. Replies help maintain the hierarchical structure of comment threads and enhance the engagement and interactivity among users.
Was this helpful?
Yes
No

Setup

To use the Comments API, install the @wix/comments package using npm or Yarn:

Copy
1
npm install @wix/comments

or

Copy
1
yarn add @wix/comments

Then import { comments } from @wix/comments:

Copy
1
import { comments } from '@wix/comments'
Was this helpful?
Yes
No

countComments( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Counts comments, given the provided filtering.

For field support for filters and sorting, see the Supported Filters & Sorting table in the queryComments() function.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Comments
Learn more about permission scopes.
Copy
function countComments(appId: string, options: CountCommentsOptions): Promise<CountCommentsResponse>
Method Parameters
appIdstringRequired
App ID to count the comments of.

optionsCountCommentsOptions
Returns
Return Type:Promise<CountCommentsResponse>
Was this helpful?
Yes
No

createComment( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Creates a new comment.

The appId, contextId, and resourceId are all required and associate the created comment with the specific resource it responds to. See Integrations for a list of integrated scopes for these fields.

If the created comment is a direct response to another comment, the commentId of the parent comment should be passed as parentComment.id in this comment's request. See Terminology for additional information on parent comments and replies.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Comments
Learn more about permission scopes.
Copy
function createComment(comment: Comment): Promise<Comment>
Method Parameters
commentCommentRequired
Comment to create.
Returns
Return Type:Promise<Comment>
Was this helpful?
Yes
No

deleteComment( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Deletes a comment.

This endpoint deletes the content of the comment and sets its status to DELETED.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Comments
Learn more about permission scopes.
Copy
function deleteComment(commentId: string): Promise<void>
Method Parameters
commentIdstringRequired
ID of the Comment to delete.
Returns
Return Type:Promise<void>
Was this helpful?
Yes
No

getComment( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Retrieves a comment.

Permission Scopes

For app development, you must have one of the following permission scopes:
Read Comments
Manage Comments
Learn more about permission scopes.
Copy
function getComment(commentId: string): Promise<Comment>
Method Parameters
commentIdstringRequired
ID of the comment to retrieve.
Returns
Return Type:Promise<Comment>
Was this helpful?
Yes
No

markComment( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Sets marked to "TRUE" to mark a comment.

You can then filter for marked comments with the queryComments() function to apply customizations.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Comments
Learn more about permission scopes.
Copy
function markComment(commentId: string): Promise<MarkCommentResponse>
Method Parameters
commentIdstringRequired
ID of the comment to mark.
Returns
Return Type:Promise<MarkCommentResponse>
Was this helpful?
Yes
No

queryComments( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Creates a query to retrieve a list of comments.

The queryComments() function builds a query to retrieve a list of comments and returns a CommentsQueryBuilder object.

The returned object contains the query definition, which is typically used to run the query using the find() function.

You can refine the query by chaining CommentsQueryBuilder functions onto the query. CommentsQueryBuilder functions enable you to sort, filter, and control the results that queryComments() returns.

queryComments() runs with the following CommentsQueryBuilder default that you can override:

  • ascending("_id")

The functions that are chained to queryComments() are applied in the order they are called. For example, if you apply ascending("voteSummary.netVoteCount") and then ascending("replyCount"), the results are sorted first by the "voteSummary.netVoteCount", and then, if there are multiple results with the same "voteSummary.netVoteCount", the items are sorted by "replyCount".

The following CommentsQueryBuilder functions are supported for the queryComments() function. For a full description of the comment object, see the object returned for the items property in CommentsQueryResult.

PROPERTYSUPPORTED FILTERS & SORTING
_ideq(),ne(),in()
contextIdeq(),ne(),in()
resourceIdeq(),ne(),in()
author.userIdeq(),ne(),in()
author.memberIdeq(),ne(),in()
author.visitorIdeq(),ne(),in()
parentComment.ideq(),ne(),in()
replyCounteq(),ne(),lt(),le(),gt(),ge(),ascending(),descending()
voteSummary.netVoteCounteq(),ne(),lt(),le(),gt(),ge(),ascending(),descending()
statuseq(),ne(),in()
ratingeq(),ne(),lt(),le(),gt(),ge(),ascending(),descending()
reactionSummary.totaleq(),ne(),lt(),le(),gt(),ge(),ascending(),descending()
markedeq(),ne(),ascending(),descending()

Permission Scopes

For app development, you must have one of the following permission scopes:
Read Comments
Manage Comments
Learn more about permission scopes.
Copy
function queryComments(appId: string): CommentsQueryBuilder
Method Parameters
appIdstringRequired
App ID to query comments for.
Returns
Was this helpful?
Yes
No

unmarkComment( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Sets marked to "FALSE" to unmark a comment.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Comments
Learn more about permission scopes.
Copy
function unmarkComment(commentId: string): Promise<UnmarkCommentResponse>
Method Parameters
commentIdstringRequired
ID of the comment to unmark.
Returns
Return Type:Promise<UnmarkCommentResponse>
Was this helpful?
Yes
No

updateComment( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Updates a comment.

Each time the comment is updated, revision increments by 1. The current revision must be passed when updating the comment. This ensures you're working with the latest comment and prevents unintended overwrites.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Comments
Learn more about permission scopes.
Copy
function updateComment(_id: string, comment: UpdateComment): Promise<Comment>
Method Parameters
_idstringRequired
Comment ID.

commentUpdateCommentRequired
Returns
Return Type:Promise<Comment>
Was this helpful?
Yes
No