List Our YouTube Channels

Learn about listing a channel using the YouTube Data API.

In this lesson, we’ll look at the list method of the Channels resource, which is used to list any channel data, such as channel title and description.

List a channel

In this section, we’ll list a specific channel that will be fetched according to the channel ID we passed in the query parameters. To list a channel, we’ll send a GET HTTP 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

part

String

Required

This parameter will specify all the resource properties that will be returned in the response fields. A user can set multiple comma-separated resource properties from the following options: auditDetails, brandingSettings, contentDetails, id, snippet, contentOwnerDetails, localizations, statistics, status, topicDetails.

forUsername

String

Optional

Filters the channel list based on the username.

id

String

Optional

Filters the channel list by channel ID. A comma-separated list of multiple channel IDs can be provided.

managedByMe

Boolean

Optional

Filters the channel list that is managed by the user.

mine

Boolean

Optional

Filters the channel list owned by the user.

maxResults

Integer

Optional

Used to specify the number of the response result.

Note: To call this endpoint, a user must provide one parameter from id, mine, forUsername, or managedByMe.  

Let’s call the API endpoint to filter the list of channels with our channel ID. Click the “Run” button to execute the code.

Press + to interact
import fetch from 'node-fetch';
// Define endpoint URL here
const endpointUrl = new URL('https://www.googleapis.com/youtube/v3/channels');
// Define Header Parameters here
const headerParameters = {
Authorization: 'Bearer {{ACCESS_TOKEN}}',
Accept: 'application/json',
};
// Define Query Parameters here
const queryParameters = new URLSearchParams({
part: 'snippet,id',
id: '{{CHANNEL_ID}}',
});
// Setting API call options
const options = {
method: 'GET',
headers: headerParameters,
};
// Function to make API call
async function listChannel() {
try {
endpointUrl.search = queryParameters;
const response = await fetch(endpointUrl, options);
// Printing response
printResponse(response);
} catch (error) {
// Printing error message
printError(error);
}
}
// Calling function to make API call
listChannel();

Let’s understand how the above code works by breaking it down:

  • Lines 7–10: We declare the headers by using the headerParameters variable in which we pass the ACCESS_TOKEN.

  • Lines 13–16: We declare the query parameters variable in which we define the part and id query parameters to filter the channels by using channel IDs.

  • Line 25: We define an async function named listChannel(), which is used to make an API call to the endpoint.

Response fields

The endpoint response field contains channel data. The most important ones are as follows:

Name

Type

Description

kind

String

Reflects the resource type of the API call.

etag

String

Contains the resource ETag.

pageInfo.totalResults

Integer

Contains the number of results of the API response.

items[]

List

Contains the list of channels that matches the request requirements.