mittelmania
mittelmania

Reputation: 3571

Searching only for music tracks on YouTube with the YouTube API

I'd like to use the YouTube API (v3) to enable searches of only music tracks (no cats or vines or any other non-musical video). I looked in the API Explorer and the docs for any pointers on that matter, but could not find any helpful information.

How can I search for music only? Is it also possible to filter the search results by year of release or music genre?

Upvotes: 9

Views: 13602

Answers (2)

Dulanjana Abeyrathna
Dulanjana Abeyrathna

Reputation: 91

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}

Upvotes: 1

Erken
Erken

Reputation: 1448

The best you can do is to add a videoCategoryId parameter in your query to the YouTube Data API. This ensures that only videos belonging to this category are returned.

As referenced in this other Stackoverflow question, the videoCategoryId for music in the US and elsewhere where music is allowed is 10.

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

Upvotes: 10

Related Questions