Get View Count in YouTube V3 API for java

最后都变了- 提交于 2019-12-01 01:34:57

After getting the "id" here, you should do a videos->list call, to get video properties like "viewcount".

Here's sample: https://github.com/youtube/api-samples/blob/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline/data/GeolocationSearch.java#L142

OK I got it the code to do it is:

YouTube.Videos.List list = youtube.videos().list("statistics");
list.setId("kffacxfA7G4");
list.setKey("your private API KEY");            
Video v = list.execute().getItems().get(0);
        System.out.println("The view count is: "+v.getStatistics().getViewCount());

This video BTW exceed the billion views - Justim Bieber rules! (-;

Once you get a video id, you could make a Video-List get call with the below query parameters.

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

You could try Youtube api v3 tool to check https://developers.google.com/youtube/v3/docs/videos/list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!