I would like to use the Youtube data API search to retrieve the most viewed videos on Youtube. However, for some reason, my results are missing some videos.
Here is the API call: https://www.googleapis.com/youtube/v3/search?part=snippet&key={YOUR-API-KEY}&alt=json&type=video&order=viewCount&maxResults=50
The 13 first results returned by the API are:
9bZkp7q19f0
RgKAFK5djSk
fRh_vgS2dFE
OPf0YbXqDm0
e-ORhEE9VVg
KYniUCGPGLs
YQHsXMglC9A
nfWlot6h_JM
NUsoVlDFqZg
HP-MbfHFUqs
CevxZvSJLk8
7PCkvCPvDXk
0KSOMA3QBU0
These should be the 13 most viewed videos on Youtube at the time I queried it.
However, looking at this Youtube-made playlist:
https://www.youtube.com/playlist?list=PLirAqAtl_h2r5g8xGajEwdXd3x1sZh8hC
I can see that the video YqeW9_5kURI
, which has 1.7 billion views, should arrive in 9th position in the list returned by the API, but it doesn't. Actually, it never appears among the 500 (max) videos returned by the API.
UPDATE
Since results change every day, I did more comprehensive tests with the search API. Here is the result of the API call I mentioned above from yesterday dec. 13th (first 10 results):
- 9bZkp7q19f0
- RgKAFK5djSk
- fRh_vgS2dFE
- OPf0YbXqDm0
- e-ORhEE9VVg
- KYniUCGPGLs
- YQHsXMglC9A
- nfWlot6h_JM
- NUsoVlDFqZg
- HP-MbfHFUqs
And here is the result obtained today, dec. 14th (again, first 10 results):
- 9bZkp7q19f0
- RgKAFK5djSk
- fRh_vgS2dFE
- KYniUCGPGLs
- nfWlot6h_JM
- NUsoVlDFqZg
- YqeW9_5kURI
- HP-MbfHFUqs
- CevxZvSJLk8
- 09R8_2nJtjg
I am absolutely sure that the API call did not change between these two dates, code is exactly the same.
First anomaly: video 7 in second call (YqeW9_5kURI) does not appear in first call (this was my original post example), although its 1.7 billion views were definitely not done overnight.
Second anomaly: videos 4, 5, 7 in first call (OPf0YbXqDm0, e-ORhEE9VVg, YQHsXMglC9A) do not appear in second call, although they are still available on Youtube and still more viewed than video 5 (nfWlot6h_JM), for instance.
These anomalies repeat very often over larger sets of results.
To sum up, the search API does not seem to yield deterministic results with no query string and viewCount order, is this expected behaviour?
Or can you help me figure out what could be the reason for this?
Thanks in advance for your help, any pointers will be greatly appreciated.