# YouTube Data API . comments

## Instance Methods

Deletes a comment.

Creates a reply to an existing comment. Note: To create a top-level comment, use the commentThreads.insert method.

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

Retrieves the next page of results.

Expresses the caller's opinion that one or more comments should be flagged as spam.

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.

Modifies a comment.

### Method Details

`delete(id)`

    Deletes a comment.

    Args:
      id: string, The id parameter specifies the comment ID for the resource that is being deleted. (required)

`insert(part, body)`

    Creates a reply to an existing comment. Note: To create a top-level comment, use the commentThreads.insert method.

    Args:
      part: string, The part parameter identifies the properties that the API response will include. Set the parameter value to snippet. The snippet part has a quota cost of 2 units. (required)
      body: object, The request body. (required)
        The object takes the form of:

    { # A comment represents a single YouTube comment.
      "snippet": { # Basic details about a comment, such as its author and text. # The snippet object contains basic details about the comment.
        "authorChannelUrl": "A String", # Link to the author's YouTube channel, if any.
        "viewerRating": "A String", # The rating the viewer has given to this comment. For the time being this will never return RATE_TYPE_DISLIKE and instead return RATE_TYPE_NONE. This may change in the future.
        "authorDisplayName": "A String", # The name of the user who posted the comment.
        "channelId": "A String", # The id of the corresponding YouTube channel. In case of a channel comment this is the channel the comment refers to. In case of a video comment it's the video's channel.
        "videoId": "A String", # The ID of the video the comment refers to, if any.
        "moderationStatus": "A String", # The comment's moderation status. Will not be set if the comments were requested through the id filter.
        "likeCount": 42, # The total number of likes this comment has received.
        "authorChannelId": "", # The id of the author's YouTube channel, if any.
        "parentId": "A String", # The unique id of the parent comment, only set for replies.
        "publishedAt": "A String", # The date and time when the comment was orignally published. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format.
        "canRate": True or False, # Whether the current viewer can rate this comment.
        "textOriginal": "A String", # The comment's original raw text as initially posted or last updated. The original text will only be returned if it is accessible to the viewer, which is only guaranteed if the viewer is the comment's author.
        "updatedAt": "A String", # The date and time when was last updated . The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format.
        "authorProfileImageUrl": "A String", # The URL for the avatar of the user who posted the comment.
        "textDisplay": "A String", # The comment's text. The format is either plain text or HTML dependent on what has been requested. Even the plain text representation may differ from the text originally posted in that it may replace video links with video titles etc.
      },
      "kind": "youtube#comment", # Identifies what kind of resource this is. Value: the fixed string "youtube#comment".
      "etag": "A String", # Etag of this resource.
      "id": "A String", # The ID that YouTube uses to uniquely identify the comment.
    }

    Returns:
      An object of the form:

        { # A comment represents a single YouTube comment.
        "snippet": { # Basic details about a comment, such as its author and text. # The snippet object contains basic details about the comment.
          "authorChannelUrl": "A String", # Link to the author's YouTube channel, if any.
          "viewerRating": "A String", # The rating the viewer has given to this comment. For the time being this will never return RATE_TYPE_DISLIKE and instead return RATE_TYPE_NONE. This may change in the future.
          "authorDisplayName": "A String", # The name of the user who posted the comment.
          "channelId": "A String", # The id of the corresponding YouTube channel. In case of a channel comment this is the channel the comment refers to. In case of a video comment it's the video's channel.
          "videoId": "A String", # The ID of the video the comment refers to, if any.
          "moderationStatus": "A String", # The comment's moderation status. Will not be set if the comments were requested through the id filter.
          "likeCount": 42, # The total number of likes this comment has received.
          "authorChannelId": "", # The id of the author's YouTube channel, if any.
          "parentId": "A String", # The unique id of the parent comment, only set for replies.
          "publishedAt": "A String", # The date and time when the comment was orignally published. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format.
          "canRate": True or False, # Whether the current viewer can rate this comment.
          "textOriginal": "A String", # The comment's original raw text as initially posted or last updated. The original text will only be returned if it is accessible to the viewer, which is only guaranteed if the viewer is the comment's author.
          "updatedAt": "A String", # The date and time when was last updated . The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format.
          "authorProfileImageUrl": "A String", # The URL for the avatar of the user who posted the comment.
          "textDisplay": "A String", # The comment's text. The format is either plain text or HTML dependent on what has been requested. Even the plain text representation may differ from the text originally posted in that it may replace video links with video titles etc.
        },
        "kind": "youtube#comment", # Identifies what kind of resource this is. Value: the fixed string "youtube#comment".
        "etag": "A String", # Etag of this resource.
        "id": "A String", # The ID that YouTube uses to uniquely identify the comment.
      }

