activity 資源包含特定頻道或使用者在 YouTube 上執行的動作相關資訊。活動動態消息中回報的動作包括:為影片評分、分享影片、將影片標示為我的最愛、上傳影片等。每個 activity 資源都會指出動作類型、與動作相關聯的頻道,以及與動作相關聯的資源,例如獲得評分或上傳的影片。
方法
這個 API 支援 activities 資源的下列方法:
資源表示法
下列 JSON 結構顯示 activities 資源的格式:
{
  "kind": "youtube#activity",
  "etag": etag,
  "id": string,
  "snippet": {
    "publishedAt": datetime,
    "channelId": string,
    "title": string,
    "description": string,
    "thumbnails": {
      (key): {
        "url": string,
        "width": unsigned integer,
        "height": unsigned integer
      }
    },
    "channelTitle": string,
    "type": string,
    "groupId": string
  },
  "contentDetails": {
    "upload": {
      "videoId": string
    },
    "like": {
      "resourceId": {
        "kind": string,
        "videoId": string,
      }
    },
    "favorite": {
      "resourceId": {
        "kind": string,
        "videoId": string,
      }
    },
    "comment": {
      "resourceId": {
        "kind": string,
        "videoId": string,
        "channelId": string,
      }
    },
    "subscription": {
      "resourceId": {
        "kind": string,
        "channelId": string,
      }
    },
    "playlistItem": {
      "resourceId": {
        "kind": string,
        "videoId": string,
      },
      "playlistId": string,
      "playlistItemId": string
    },
    "recommendation": {
      "resourceId": {
        "kind": string,
        "videoId": string,
        "channelId": string,
      },
      "reason": string,
      "seedResourceId": {
        "kind": string,
        "videoId": string,
        "channelId": string,
        "playlistId": string
      }
    },
    "social": {
      "type": string,
      "resourceId": {
        "kind": string,
        "videoId": string,
        "channelId": string,
        "playlistId": string
      },
      "author": string,
      "referenceUrl": string,
      "imageUrl": string
    },
    "channelItem": {
      "resourceId": {
      }
    },
  }
}屬性
下表定義這個資源中顯示的屬性:
| 屬性 | |
|---|---|
| kind | string識別 API 資源的類型。值為 youtube#activity。 | 
| etag | etag這項資源的 Etag。 | 
| id | stringYouTube 用來識別活動的專屬 ID。 | 
| snippet | objectsnippet物件包含活動的基本詳細資料,包括活動類型和群組 ID。 | 
| snippet.publishedAt | datetime活動發生的日期和時間。值以 ISO 8601 格式指定。 | 
| snippet.channelId | stringYouTube 用來專屬識別與活動相關聯的頻道 ID。 | 
| snippet.title | string與活動主要相關的資源標題。 | 
| snippet.description | string與活動主要相關的資源說明。 | 
| snippet.thumbnails | object與主要活動相關聯的資源縮圖對應。地圖中的每個物件,其鍵都是縮圖圖片的名稱,值則是包含縮圖其他資訊的物件。 | 
| snippet.thumbnails.(key) | object有效鍵值如下: 
 | 
| snippet.thumbnails.(key).url | string圖片的網址。 | 
| snippet.thumbnails.(key).width | unsigned integer圖片寬度。 | 
| snippet.thumbnails.(key).height | unsigned integer圖片的高度。 | 
| snippet.channelTitle | string負責這項活動的頻道名稱 | 
| snippet.type | string資源描述的活動類型。 這個屬性的有效值包括: 
 | 
