Hi Jayraj
I am trying like below . How further to be done. I want to display Channel Name,Video Title,Description,Search Keywords of that video
var clientTag = new RestClient("googleapis.com/youtube/v3/");
var tagRequest = new RestRequest("videos", Method.GET);
tagRequest.AddParameter("key", "AIzaSyKSHDHYDHDYD6Q9b5LsKYHT8");
Thanks
Ramco RamcoPosted Apr 5, 2024, 11:51 AM
Hi Naimish
I want to get these keywords . Secondly to start with i want my own videos. What changes i need to do.
Thanks
Naimish MakwanaPosted Apr 5, 2024, 11:37 AM
Yes, your code is almost correct. You’re correctly using the
searchendpoint to get a list of videos and then using thevideosendpoint to get the details of each video. However, you need to make sure that thesnippetpart is included in thepartparameter when you’re making the request to thevideosendpoint, as thetagsfield is part of thesnippet.Here’s how you can modify your code to get the search keywords (tags) of each video:
In this code,
YoutubeSearchListResponse,VideoListResponse, andItemare classes that represent the structure of the API response. You need to define these classes according to the API response structure.Please note that the YouTube Data API does not provide the search keywords of a video directly. The
tagsfield in thesnippetof a video resource contains the keywords of the video, but this field is only included for videos that are owned by the authenticated user. If you want to get the keywords of your videos, you need to authenticate with OAuth 2.0 and use thevideos.listmethod with theidparameter set to the IDs of your videos.Thanks
Ramco RamcoPosted Apr 5, 2024, 11:11 AM
Hi Naimish
Can u pls help according to my code. Is it possible through below code that i will be able to get Search Keywords Video Wise
Thanks
Naimish MakwanaPosted Apr 5, 2024, 10:55 AM
Please try below code.
And here’s how you can use these classes with your existing code:
Please note that this code assumes that you have the
RestSharpandNewtonsoft.Jsonlibraries installed in your project. If not, you can install them via NuGet Package Manager.Thanks
Ramco RamcoPosted Apr 5, 2024, 10:46 AM
Hi Naimish
I am getting error IRestResponse does not contain a definition for data. Secondly i want to get Search Keywordsof my Videos
Thanks
Naimish MakwanaPosted Apr 5, 2024, 10:38 AM
The error message indicates that the YouTube API expects a filter parameter, such as
myRating,id, orchart. In your case, you’re trying to get details of videos, so you should use theidparameter. However, you’ve commented out the line where you add theidparameter.If you want to loop through all your short videos, you need to have a list of all the video IDs. Once you have this list, you can loop through it and make a request for each video ID.
Here’s an example of how you can do it:
Please replace
"videoId1","videoId2","videoId3"with your actual video IDs. This code will loop through each video ID in the list, make a request to the YouTube API, and extract the required details.Remember to handle potential exceptions and errors in your code. This includes checking if the video id is valid and handling the case where the video might not have any tags.
Note: Be careful not to expose your API key (
AIzKSHHDHGDt6cGJDKDJQ9b5Ls8EDISJ8) in a public or insecure environment, as it could be used by others to access your Google API services. It’s always a good practice to store sensitive information like this in a secure way (like environment variables or secure app config).Thanks
Ramco RamcoPosted Apr 5, 2024, 10:27 AM
Hi
I am getting below error. I want to loop through all my Short Videos.
Below is the code
Thanks
Jayraj ChhayaPosted Apr 5, 2024, 9:09 AM
To achieve this, you need to make a request to the YouTube Data API endpoint for videos and specify the
partparameter to include the information you need (e.g., snippet). Additionally, you can use theidparameter to specify the video ID for the video you are interested in.