user2538076
user2538076

Reputation: 173

YouTube Data API V3: Fetch multiple videoCategoryId videos

I am using YouTube Data API Version 3.0 in one of my projects to fetch my channel video details from YouTube. I don't want the user to login to his/her Google account that's why I am directly using Search.list method instead of going through the OAuth 2.0 way.

Usually I fetch data using following URL.

https://www.googleapis.com/youtube/v3/search?key={API_KEY}&maxResults=5&part=snippet&type=video&channelId={CHANNEL_ID}

Now, I want to fetch data of 5 different categories at a time. What I can do is, hit the same URL 5 times with query string as

key={API_KEY}&maxResults=1&part=snippet&type=video&channelId={CHANNEL_ID}&videoCategoryId={CATEGORY_ID}

or,

Is there a way like

key={API_KEY}&maxResults=5&part=snippet&type=video&channelId={CHANNEL_ID}&videoCategoryId={CATEGORY_ID_1, CATEGORY_ID_2, CATEGORY_ID_3, CATEGORY_ID_4, CATEGORY_ID_5}

I want to fetch only 1 video data per category. That is why I have given 5 comma separated category IDs.

Also, Search.list method does not give videoCategoryId. To get it, I have to use

https://www.googleapis.com/youtube/v3/videos?part=snippet&id={VIDEO_ID}&key={API_KEY}

Is there any way to get videoCategoryId in Search.list method?

Upvotes: 1

Views: 1785

Answers (1)

Ibrahim Ulukaya
Ibrahim Ulukaya

Reputation: 12877

  1. You need to have 5 queries for that. Even if you were able to give 5 category ids, it wouldn't understand to pick up one video data for each one.
  2. Search doesn't return videoCategory right now, videos->list has it.
  3. There is no problem going through OAuth2, you can just ask read-only permission, and should be fine. Users can pick their already stored accounts easily.

Upvotes: 3

Related Questions