Modify YouTube Channels
Learn about adding a banner to a channel and updating it using the YouTube Data API.
We'll cover the following...
The Channels resource contains details like the number of subscribers, view count, video count, channel name, and description, which helps users to create their presence on the internet with their content.
In this lesson, we’ll look at how we can add a banner and update a channel by using the YouTube Data API’s resources.
Note: The YouTube Data API only offers 10,000 points per day to its free users. These are consumed according to each endpoint call quota. This is explained in detail in the Endpoints Call Quotas lesson in the Appendix.
Upload a channel banner
In this section, we'll upload a channel banner using the ChannelBanners resource's insert method. We can only upload a banner to the YouTube channel with a 6:9 aspect ratio and at least 2048 x 1152 pixels. To add a banner to a channel, we’ll make a POST request to the following endpoint:
https://www.googleapis.com/upload/youtube/v3/channelBanners/insert
Request parameters
For this endpoint, there’s only one optional parameter: onBehalfOfContentOwner. Authenticated users can use this endpoint to make changes to the content on behalf of the content owner.
Let’s see how to call the API endpoint to upload the channel banner. Click the “Run” button to execute the following code:
Let’s understand how the above code works by breaking it down:
Line 2: We import the
fsfile system module to read the banner image.Line 4: We specify the endpoint URL for the endpoint.
Lines 7–10: We declare the headers by using the
headerParametersvariable in which we pass theACCESS_TOKEN.Line 12: We define an
imgPathvariable that contains the path of the channel banner image. The image file has already been uploaded to the platform.Line 20: We define an async function
uploadChannelBanner()to call the endpoint.
Click the link below to go to your channel and check out your updated channel banner:
Response fields
Some important response fields are as follows:
Name | Type | Description |
| String | Reflects the resource type of the API call. |
| ETag | Contains the resource ETag. |
| String | Contains the URL of the uploaded image. |
Update a channel
After uploading a channel banner, we can also make changes to that channel’s content. For that purpose, we’ll use the update method of the Channels resource by sending a POST request to the following URL:
https://www.googleapis.com/youtube/v3/channels
Request parameters
Here are some important parameters that we can use to call the endpoint:
Name | Type | Category | Description |
| String | Required | This parameter serves two functions. It specifies the properties that will be set by the user as well as the properties that will be included in the API response, which are |
| String | Optional | Used to identify that the authenticated user is making changes to the content on behalf of the content owner. |
| String | Required | Used to specify the listing channel by using its ID. |
| String | Optional | Used to update the channel's country. |
| String | Optional | Used to update the channel description. |
Let’s update the description of our channel. To do this, we need to set the part parameter as brandingSetting. Click the “Run” button to execute the code.
Let’s understand how the above code works by breaking it down:
Lines 6–9: We declare the headers by using the
headerParametersvariable in which we pass theACCESS_TOKEN.Lines 11–13: We declare the
queryParametersvariable in which we pass thepartas a query parameter and set it tobrandingSettingsfor the call.Lines 16–23: We declare the
bodyParametersvariable, in which we define the channel ID in theidparameter and pass the updated description in thebrandingSettings.channel.descriptionparameter.
Response fields
The endpoint returns updated channel details. Some of the important response fields are as follows:
Name | Type | Description |
| String | Reflect the resource type of the API call. |
| ETag | Contains the resource ETag. |
| String | Contains the ID of the channel we are updating. |
| String | Contains the description of the channel. |
| String | Contains the title of the channel. |