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

3

33

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....

Penitential answered 17/7, 2013 at 11:0 Comment(6)
I assume you can find out what videoCategories exist by querying them developers.google.com/youtube/v3/docs/videoCategories/listStomodaeum
Hi Gordon. This is where i was looking i totally couldn't work out how to query that and get an id. Any ideas?Penitential
Well, I don't have an API key but it says "Try it now" on that page and you can fire the query with the API explorer, so why not give it a shot? As far as I can see all it takes is entering the part and enable OAuth.Stomodaeum
I've tried putting various things in the 'part' parameter and cant get an id back?Penitential
Try this: part=id,snippet. regionCode=us. This is what's returned: "kind": "youtube#videoCategory", "etag": "\"rFqCJSkEICLP3Hq6a4AADI7kf48/1LzYK9Uf9Nt0hzBqNqhuHw0LPI0\"", "id": "10", "snippet": { "channelId": "UCBR8-60-B28hp2BmDPdntcQ", "title": "Music" }Gentile
@Penitential have found the videos categories id ??Stanton
O
42

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.

Over answered 19/7, 2013 at 5:55 Comment(1)
Hi, how can i get the channel list of that particular category from youtube data api, Please help me..Lauderdale
S
56

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
Sells answered 8/3, 2016 at 20:36 Comment(1)
This list will inevitably change on youtube's end and thus this list will be out of date. It should instead refer people to using the API to get the most up-to-date list instead.Affix
O
42

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.

Over answered 19/7, 2013 at 5:55 Comment(1)
Hi, how can i get the channel list of that particular category from youtube data api, Please help me..Lauderdale
S
20

At the bottom of: https://developers.google.com/youtube/v3/docs/videoCategories/list is a 'try it now' section.

Put 'snippet' in the field labelled 'part' and add a region code, e.g. GB or US in the field labelled 'regionCode'.

This will bring back a full list of categories for your chosen region.

Solangesolano answered 16/2, 2015 at 10:52 Comment(3)
Hi, how can i get the channel list of that particular category from youtube data api, Please help me...Lauderdale
snippet was the key for me thank you! I kept getting just the ids... I thought I was going crazy for a second.Affix
This does not answer the question. The user ask about the list of categories recognized by Youtube regardless any criterionKegler

© 2022 - 2024 — McMap. All rights reserved.