0

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):

  1. 9bZkp7q19f0
  2. RgKAFK5djSk
  3. fRh_vgS2dFE
  4. OPf0YbXqDm0
  5. e-ORhEE9VVg
  6. KYniUCGPGLs
  7. YQHsXMglC9A
  8. nfWlot6h_JM
  9. NUsoVlDFqZg
  10. HP-MbfHFUqs

And here is the result obtained today, dec. 14th (again, first 10 results):

  1. 9bZkp7q19f0
  2. RgKAFK5djSk
  3. fRh_vgS2dFE
  4. KYniUCGPGLs
  5. nfWlot6h_JM
  6. NUsoVlDFqZg
  7. YqeW9_5kURI
  8. HP-MbfHFUqs
  9. CevxZvSJLk8
  10. 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.

bmartin
  • 1
  • 3

1 Answers1

0

Try to include filtering parameters like chart. The chart parameter identifies the chart that you want to retrieve. mostPopular retruns the most popular videos for the specified content region and `video category.

If successful, this method returns a response body with the following structure:

{
  "kind": "youtube#videoListResponse",
  "etag": etag,
  "nextPageToken": string,
  "prevPageToken": string,
  "pageInfo": {
    "totalResults": integer,
    "resultsPerPage": integer
  },
  "items": [
    video Resource
  ]
}
Android Enthusiast
  • 4,826
  • 2
  • 15
  • 30
  • Many thanks for your reply. Unfortunately, mostPopular and mostViewed are two different things: popular videos may be recent videos with big momentum according to Google's algorithm, although most viewed videos account for the total number of views since publication. And I need the latter... – bmartin Dec 14 '16 at 13:21