Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 298
mittelmania Avatar asked Apr 16 '15 06:04

mittelmania


People also ask

Is there an API for YouTube Music?

The purpose of this library is to automate interactions with YouTube Music, such as retrieving your library content, managing playlists and uploading songs. To achieve this, it emulates web requests that would occur if you performed the same actions in your web browser.

Does YouTube have a search API?

Returns a collection of search results that match the query parameters specified in the API request. By default, a search result set identifies matching video , channel , and playlist resources, but you can also configure queries to only retrieve a specific type of resource. Try it now.

Can I use YouTube API for free?

YouTube Data API costs are based on quota usage, and all requests will incur at least a 1-point quota cost. For each project, you're allowed 10,000 free quota units per day.


1 Answers

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'?

like image 99
Erken Avatar answered Oct 05 '22 20:10

Erken