ARTICLE AD BOX
I am using the videos.list endpoint of the YouTube Data API v3 to request information about multiple YouTube videos at once.
The documentation states the id parameter "specifies a comma-separated list of the YouTube video id(s) for the resource(s) that are being retrieved", but it doesn't specify how many video IDs can be included in a single request.
Requesting a small list of 5 IDs works fine with the Python library:
import googleapiclient.discovery API_KEY = "API_KEY_HERE" # https://console.cloud.google.com/apis/credentials youtube = googleapiclient.discovery.build("youtube", "v3", developerKey=API_KEY) videos_response = youtube.videos().list( part="id,snippet", id='2WwQ1JtNXdg,6xrwb6ZI5qA,u01zTDXOSLk,eOBhX6P5Is0,sbbNEfFoLhY' ).execute()However, requesting a larger list of of 100 ids returns an error "The request specifies an invalid filter parameter."
import googleapiclient.discovery API_KEY = "API_KEY_HERE" # Generated on https://console.cloud.google.com/apis/credentials youtube = googleapiclient.discovery.build("youtube", "v3", developerKey=API_KEY) videos_response = youtube.videos().list( part="id,snippet", id='2WwQ1JtNXdg,6xrwb6ZI5qA,u01zTDXOSLk,eOBhX6P5Is0,sbbNEfFoLhY,Xp_HiLIaEIM,ieKHezgE1k0,kvXjBhnDba4,dNjArFWM_qo,rY6O58WEFf0,' \ 'HIxdtfuXPl8,xJCgKKJ5gUA,U1uorPQyFog,THiakZ223Tw,Q9q66pu1qG8,secBAgPzmLQ,w6FYojPnLTc,YR-uF1qbsCg,Ha6X7ZGH1ZY,B1s2r5IZeE0,' \ 'FTwTBRBXSOA,fwfxWt_VADU,LsdYMP6VCWU,dv0kq4sqM20,YfsODnAzK_k,N6tswmHlQ4o,9ZQ_X4nG6GI,O8RGQJX8Ckk,WGHEJU_XJ7g,Vz0Mcaig8F4,' \ 'G9WUffoII0Y,JwMFqIKs3K4,vNLMQbs6Ed4,FzMgAVcecWs,9xw_5et8uaA,ahwioVnzleQ,TVW4vN_RZNE,eO70h93vsqA,eZhFqhHjKg8,KvWUsPJct4M,' \ 'btr-CE0-fL0,iV7SIaqCZtc,b6lhNz2DjbM,YsefRYAnnRQ,xHnArgOpw1g,zI3E4aZDXRg,PAhfWh1yMfo,j-DyAQWre_c,3FzQokbl5dQ,s02I7Byim3s,' \ '3imfqFnT7CE,CGMMDWUEF80,9wDs433r5C8,KlVwnG_qsoM,9ndsCEwwOrs,FVCaiaRfYhU,GTfC2gWa0pM,h_xTOIeM5iY,cdTxcDhuVjI,oCDjS4BJHqw,' \ '_6D9CyCxjPY,Y6N8PP-quBs,PwJsO82LbN0,xoFVu0BHHXI,ezadV5NaTCk,k644Rnh3WD8,dsrOunxf1tc,kezPpjBEmgY,GUWyVkVkoCU,VsxbJEspqJU,' \ 'y6uRKQZXHi4,JSJbYcjBJWY,ZNZ4rf0PHes,8jVuLJZA96k,mxJAGP6Y-Eo,jadxF42337Y,b6FMUVIOrwo,9BMNxqeO-JI,FeMagLXo3qM,nrYdqakWUi4,' \ 'JFF4gzbap7c,t3jofkT53qA,xwh6zid3P-A,_OKpuKpvk9s,qJftrfO7OvY,kRQnsKu8Avg,RFAmLkIhhX0,EE85Au3ujcg,DxDUo5c3fao,O3VOZpsxfLU,' \ 'x0IIKNJd968,bjja0UMOxJY,f7KU49sgrqM,XFLYqTtGvUk,tuDof4ZmDzg,nGZvacAem2o,Oe5F3R7S_28,1Lb0_lOcpeE,Nlv_Oc_GYFk,NIi3qagXEn8' ).execute()Error (with personal information redacted):
Traceback (most recent call last): File "c:\Users\<name>\Downloads\YouTube_api_test\YouTube_api_test.py", line 21, in <module> ).execute() ~~~~~~~^^ File "c:\Users\<name>\AppData\Local\Programs\Python\Python313\Lib\site-packages\googleapiclient\_helpers.py", line 130, in positional_wrapper return wrapped(*args, **kwargs) File "c:\Users\<name>\AppData\Local\Programs\Python\Python313\Lib\site-packages\googleapiclient\http.py", line 938, in execute raise HttpError(resp, content, uri=self.uri) googleapiclient.errors.HttpError: <HttpError 400 when requesting https://youtube.googleapis.com/youtube/v3/videos?part=id%2Csnippet&id=<long_list_of_ids>&key=<API_KEY_HERE>&alt=json returned "The request specifies an invalid filter parameter.". Details: "[{'message': 'The request specifies an invalid filter parameter.', 'domain': 'youtube.parameter', 'reason': 'invalidFilters', 'location': 'parameters.', 'locationType': 'other'}]">Is there a maximum number of video IDs allowed in the id parameter when calling video.list? If so, what is the limit?
