3

I tried to display all videos from my youtube channel using below json url. But it only 25 videos display from this url.

https://gdata.youtube.com/feeds/api/videos?author=Anklespankin&v=2&alt=jsonc

Actually user has uploaded more than 500 videos

https://www.youtube.com/user/Anklespankin

how to get all videos.give me json solution.

I have refer Youtube Api to fetch all videos on a Channel this link but in that there is solution

   https://www.googleapis.com/youtube/v3/search?key={your_key_here}&channelId={channel_id_here}&part=snippet,id&order=date&maxResults=20"

but here i have to pass max result and if i write more than 50 i do not getting any result

Community
  • 1
  • 1
Elesh Baraiya
  • 231
  • 1
  • 6
  • 16

1 Answers1

2

You can't do it with one call. You have to do it using more calls. First, you download the first 20 videos of the user, using:

https://gdata.youtube.com/feeds/api/videos?author=Anklespankin&v=2&alt=jsonc&start-index=1&max-results=20

Then you check the totalItems property, to see how many videos he has in total. If more than 20, you fetch the others by offsetting start-index:

https://gdata.youtube.com/feeds/api/videos?author=Anklespankin&v=2&alt=jsonc&start-index=21&max-results=20
https://gdata.youtube.com/feeds/api/videos?author=Anklespankin&v=2&alt=jsonc&start-index=41&max-results=20

And so on. Of course you can use bigger numbers like max-results=50, and then you don't have to make that much calls.

Daniel Zolnai
  • 16,487
  • 7
  • 59
  • 71