REST Resource: subscriptions

Resource: Subscription

A subscription resource contains information about a YouTube user subscription. A subscription notifies a user when new videos are added to a channel or when another user takes one of several actions on YouTube, such as uploading a video, rating a video, or commenting on a video.

JSON representation
{
  "kind": string,
  "etag": string,
  "id": string,
  "snippet": {
    "publishedAt": string,
    "title": string,
    "description": string,
    "resourceId": {
      "kind": string,
      "videoId": string,
      "channelId": string,
      "playlistId": string
    },
    "channelId": string,
    "thumbnails": {
      object (ThumbnailDetails)
    }
  },
  "contentDetails": {
    "totalItemCount": integer,
    "newItemCount": integer,
    "activityType": enum
  },
  "subscriberSnippet": {
    "title": string,
    "description": string,
    "channelId": string,
    "thumbnails": {
      object (ThumbnailDetails)
    }
  }
}
Fields
kind

string

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

etag

string

Output only. Etag of this resource.

id

string

Output only. The ID that YouTube uses to uniquely identify the subscription.

snippet

object

The snippet object contains basic details about the subscription, including its title and the channel that the user subscribed to.

snippet.publishedAt

string

Output only. The date and time that the subscription was created. The value is specified in ISO 8601 format.

snippet.title

string

Output only. The subscription's title.

snippet.description

string

Output only. The subscription's details.

snippet.resourceId

object

The resourceId object contains information about the channel that the user subscribed to.

For subscriptions, resourceId.kind is always "youtube#channel" and resourceId.channelId identifies the subscribed channel (videoId and playlistId aren't used). In subscriptions.insert requests, snippet.resourceId.channelId is required.

snippet.resourceId.kind

string

The type of the API resource.

snippet.resourceId.videoId

string

The ID that YouTube uses to uniquely identify the referred resource, if that resource is a video. This property is only present if the resourceId.kind value is youtube#video.

snippet.resourceId.channelId

string

The ID that YouTube uses to uniquely identify the referred resource, if that resource is a channel. This property is only present if the resourceId.kind value is youtube#channel.

snippet.resourceId.playlistId

string

The ID that YouTube uses to uniquely identify the referred resource, if that resource is a playlist. This property is only present if the resourceId.kind value is youtube#playlist.

snippet.channelId

string

The ID that YouTube uses to uniquely identify the subscriber's channel. The snippet.resourceId object identifies the channel that the user subscribed to. In subscriptions.insert requests, if this property is specified, it must match the authenticated user's channel ID.

snippet.thumbnails

object (ThumbnailDetails)

Output only. A map of thumbnail images associated with the subscribed channel. For each object in the map, the key is the name of the thumbnail image, and the value is an object that contains the image URL.

Subscriptions populate only the default (88x88 px), medium (240x240 px), and high (800x800 px) url fields without width or height values.

contentDetails

object

The contentDetails object contains basic statistics about the subscription.

contentDetails.totalItemCount

integer (uint32 format)

Output only. The approximate number of items that the subscription points to.

contentDetails.newItemCount

integer (uint32 format)

Output only. The number of new items in the subscription since its content was last read. subscriptions.list returns 0 or 1 to indicate whether new content is available when listing the authenticated user's own subscriptions (mine=true, or channelId matching the caller), and 0 for subscriptions.insert and other subscriptions.list filters.

contentDetails.activityType

enum

The type of activity this subscription is for: all for all public activity or uploads for uploads only. subscriptions.insert always creates subscriptions with all public activity enabled; passing uploads only changes the immediate response.

Valid values of this enum field are:

  • all
  • uploads
subscriberSnippet

object

Output only. The subscriberSnippet object contains basic details about the subscriber. This object is empty ({}) if the subscriber doesn't have a YouTube channel.

subscriberSnippet.title

string

Output only. The title of the subscriber's channel.

subscriberSnippet.description

string

Output only. The description of the subscriber's channel.

subscriberSnippet.channelId

string

Output only. The ID that YouTube assigns to uniquely identify the subscriber's channel.

subscriberSnippet.thumbnails

object (ThumbnailDetails)

Output only. Thumbnail images for the subscriber's channel. Subscriptions populate only the default (88x88 px), medium (240x240 px), and high (800x800 px) url fields without width or height values.

Methods

delete

Deletes a subscription.

insert

Adds a subscription for the authenticated user's channel.

list

Returns subscription resources that match the API request criteria.