`list(part, pageToken=None, maxResults=None, id=None, parentId=None, textFormat=None)`

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

    Args:
      part: string, The part parameter specifies a comma-separated list of one or more comment resource properties that the API response will include. (required)
      pageToken: string, The pageToken parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken property identifies the next page of the result that can be retrieved.

    Note: This parameter is not supported for use in conjunction with the id parameter.
      maxResults: integer, The maxResults parameter specifies the maximum number of items that should be returned in the result set.

    Note: This parameter is not supported for use in conjunction with the id parameter.
      id: string, The id parameter specifies a comma-separated list of comment IDs for the resources that are being retrieved. In a comment resource, the id property specifies the comment's ID.
      parentId: string, The parentId parameter specifies the ID of the comment for which replies should be retrieved.

    Note: YouTube currently supports replies only for top-level comments. However, replies to replies may be supported in the future.
      textFormat: string, This parameter indicates whether the API should return comments formatted as HTML or as plain text.
        Allowed values
          html - Returns the comments in HTML format. This is the default value.
          plainText - Returns the comments in plain text format.

    Returns:
      An object of the form:

        {
        "eventId": "A String", # Serialized EventId of the request which produced this response.
        "nextPageToken": "A String", # The token that can be used as the value of the pageToken parameter to retrieve the next page in the result set.
        "kind": "youtube#commentListResponse", # Identifies what kind of resource this is. Value: the fixed string "youtube#commentListResponse".
        "visitorId": "A String", # The visitorId identifies the visitor.
        "items": [ # A list of comments that match the request criteria.
          { # A comment represents a single YouTube comment.
            "snippet": { # Basic details about a comment, such as its author and text. # The snippet object contains basic details about the comment.
              "authorChannelUrl": "A String", # Link to the author's YouTube channel, if any.
              "viewerRating": "A String", # The rating the viewer has given to this comment. For the time being this will never return RATE_TYPE_DISLIKE and instead return RATE_TYPE_NONE. This may change in the future.
              "authorDisplayName": "A String", # The name of the user who posted the comment.
              "channelId": "A String", # The id of the corresponding YouTube channel. In case of a channel comment this is the channel the comment refers to. In case of a video comment it's the video's channel.
              "videoId": "A String", # The ID of the video the comment refers to, if any.
              "moderationStatus": "A String", # The comment's moderation status. Will not be set if the comments were requested through the id filter.
              "likeCount": 42, # The total number of likes this comment has received.
              "authorChannelId": "", # The id of the author's YouTube channel, if any.
              "parentId": "A String", # The unique id of the parent comment, only set for replies.
              "publishedAt": "A String", # The date and time when the comment was orignally published. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format.
              "canRate": True or False, # Whether the current viewer can rate this comment.
              "textOriginal": "A String", # The comment's original raw text as initially posted or last updated. The original text will only be returned if it is accessible to the viewer, which is only guaranteed if the viewer is the comment's author.
              "updatedAt": "A String", # The date and time when was last updated . The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format.
              "authorProfileImageUrl": "A String", # The URL for the avatar of the user who posted the comment.
              "textDisplay": "A String", # The comment's text. The format is either plain text or HTML dependent on what has been requested. Even the plain text representation may differ from the text originally posted in that it may replace video links with video titles etc.
            },
            "kind": "youtube#comment", # Identifies what kind of resource this is. Value: the fixed string "youtube#comment".
            "etag": "A String", # Etag of this resource.
            "id": "A String", # The ID that YouTube uses to uniquely identify the comment.
          },
        ],
        "tokenPagination": { # Stub token pagination template to suppress results.
        },
        "etag": "A String", # Etag of this resource.
        "pageInfo": { # Paging details for lists of resources, including total number of items available and number of resources returned in a single page.
          "totalResults": 42, # The total number of results in the result set.
          "resultsPerPage": 42, # The number of results included in the API response.
        },
      }

`list_next(previous_request, previous_response)`

    Retrieves the next page of results.

    Args:
      previous_request: The request for the previous page. (required)
      previous_response: The response from the request for the previous page. (required)

    Returns:
      A request object that you can call 'execute()' on to request the next
      page. Returns None if there are no more items in the collection.

`markAsSpam(id)`

    Expresses the caller's opinion that one or more comments should be flagged as spam.

    Args:
      id: string, The id parameter specifies a comma-separated list of IDs of comments that the caller believes should be classified as spam. (required)

