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

后端 未结 3 509
慢半拍i
慢半拍i 2020-12-04 20:06

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


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-04 20:53

    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®ionCode={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.

提交回复
热议问题