0

I want to get the most viewed video in the actual day and from a specific channel. But I don't know how I can do that. I'm a noob and do not know anything about the API and have now a weird problem.

I used this URL:

https://www.googleapis.com/youtube/v3/videos?channelId=UCZMsvbAhhRblVGXmEXW8TSA&chart=mostPopular&part=snippet,id&order=date&maxResults=1&regionCode=DE&key={KEY},

which should return the most viewed video from the YouTube channel of which ID is UCZMsvbAhhRblVGXmEXW8TSA and from today. I used regionCode and maxResults, but that doesn't help either.

I get a completely wrong video from a completely wrong channel. What I'm making wrong?

stvar
  • 5,871
  • 2
  • 10
  • 23
Overdrive
  • 47
  • 1
  • 16

1 Answers1

0

Unfortunately, there's no YouTube Data API endpoint that'll respond positively to your need:

get the most viewed video in the actual day and from a specific channel

On the other hand, you have to acknowledge that the Videos.list API endpoint has no request parameters named channelId and order.

You may well be confused by the Search.list API endpoint, since this endpoint does have two parameters with the names channelId and order. But this latter endpoint has no request parameter named chart.


Using the YouTube Data API, you may try to apply the following procedure:

  • Step 1: get a feed of say 50 items from the Search.list endpoint, queried with channelId set to your channel of interest, order set to viewCount and type set to video;

  • Step 2: upon waiting 24 hours, repeat the step 1; then make a difference between the two sets of data obtained for to determine the video that has the most number of views until 24 hours ago.

That's not a precise procedure, because, it may well happen that you'll have videos that appear among those obtained by step 1, while not appearing among the videos obtained by step 2 and reciprocally.

Depending on the popularity of that channel, you may have to have the cardinality of the two working sets of videos greater than 50.

Also do note that the Search.list endpoint has a fuzzy behavior. That means that one cannot expect the endpoint to function as say a search operation applied on a locally stored database.

stvar
  • 5,871
  • 2
  • 10
  • 23