Hi
I need Youtube Video Category List country wise Code/Name
CategoryId,CategoryName,CountryId,CountryName.
Thanks
Hi
I need Youtube Video Category List country wise Code/Name
CategoryId,CategoryName,CountryId,CountryName.
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Abhishek YadavRank #217 · 11.3K reputationPosted Apr 9, 2024, 1:07 AM EDT
Here is a sample code in C# to get the YouTube video category list by country:
using System; using System.Collections.Generic; using System.Net; using Newtonsoft.Json; public class VideoCategory { public string CategoryId { get; set; } public string CategoryName { get; set; } public string CountryId { get; set; } public string CountryName { get; set; } } public class YouTubeApi { public List GetVideoCategoryListByCountry(string countryCode) { string url = "https://www.googleapis.com/youtube/v3/videoCategories?part=snippet®ionCode=" + countryCode + "&key=YOUR_API_KEY"; using (WebClient client = new WebClient()) { string json = client.DownloadString(url); dynamic data = JsonConvert.DeserializeObject(json); List videoCategories = new List(); foreach (var item in data.items) { VideoCategory videoCategory = new VideoCategory { CategoryId = item.id, CategoryName = item.snippet.title, CountryId = data.regionCode, CountryName = data.items[0].snippet.country }; videoCategories.Add(videoCategory); } return videoCategories; } } } class Program { static void Main(string[] args) { var youtubeApi = new YouTubeApi(); // You can pass in the country code as a parameter to get video category list for that country List videoCategories = youtubeApi.GetVideoCategoryListByCountry("US"); foreach (var category in videoCategories) { Console.WriteLine("CategoryId: " + category.CategoryId); Console.WriteLine("CategoryName: " + category.CategoryName); Console.WriteLine("CountryId: " + category.CountryId); Console.WriteLine("CountryName: " + category.CountryName); Console.WriteLine("---------------"); } } }Please replace
YOUR_API_KEYwith your actual YouTube Data API key. Also, make sure to install theNewtonsoft.JsonNuGet package in your project.This code will fetch the video category list for a specific country and display the CategoryId, CategoryName, CountryId, and CountryName for each category.
Ramco RamcoRank #462 · 5.4K reputationPosted Apr 9, 2024, 1:20 AM EDT
Hi Abhishek
I have below code but it is not showing region option
ar client = new RestClient(); var request = new RestRequest("https://www.googleapis.com/youtube/v3/videoCategories", Method.GET); request.AddParameter("part", "snippet"); request.AddParameter("regionCode", RegionCode); request.AddParameter("key", "AIzaSyJAKHYHDJHDLs8ECKSJSG8"); var response = client.Execute(request); Root root = JsonConvert.DeserializeObject(response.Content);Thanks