comment 資源包含單一 YouTube 留言的相關資訊。comment 資源可代表影片或頻道的留言。此外,留言可能是頂層留言,也可能是回覆頂層留言。
方法
這個 API 支援 comments 資源的下列方法:
資源表示法
下列 JSON 結構顯示 comments 資源的格式:
{
  "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
  }
}屬性
下表定義這個資源中顯示的屬性:
| 屬性 | |
|---|---|
| kind | string識別 API 資源的類型。值為 youtube#comment。 | 
| etag | etag這項資源的 Etag。 | 
| id | stringYouTube 用於識別留言的專屬 ID。 | 
| snippet | objectsnippet物件包含留言的基本詳細資料。 | 
| snippet.authorDisplayName | string發布留言的使用者顯示名稱。 | 
| snippet.authorProfileImageUrl | string發布留言的使用者的大頭貼網址。 | 
| snippet.authorChannelUrl | string留言者的 YouTube 頻道網址 (如有)。 | 
| snippet.authorChannelId | object這個物件會封裝留言作者的 YouTube 頻道資訊 (如有)。 | 
| snippet.authorChannelId.value | string留言者的 YouTube 頻道 ID (如有)。 | 
| snippet.channelId | string與留言相關聯的 YouTube 頻道 ID。 | 
| snippet.textDisplay | string留言文字。您可以擷取純文字或 HTML 格式的文字。( comments.list和commentThreads.list方法都支援textFormat參數,可指定所選文字格式。)即使是純文字,也可能與原始留言文字不同。例如,系統可能會將影片連結替換成影片標題。 | 
| snippet.textOriginal | string留言的原始純文字,也就是最初發布或上次更新的內容。只有通過驗證的使用者是留言作者時,系統才會傳回原始文字。 | 
| snippet.parentId | string父項留言的專屬 ID。只有在留言是回覆其他留言時,才會設定這項屬性。 | 
| snippet.canRate | boolean這項設定會指出目前的檢視者是否可以對留言評分。 | 
| snippet.viewerRating | string觀眾對這則留言的評分。不過,這項屬性不會識別 dislike評分,但這項行為可能會變更。在此期間,如果觀眾給予正面評價,屬性值會是like。在所有其他情況下,包括使用者給予負評或未評分,值都是none。這項屬性的有效值為: 
 | 
| snippet.likeCount | unsigned integer留言獲得的喜歡 (正面評分) 總數。 | 
| snippet.moderationStatus | string留言的管理狀態。只有在 API 要求的授權者是頻道或影片擁有者,且要求是針對該頻道或影片的留言提出時,系統才會傳回這項屬性。此外,如果 API 要求使用 id篩選器參數,系統就不會設定這個屬性。這個屬性的有效值包括: 
 | 
| snippet.publishedAt | datetime留言的原始發布日期和時間。值以 ISO 8601 格式指定。 | 
| snippet.updatedAt | datetime上次更新留言的日期和時間。值以 ISO 8601 格式指定。 |