Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YouTube API V3: Where can i find a list of each 'videoCategoryId'?

Tags:

I'm using the Youtube API V3 but can't find documentation for how to filter by category:

Here's my code:

$results = $youtube->search->listSearch('id,snippet', array(     'q' =>                  $_GET['q'],     'maxResults' =>         20,     'type' =>               'video'     'videoCategoryId' =>    'what-do-i-put-here?', )); 

I've been going through their documentation for an hour and can't seem to find any reference to how I find out what the various category's ids are. In my case I'm looking for the videoCategoryId for music....

like image 248
Haroldo Avatar asked Jul 17 '13 11:07

Haroldo


People also ask

How can I get a list of all my YouTube videos on my channel?

There are two steps: Query Channels to get the "uploads" Id. eg https://www.googleapis.com/youtube/v3/channels?id={channel Id}&key={API key}&part=contentDetails. Use this "uploads" Id to query PlaylistItems to get the list of videos.

What data can you get from YouTube API?

The API provides the ability to retrieve feeds related to videos, users, and playlists. It also provides the ability to manipulate these feeds, such as creating new playlists, adding videos as favorites, and sending messsages.


2 Answers

Using YouTube API v3 video category id list by Dinesh Gowtham Prathap at https://gist.github.com/dgp/1b24bf2961521bd75d6c

1 - Film & Animation  2 - Autos & Vehicles 10 - Music 15 - Pets & Animals 17 - Sports 18 - Short Movies 19 - Travel & Events 20 - Gaming 21 - Videoblogging 22 - People & Blogs 23 - Comedy 24 - Entertainment 25 - News & Politics 26 - Howto & Style 27 - Education 28 - Science & Technology 29 - Nonprofits & Activism 30 - Movies 31 - Anime/Animation 32 - Action/Adventure 33 - Classics 34 - Comedy 35 - Documentary 36 - Drama 37 - Family 38 - Foreign 39 - Horror 40 - Sci-Fi/Fantasy 41 - Thriller 42 - Shorts 43 - Shows 44 - Trailers 
like image 131
Alaa Sadik Avatar answered Sep 17 '22 13:09

Alaa Sadik


Video categories are region specific -- that's why the category list service requires either a category ID or a region, but not both. This endpoint:

https://www.googleapis.com/youtube/v3/videoCategories?part=snippet&regionCode={two-character-region}&key={YOUR_API_KEY}

will return all categories, along with their ids, for a given region. So as Ikai Lan pointed out in the comments, the ID for music is '10' in the US and, in fact, in all regions where this category is allowed; but there may be some regions where it isn't allowed, or some regions that aren't supported at all.

like image 32
jlmcdonald Avatar answered Sep 21 '22 13:09

jlmcdonald