Comments

A comment resource contains information about a single YouTube comment. A comment resource can represent a comment about either a video or a channel. In addition, the comment could be a top-level comment or a reply to a top-level comment.

Methods

The API supports the following methods for comments resources:

list
Returns a list of comments that match the API request parameters. Try it now.
insert
Creates a reply to an existing comment. Note: To create a top-level comment, use the commentThreads.insert method. Try it now.
update
Modifies a comment. Try it now.
delete
Deletes a comment. Try it now.
setModerationStatus
Sets the moderation status of one or more comments. The API request must be authorized by the owner of the channel or video associated with the comments. Try it now.
markAsSpam
Note: This method has been deprecated and is no longer supported.
Expresses the caller's opinion that one or more comments should be flagged as spam.

Resource representation

The following JSON structure shows the format of a comments resource:

{
  "kind": "youtube#comment",
  "etag": etag,
  "id": string,
  "snippet": {
    "authorDisplayName": string,
    "authorProfileImageUrl": string,
    "authorChannelUrl": string,
    "authorChannelId": {
      "value": string
    },
    "channelId": string,
    "textDisplay": string,
    "textOriginal": string,
    "parentId": string,
    "canRate": boolean,
    "viewerRating": string,
    "likeCount": unsigned integer,
    "moderationStatus": string,
    "publishedAt": datetime,
    "updatedAt": datetime
  }
}

Properties

The following table defines the properties that appear in this resource:

Properties
kindstring
Identifies the API resource's type. The value will be youtube#comment.
etagetag
The Etag of this resource.
idstring
The ID that YouTube uses to uniquely identify the comment.
snippetobject
The snippet object contains basic details about the comment.
snippet.authorDisplayNamestring
The display name of the user who posted the comment.
snippet.authorProfileImageUrlstring
The URL for the avatar of the user who posted the comment.
snippet.authorChannelUrlstring
The URL of the comment author's YouTube channel, if available.
snippet.authorChannelIdobject
This object encapsulates information about the comment author's YouTube channel, if available.
snippet.authorChannelId.valuestring
The ID of the comment author's YouTube channel, if available.
snippet.channelIdstring
The ID of the YouTube channel associated with the comment.
snippet.textDisplaystring
The comment's text. The text can be retrieved in either plain text or HTML. (The comments.list and commentThreads.list methods both support a textFormat parameter, which specifies the chosen text format.)

Even the plain text may differ from the original comment text. For example, it may replace video links with video titles.
snippet.textOriginalstring
The original, raw text of the comment as it was initially posted or last updated. The original text is only returned to the authenticated user if they are the comment's author.
snippet.parentIdstring
The unique ID of the parent comment. This property is only set if the comment was submitted as a reply to another comment.
snippet.canRateboolean
This setting indicates whether the current viewer can rate the comment.
snippet.viewerRatingstring
The rating the viewer has given to this comment. This property doesn't identify dislike ratings, though this behavior is subject to change. In the meantime, the property value is like if the viewer has rated the comment positively. The value is none in all other cases, including the user having given the comment a negative rating or not having rated the comment.

Valid values for this property are:
  • like
  • none
snippet.likeCountunsigned integer
The total number of likes (positive ratings) the comment has received.
snippet.moderationStatusstring
The comment's moderation status. This property is only returned if the API request was authorized by the owner of the channel or the video on which the requested comments were made. Also, this property isn't set if the API request used the id filter parameter.

Valid values for this property are:
  • heldForReview
  • likelySpam
  • published
  • rejected
snippet.publishedAtdatetime
The date and time when the comment was orignally published. The value is specified in ISO 8601 format.
snippet.updatedAtdatetime
The date and time when the comment was last updated. The value is specified in ISO 8601 format.