Implementation and Migration: Channels (profiles)

The following examples show how to use the YouTube Data API (v3) to perform functions related to retrieving and updating channel data.

Retrieve information about a channel

YouTube Data API (v2) functionality: Retrieving a user's profile

Whereas the v2 API provided a way for retrieving a user's profile, the v3 API provides a method for retrieving information about a channel. There are several differences between the two implementations:

  • The channel resource in the v3 API contains branding information, which was accessed via a branding options feed in the v2 API.

  • In the v3 API, you need to retrieve the channel resource to obtain playlist IDs that identify a channel's uploaded videos, favorite videos, liked videos, watch history, and watch later lists. (To fetch this information when calling the channels.list method, make sure the part parameter value includes the contentDetails resource part.

  • The v3 API's channel resource contains in-video promotion data. (You can also use the API to set in-video promotion data.) An in-video promotional campaign is used to display the thumbnail image of a promoted video in the video player during playback of the channel's videos.

  • Many of the elements in the v2 API's profile – such as yt:books, yt:movies, and yt:music – have been deprecated.

Call the channels.list method to retrieve information about a particular channel. There are a few ways to identify the channel:

Set a channel's branding information

YouTube Data API (v2) functionality: Updating branding options

This example updates a channel's branding options. The example has two steps:

  • Step 1: Retrieve the channel's branding options

    Call the channels.list method and set the part parameter value to brandingSettings and the mine parameter value to true.

    https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list?
            part=brandingSettings
            &mine=true

    Your application could display the retrieved settings, allowing the user to modify the settings to update.

  • Step 2: Update the channel's branding options

    Call the channels.list method and set the following values:

    • Set the id property to the channel's unique YouTube channel ID. The ID can be extracted from the API response in step 1.
    • Set the part parameter value to brandingSettings.

    The link to the API Explorer below creates a channel resource with the following branding settings:

    {
      "id": "CHANNEL_ID",
      "brandingSettings": {
        "channel": {
          "description": "A great channel to be enjoyed by all.",
          "moderateComments": true,
          "showRelatedChannels": true,
          "showBrowseView": true,
          "featuredChannelsTitle": "Featured Channel Stuff",
          "featuredChannelsUrls": [
            "UC_x5XG1OV2P6uZZ5FSM9Ttw",
            "UCBR8-60-B28hp2BmDPdntcQ",
            "UCK8sQmJBp8GCxrOtXWBpyEA"
          ],
          "profileColor": "#006600"
        }
      }
    }

    To complete the request in the APIs Explorer, you need to set the id property's value to the channel ID of the authenticated user's channel. You should also set the image properties to match your current settings.

    https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.videos.update?
            part=brandingSettings
    

Update a channel's in-video promotional campaign data

New in v3: This functionality is new in the v3 API.

You can call the channels.update method to modify a channel's in-video promotional campaign settings. A channel can use an in-video promotional campaign to display thumbnail images for a promoted video within the video player during playbacks of the channel's videos. This Python code sample demonstrates how to call this function using the Google APIs Client Library for Python.

Related code samples: Python

Manage channel sections

New in v3: This functionality is new in the v3 API.

The API supports the channelSections.list, channelSections.insert, channelSections.update, and channelSections.delete methods for managing channel sections. A channel section is a set of videos that are featured on a channel. For example, a section could include a channel's latest uploads, most popular uploads, or videos from one or more playlists.

The example below retrieves the channel sections for Google's official YouTube channel. The request calls the channelSections.list method and sets the channelId parameter value to UCK8sQmJBp8GCxrOtXWBpyEA, which is the channel ID for Google's channel.

https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channelSections.list?
part=snippet,contentDetails
&channelId=UCK8sQmJBp8GCxrOtXWBpyEA

This request requires authorization if, instead of using the channelId parameter, you set the mine parameter value to true. That parameter indicates that you are retrieving channel sections for the currently authenticated user's channel.

Upload and set a watermark image for a channel

New in v3: This functionality is new in the v3 API.

You can call the watermarks.set method to upload a watermark image and set it for a channel. The image then displays during playbacks of the specified channel's videos. You can also specify a target channel to which the image will link as well as timing details that determine when the watermark appears and how long it is visible.

The watermarks.unset method deletes a channel's watermark image.

Unfortunately, this query cannot be tested using the APIs Explorer because the APIs Explorer does not support the ability to upload media files, which is a requirement for this method.

Send feedback about...

YouTube Data API
YouTube Data API