Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Youtube API Search doesn't retrieve all videos in the channel

Tags:

youtube-api

I have to retrieve all video of my channel with Youtube API. All videos are published on Youtube and I can see them correctly.

I tried to make the request directly from this page: https://developers.google.com/youtube/v3/docs/search/list and this is the example request: GET http s://www.googleapis.com/youtube/v3/search?part=snippet&channelId=myChannelID&maxResults=50&key={YOUR_API_KEY}

Request doesn't retrieve all videos, it returns only 7 on the total of 9. All videos have the same configuration. Missing videos are always the same.

If I use the video API passing the ID of one of those videos excluded from the search response, it returns a correct response and it belong correctly to my channel: https://developers.google.com/youtube/v3/docs/videos/list#try-it

Someone can help me?

thank you in advance

Francesco

like image 266
Devs Yakamoz Avatar asked Dec 20 '22 04:12

Devs Yakamoz


1 Answers

The answer to "How do I obtain a list of all videos in a channel using the YouTube Data API v3?" here may be what you need. Look especially at the video linked to in the answer.

To summarize, to get all the uploads from a channel, you need to get the items from the uploads playlist for the channel using playlistItems.list on that playlist's ID rather than calling search.list on the channel ID.

Try this two-step approach:

  1. Get the ID of your channel's uploads playlist using the channels.list API call: GET https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id={YOUR_CHANNEL_ID}&key={YOUR_API_KEY}
  2. Get the videos from the uploads playlist using the playlistItems.list call: GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=3&playlistId={YOUR_PLAYLIST_ID}&key={YOUR_API_KEY}
like image 88
mmirus Avatar answered Apr 19 '23 11:04

mmirus