In this article, we will learn how to use the YouTube API to retrieve information about a specific video on YouTube, given its video ID. The process involves using Videos.List() method of the YouTubeService class to retrieve the information and specifying the video ID as a parameter.
In a previously published article [YouTube API Integration With C# .NET], we learned how to search for and retrieve a list of videos on YouTube using the YouTube API. The process involves installing the YouTube API client library, obtaining an API key, importing the necessary namespaces and libraries, initializing the YouTube service, and using the Search.List() method of the YouTubeService class to specify the search parameters.
Here is a step-by-step guide on how to use the Videos.List() method to retrieve information about a specific video using the YouTube API in C#:
Step 1. Prerequisites
To Install the YouTube API client library, obtaining an API key, importing the necessary namespaces and libraries, initializing the YouTube service, please see my previous article on [YouTube API Integration With C# .NET].
Step 2. Initialize the YouTubeService Class
The second step is to initialize the YouTubeService class. This class is responsible for making requests to the YouTube API and processing the responses. To initialize the class, you need to pass an instance of the BaseClientService. Initializer class to its constructor. This instance should contain your API key and the name of your application.
YouTubeService youtubeService = new YouTubeService(new BaseClientService.Initializer()
{
ApiKey = "YOUR_API_KEY",
ApplicationName = "YOUR_APPLICATION_NAME"
});
Step 3. Define the Video ID
Next, you need to define the video ID of the video you want to retrieve information about. You can find the video ID in the URL of the video. For example, if the URL of the video is https://www.youtube.com/watch?v=abcdefg", the video ID is "abcdefg".
string videoId = "VIDEO_ID";
Step 4. Prepare the Request
Use the Videos.List() method to retrieve information about a specific video. Pass the video ID to the method, and set the Part parameter to “snippet, contentDetails, statistics, status”.
VideosResource.ListRequest listRequest = youtubeService.Videos.List("snippet,contentDetails,statistics,status");
listRequest.Id = videoId;
If you pass the parameter "snippet, contentDetails, statistics, status" to the Part parameter of the Videos.List() method, the following information about the video will be returned:
- Snippet
This includes information about the video's title, description, channel information, tags, and the video's publication date.
- ContentDetails
This includes information about the video's duration, aspect ratio, definition, and dimensions.
- Statistics
This includes information about the video's view count, like count, dislike count, comment count, and favourite count.
- Status
This includes information about the video's upload status, privacy status, and license information.


Join the conversation! Your thoughts help the community grow.