Jeff
Jeff

Reputation: 43

Youtube API View count for Category

How can I get the total youtube video view count for videos in a specific category for a date range? I thought of using the videos/list [https://www.googleapis.com/youtube/v3/videos] and just iterating through that to get the total count but the filtering is only allowing to at best to get the most popular videos.

Upvotes: 0

Views: 410

Answers (1)

Android Enthusiast
Android Enthusiast

Reputation: 4950

You can use the statistics part of the Youtube API which contains the viewCount. You can retrieve the number of times the video has been viewed using statistics.viewCount. For the date range, you can include the order parameter date to specifies the method that will be used to order resources. Resources are sorted in reverse chronological order based on the date they were created.

Here a sample request for statistics:

GET https://www.googleapis.com/youtube/v3/videos?part=statistics&id=Q5mHPo2yDG8&key={YOUR_API_KEY}

Sample response:

"statistics": {
"viewCount": unsigned long,
"likeCount": unsigned long,
"dislikeCount": unsigned long,
"favoriteCount": unsigned long,
"commentCount": unsigned long
},

Upvotes: 0

Related Questions