`setModerationStatus(id, moderationStatus, banAuthor=None)`

    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.

    Args:
      id: string, The id parameter specifies a comma-separated list of IDs that identify the comments for which you are updating the moderation status. (required)
      moderationStatus: string, Identifies the new moderation status of the specified comments. (required)
        Allowed values
          heldForReview - Marks a comment as awaiting review by a moderator.
          published - Clears a comment for public display.
          rejected - Rejects a comment as being unfit for display. This action also effectively hides all replies to the rejected comment.

    Note: The API does not currently provide a way to list or otherwise discover rejected comments. However, you can change the moderation status of a rejected comment if you still know its ID. If you were to change the moderation status of a rejected comment, the comment replies would subsequently be discoverable again as well.
      banAuthor: boolean, The banAuthor parameter lets you indicate that you want to automatically reject any additional comments written by the comment's author. Set the parameter value to true to ban the author.

    Note: This parameter is only valid if the moderationStatus parameter is also set to rejected.

`update(part, body)`

    Modifies a comment.

    Args:
      part: string, The part parameter identifies the properties that the API response will include. You must at least include the snippet part in the parameter value since that part contains all of the properties that the API request can update. (required)
      body: object, The request body. (required)
        The object takes the form of:

    { # A comment represents a single YouTube comment.
      "snippet": { # Basic details about a comment, such as its author and text. # The snippet object contains basic details about the comment.
        "authorChannelUrl": "A String", # Link to the author's YouTube channel, if any.
        "viewerRating": "A String", # The rating the viewer has given to this comment. For the time being this will never return RATE_TYPE_DISLIKE and instead return RATE_TYPE_NONE. This may change in the future.
        "authorDisplayName": "A String", # The name of the user who posted the comment.
        "channelId": "A String", # The id of the corresponding YouTube channel. In case of a channel comment this is the channel the comment refers to. In case of a video comment it's the video's channel.
        "videoId": "A String", # The ID of the video the comment refers to, if any.
        "moderationStatus": "A String", # The comment's moderation status. Will not be set if the comments were requested through the id filter.
        "likeCount": 42, # The total number of likes this comment has received.
        "authorChannelId": "", # The id of the author's YouTube channel, if any.
        "parentId": "A String", # The unique id of the parent comment, only set for replies.
        "publishedAt": "A String", # The date and time when the comment was orignally published. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format.
        "canRate": True or False, # Whether the current viewer can rate this comment.
        "textOriginal": "A String", # The comment's original raw text as initially posted or last updated. The original text will only be returned if it is accessible to the viewer, which is only guaranteed if the viewer is the comment's author.
        "updatedAt": "A String", # The date and time when was last updated . The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format.
        "authorProfileImageUrl": "A String", # The URL for the avatar of the user who posted the comment.
        "textDisplay": "A String", # The comment's text. The format is either plain text or HTML dependent on what has been requested. Even the plain text representation may differ from the text originally posted in that it may replace video links with video titles etc.
      },
      "kind": "youtube#comment", # Identifies what kind of resource this is. Value: the fixed string "youtube#comment".
      "etag": "A String", # Etag of this resource.
      "id": "A String", # The ID that YouTube uses to uniquely identify the comment.
    }

    Returns:
      An object of the form:

        { # A comment represents a single YouTube comment.
        "snippet": { # Basic details about a comment, such as its author and text. # The snippet object contains basic details about the comment.
          "authorChannelUrl": "A String", # Link to the author's YouTube channel, if any.
          "viewerRating": "A String", # The rating the viewer has given to this comment. For the time being this will never return RATE_TYPE_DISLIKE and instead return RATE_TYPE_NONE. This may change in the future.
          "authorDisplayName": "A String", # The name of the user who posted the comment.
          "channelId": "A String", # The id of the corresponding YouTube channel. In case of a channel comment this is the channel the comment refers to. In case of a video comment it's the video's channel.
          "videoId": "A String", # The ID of the video the comment refers to, if any.
          "moderationStatus": "A String", # The comment's moderation status. Will not be set if the comments were requested through the id filter.
          "likeCount": 42, # The total number of likes this comment has received.
          "authorChannelId": "", # The id of the author's YouTube channel, if any.
          "parentId": "A String", # The unique id of the parent comment, only set for replies.
          "publishedAt": "A String", # The date and time when the comment was orignally published. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format.
          "canRate": True or False, # Whether the current viewer can rate this comment.
          "textOriginal": "A String", # The comment's original raw text as initially posted or last updated. The original text will only be returned if it is accessible to the viewer, which is only guaranteed if the viewer is the comment's author.
          "updatedAt": "A String", # The date and time when was last updated . The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format.
          "authorProfileImageUrl": "A String", # The URL for the avatar of the user who posted the comment.
          "textDisplay": "A String", # The comment's text. The format is either plain text or HTML dependent on what has been requested. Even the plain text representation may differ from the text originally posted in that it may replace video links with video titles etc.
        },
        "kind": "youtube#comment", # Identifies what kind of resource this is. Value: the fixed string "youtube#comment".
        "etag": "A String", # Etag of this resource.
        "id": "A String", # The ID that YouTube uses to uniquely identify the comment.
      }