REST Resource: comments

Resource: Comment

A comment resource contains information about a single YouTube comment on a video or a post. The comment can be a top-level comment or a reply to a top-level comment.

Comments on posts are in a pilot phase with access limited to select launch partners (approved Google Cloud projects). Broader public API access is planned for General Availability in 2027.

JSON representation
{
  "kind": string,
  "etag": string,
  "id": string,
  "snippet": {
    "channelId": string,
    "videoId": string,
    "postId": string,
    "textDisplay": string,
    "textOriginal": string,
    "parentId": string,
    "authorDisplayName": string,
    "authorProfileImageUrl": string,
    "authorChannelUrl": string,
    "authorChannelId": {
      "value": string
    },
    "canRate": boolean,
    "viewerRating": enum,
    "likeCount": integer,
    "moderationStatus": enum (ModerationStatus),
    "publishedAt": string,
    "updatedAt": string,
    "imageUrl": string
  }
}
Fields
kind

string

Identifies what kind of resource this is. Value: the fixed string "youtube#comment".

etag

string

Etag of this resource.

id

string

The ID that YouTube uses to uniquely identify the comment.

snippet

object

The snippet object contains basic details about the comment.

snippet.channelId

string

The ID of the YouTube channel associated with the comment (the channel that owns the video or post the comment refers to).

snippet.videoId

string

The ID of the video the comment refers to, if any.

The API returns this field only for comments in a commentThread resource, in snippet.topLevelComment and replies.comments[].

snippet.postId

string

The ID of the post that the comment refers to, if any.

The API returns this field only for comments in a commentThread resource, in snippet.topLevelComment and replies.comments[]. This field is available only to approved Google Cloud projects.

snippet.textDisplay

string

The comment's text, formatted as either HTML or plain text depending on the textFormat parameter in comments.list and commentThreads.list requests (or plain text in comments.insert and comments.update responses).

snippet.textOriginal

string

The original, raw text of the comment as initially posted or last updated.

snippet.parentId

string

The unique ID of the parent top-level comment. This property is only set if the comment was submitted as a reply to another comment.

snippet.authorDisplayName

string

The display name of the user who posted the comment.

snippet.authorProfileImageUrl

string

The URL for the avatar of the user who posted the comment.

snippet.authorChannelUrl

string

The URL of the comment author's YouTube channel, if available.

snippet.authorChannelId

object

Encapsulates information about the comment author's YouTube channel, if available.

snippet.authorChannelId.value

string

The ID of the comment author's YouTube channel, if available.

snippet.canRate

boolean

Indicates whether the viewer can rate the comment.

snippet.viewerRating

enum

The rating the viewer has given to this comment.

Valid values of this enum field are:

  • none
  • like
  • dislike
snippet.likeCount

integer (uint32 format)

The total number of likes (positive ratings) the comment has received.

snippet.moderationStatus

enum (ModerationStatus)

The comment's moderation status. This property is populated whenever a returned comment is held for review (heldForReview) or flagged as spam (likelySpam), and is omitted for published comments.

snippet.publishedAt

string

The date and time when the comment was originally published. The value is specified in ISO 8601 format.

snippet.updatedAt

string

The date and time when the comment was last updated. The value is specified in ISO 8601 format.

snippet.imageUrl

string

Output only. The URL of the image or animated GIF attached to the comment, if any. This property is only present when a comment contains an image or GIF. The URL is served as a signed link with a six-hour time to live (TTL) and expires six hours after retrieval.

Methods

delete

Deletes a comment.

insert

Creates a reply to an existing comment.

list

Returns a list of comments that match the API request parameters.

setModerationStatus

Sets the moderation status of one or more comments.

update

Modifies a comment.