Hi
How to get search keywords of my own youtube videos
List listVideo = new List();
var client = new RestClient("googleapis.com/youtube/v3");
var request = new RestRequest("search", Method.GET);
request.AddParameter("part", "snippet");
request.AddParameter("type", "video");
request.AddParameter("maxResults", 100);
request.AddParameter("sortOrder", "desc");
request.AddParameter("key", "AIzaSyCFG8");
var response = client.Execute(request);
htmlTable.Append("");
htmlTable.Append("SN Channel Id / Title Video Title Description Category View Count Published ");
htmlTable.Append("");
Int32 ViewCount = 0;
foreach (var data in response.Data.items)
{
var clientTag0 = new RestClient("googleapis.com/youtube/v3/");
var tagRequest0 = new RestRequest("videos", Method.GET);
tagRequest0.AddParameter("key", "AIzaSG8");
tagRequest0.AddParameter("part", "snippet,statistics");
tagRequest0.AddParameter("id", data.id.videoId);
var tagResponse0 = clientTag0.Execute(tagRequest0);
foreach (var searchResult in tagResponse0.Data.items)
{
listVideo.Add(searchResult);
}
}
if (listVideo.Any())
Thanks
3 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Prasad RaveendranPosted Jun 30, 2024, 7:50 PM
If you're not receiving tags for your own videos despite using the correct API calls, there are a few potential issues to consider and steps to troubleshoot:
Permissions and OAuth2 Scope: Ensure that your OAuth2 token has the correct scope (
https://www.googleapis.com/auth/youtube.readonlyor broader scopes likehttps://www.googleapis.com/auth/youtubeif necessary) to access your videos' tags. If the scope is too restrictive, it may prevent fetching detailed video information.Video Privacy Settings: Check the privacy settings of your videos. If your videos are private or unlisted, they may not be accessible through the API unless you have authenticated with the appropriate permissions.
API Quotas and Limits: Verify that you haven't exceeded API quotas or limits. Google APIs have daily quotas that restrict the number of requests you can make per day. Ensure you are within your quota limits to receive complete responses.
Error Handling: Implement proper error handling to capture any API errors or exceptions that may occur during the request. This will help identify specific issues such as authentication failures or quota limits.
Verify API Responses: Log or inspect the API responses (
tagResponse0in your case) to ensure that theitemsreturned actually contain the tags (snippet.tags) you expect. Sometimes, videos may not have tags, or there could be issues with how data is processed or displayed.Here’s a checklist to help debug your implementation:
Check OAuth2 Scope: Verify that your OAuth2 token has the necessary scope (
https://www.googleapis.com/auth/youtube.readonlyor broader) to access video details including tags.Verify Video ID: Double-check that the video IDs you're querying (
data.id.videoId) are correct and belong to your channel.Review API Responses: Inspect the JSON responses from YouTube API to ensure that tags are indeed present in the
snippetpart of the video details.Test with Public Videos: Initially, test with videos that are public to ensure that your API integration and authentication flow are correctly implemented.
If you still face issues, it might help to log the raw API response (
tagResponse0.Content) to understand exactly what data is being returned and whether it includes thetagsfield for your videos. Adjustments can then be made based on the specific nature of the returned data.Ramco RamcoPosted Jun 19, 2024, 11:16 AM
Hi Prasad
It is not showing my videos. I want my own videos list's search keyworrds
Thanks
Prasad RaveendranPosted Jun 18, 2024, 2:18 AM
o retrieve the search keywords (tags) of your own YouTube videos using the YouTube Data API, you need to make a request to the
videosendpoint and include thesnippetpart in your request parameters. Here's a step-by-step guide to modifying your existing code to fetch and display these keywords:-
-
-
Explanation:Modify your request to include the
tagsfield in thesnippetpart: Ensure thepartparameter in yourvideosrequest includessnippetso that you can access the tags of the videos.Extract the tags from the response: After receiving the response from the
videosendpoint, extract thetagsfield from thesnippetobject of each video.Display the tags: Append the tags to your HTML table or any other preferred output format.
API Client Initialization: Initialize the
RestClientwith the YouTube Data API base URL (https://www.googleapis.com/youtube/v3).Search Request Setup: Set up the search request to get a list of video IDs from your channel.
Videos Request Setup: For each video ID obtained from the search response, set up another request to get detailed information about the video, including the
tags.HTML Table Construction: Construct an HTML table to display the video information along with their tags.
Data Models: Ensure you have the
VideoListResponseandYoutubeSearchListResponseclasses correctly defined to deserialize the API responses.Make sure to replace
"YOUR_API_KEY"with your actual YouTube Data API key.