Searching only for music tracks on YouTube with the YouTube API
Asked Answered
T

2

9

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?

Topeka answered 16/4, 2015 at 6:45 Comment(2)
Refer following thread: code.google.com/p/gdata-issues/issues/detail?id=5341Msg
The link is a complaint from 2013 that does not offer any solution, hence not helpfulTopeka
U
10

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

Ushijima answered 18/12, 2015 at 9:17 Comment(1)
This seems not working for the likes videos of a given user.Buttonwood
L
1

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}

Lamblike answered 31/10, 2022 at 17:28 Comment(1)
developers.google.com/youtube/v3/docs/videoCategories/list to get video category list and here is example for it issuetracker.google.com/issues/35173856Lamblike

© 2022 - 2024 — McMap. All rights reserved.