| snippet.groupId | string與活動相關聯的群組 ID。群組 ID 可識別與同一使用者和資源相關聯的使用者事件。舉例來說,如果使用者對影片評分,並將同一部影片標示為我的最愛,這些事件的項目在使用者動態消息中會具有相同的群組 ID。在使用者介面中,您可以將具有相同 groupId值的事件分組,避免重複。 | 
| contentDetails | objectcontentDetails物件包含與活動相關聯的內容資訊。舉例來說,如果snippet.type值為videoRated,則contentDetails物件的內容會識別已評分的影片。 | 
| contentDetails.upload | objectupload物件包含上傳影片的相關資訊。只有在snippet.type為upload時,才會顯示這個屬性。 | 
| contentDetails.upload.videoId | stringYouTube 用於識別上傳影片的專屬 ID。 | 
| contentDetails.like | objectlike物件包含獲得正面 (喜歡) 評分的資源相關資訊。只有在snippet.type為like時,才會顯示這個屬性。 | 
| contentDetails.like.resourceId | objectresourceId物件包含可識別評分資源的資訊。 | 
| contentDetails.like.resourceId.kind | stringAPI 資源的類型。 | 
| contentDetails.like.resourceId.videoId | string如果評分資源是影片,則為 YouTube 用來專屬識別影片的 ID。只有在 resourceId.kind為youtube#video時,才會顯示這個屬性。 | 
| contentDetails.favorite | objectfavorite物件包含標示為我的最愛影片的相關資訊。只有在snippet.type為favorite時,才會顯示這個屬性。 | 
| contentDetails.favorite.resourceId | objectresourceId物件包含可識別標示為最愛的資源資訊。 | 
| contentDetails.favorite.resourceId.kind | stringAPI 資源的類型。 | 
| contentDetails.favorite.resourceId.videoId | stringYouTube 用來識別喜愛影片的專屬 ID。只有在 resourceId.kind為youtube#video時,才會顯示這項屬性。注意: activities.list方法目前不會傳回新留言的資源。 | 
| contentDetails.comment | objectcomment物件包含收到留言的資源相關資訊。只有在snippet.type為comment時,才會顯示這個屬性。 | 
| contentDetails.comment.resourceId | objectresourceId物件包含可識別與留言相關聯資源的資訊。 | 
| contentDetails.comment.resourceId.kind | stringAPI 資源的類型。 | 
| contentDetails.comment.resourceId.videoId | stringYouTube 用於識別與留言相關聯影片的專屬 ID。只有在 resourceId.kind為youtube#video時,才會顯示這個屬性。 | 
| contentDetails.comment.resourceId.channelId | stringYouTube 用來明確識別與留言相關聯頻道的 ID。只有在 resourceId.kind為youtube#channel時,才會顯示這個屬性。 | 
| contentDetails.subscription | objectsubscription物件包含使用者訂閱的頻道相關資訊。只有在snippet.type為subscription時,才會顯示這個屬性。 | 
| contentDetails.subscription.resourceId | objectresourceId物件包含可識別使用者訂閱資源的資訊。 | 
| contentDetails.subscription.resourceId.kind | stringAPI 資源的類型。 | 
| contentDetails.subscription.resourceId.channelId | stringYouTube 用來識別使用者訂閱頻道的專屬 ID。只有在 resourceId.kind為youtube#channel時,才會顯示這個屬性。 | 
| contentDetails.playlistItem | objectplaylistItem物件包含新播放清單項目的相關資訊。只有在snippet.type為playlistItem時,才會顯示這個屬性。 | 
| contentDetails.playlistItem.resourceId | objectresourceId物件包含可識別已新增至播放清單的資源資訊。 | 
| contentDetails.playlistItem.resourceId.kind | stringAPI 資源的類型。 | 
| contentDetails.playlistItem.resourceId.videoId | stringYouTube 用來專屬識別已加入播放清單影片的 ID。只有在 resourceId.kind為youtube#video時,才會顯示這個屬性。 | 
| contentDetails.playlistItem.playlistId | stringYouTube 用來識別播放清單的值。 | 
| contentDetails.playlistItem.playlistItemId | stringYouTube 用來專屬識別播放清單中項目的值。 | 
| contentDetails.recommendation | objectrecommendation物件包含建議資源的相關資訊。只有在snippet.type為recommendation時,才會顯示這個屬性。 | 
| contentDetails.recommendation.resourceId | objectresourceId物件包含可識別建議資源的資訊。 | 
| contentDetails.recommendation.resourceId.kind | stringAPI 資源的類型。 | 
| contentDetails.recommendation.resourceId.videoId | string如果建議的資源是影片,這個 ID 就是 YouTube 用來專屬識別影片的 ID。只有在 resourceId.kind為youtube#video時,才會顯示這個屬性。 | 
| contentDetails.recommendation.resourceId.channelId | string如果建議的資源是頻道,則為 YouTube 用於明確識別頻道的 ID。只有在 resourceId.kind為youtube#channel時,才會顯示這個屬性。 | 
| contentDetails.recommendation.reason | string向使用者推薦資源的原因。 這個屬性的有效值如下: 
 | 
| contentDetails.recommendation.seedResourceId | objectseedResourceId物件包含導致建議的資源相關資訊。 | 
| contentDetails.recommendation.seedResourceId.kind | stringAPI 資源的類型。 | 
| contentDetails.recommendation.seedResourceId.videoId | string如果推薦內容是由特定影片所致,這裡會顯示 YouTube 用來專屬識別該影片的 ID。只有在 seedResourceId.kind為youtube#video時,才會顯示這個屬性。 | 
| contentDetails.recommendation.seedResourceId.channelId | string如果建議是由特定頻道所致,則為 YouTube 用於專屬識別頻道的 ID。只有在 seedResourceId.kind為youtube#channel時,才會顯示這個屬性。 | 
| contentDetails.recommendation.seedResourceId.playlistId | string如果建議是由特定播放清單所致,則為 YouTube 用於識別播放清單的專屬 ID。只有在 seedResourceId.kind為youtube#playlist時,才會顯示這個屬性。 | 
| contentDetails.social | objectsocial物件包含社群網路貼文的詳細資料。只有在snippet.type為social時,才會顯示這個屬性。 | 
| contentDetails.social.type | string社群網路名稱。 這個屬性的有效值如下: 
 | 
| contentDetails.social.resourceId | objectresourceId物件會封裝資訊,用來識別與社群網路貼文相關聯的資源。 | 
| contentDetails.social.resourceId.kind | stringAPI 資源的類型。 | 
| contentDetails.social.resourceId.videoId | string如果社群網路貼文提及影片,這個 ID 是 YouTube 用來識別該影片的專屬 ID。只有在 social.resourceId.kind屬性的值為youtube#video時,才會顯示這個屬性。 | 
| contentDetails.social.resourceId.channelId | string如果社群網路貼文提及頻道,YouTube 會使用這個 ID 專屬識別該頻道。只有在 social.resourceId.kind屬性的值為youtube#channel時,才會顯示這個屬性。 | 
| contentDetails.social.resourceId.playlistId | string如果社群網路貼文提及播放清單,這個 ID 就是 YouTube 用來識別該播放清單的專屬 ID。只有在 social.resourceId.kind屬性的值為youtube#playlist時,才會顯示這個屬性。 | 
| contentDetails.social.author | string社群媒體貼文的作者。 | 
| contentDetails.social.referenceUrl | string社群網路貼文的網址。 | 
| contentDetails.social.imageUrl | string貼文作者的圖片。 | 
| contentDetails.channelItem | objectchannelItem物件包含已新增至頻道的資源詳細資料。只有在snippet.type為channelItem時,才會顯示這個屬性。 | 
| contentDetails.channelItem.resourceId | objectresourceId物件包含可識別已新增至頻道的資源資訊。 |