19

I want to get the total playtime of a youtube playlist, so first I request video id's for each element in a playlist then I request the durations for all the videos.

There is a limit to how many items the playlist returns, which is 50, so I have to make multiple requests until I get to the end of the playlist.

Youtube's Data API v3 Docs entry for /videos/list say that in the id parameter to the api you can list multiple video id's, and that pageToken "is not supported for use in conjunction with the id parameter". So I should be able to send more than 50 id's to get the entire collection back, but when I do I get a 400 response with the message "The request specifies an invalid filter parameter" ("invalidFilters").

Is there a limit to the number of id's you can send? If so, what is it?

Ignat
  • 1,142
  • 1
  • 12
  • 22

1 Answers1

27

The limit is 50 ids. You have to make a request to /videos per playlist page, you can't just have one gigantic request.

Ignat
  • 1,142
  • 1
  • 12
  • 22
  • 1
    can you point to some doc? cant find this '50' limit. https://developers.google.com/youtube/v3/docs/videos/list – Eyal Ch Jul 02 '18 at 07:50
  • @EyalCh it seems to be an arbitrary limit. I did not find any documentation for it either, and discovered this limit through trial and error. – Ignat Feb 11 '19 at 10:27
  • 2
    Came across this comments, and well it's quite hidden but its documented: https://developers.google.com/youtube/v3/docs/videos/list under "maxResults" => Acceptable values are 1 to 50, inclusive. The default value is 5. Well you can't submit 51 ids when you only can retrieve 50. – Nightking Jul 24 '19 at 12:19
  • 3
    @Nightking Currently it says that "maxResults => ... is not supported for use in conjunction with the id parameter", so that limit doesn't apply to ids. And it looks like limit for ids is not documented anywhere. – Markus Laire Sep 10 '20 at 13:28
  • @MarkusLaire Of course maxResults cannot be used when you're using the id parameter, because they are exact opposite parameters. The point is: if the limit for returned items is 50 at a time, it makes sense that the limit for input items is also 50 at a time. It's not documented, but it's a common sense inference and it seems to apply. – Tobia Sep 19 '21 at 18:05