Retrieve public statistics of video via youtube api

后端 未结 3 820
执念已碎
执念已碎 2021-01-14 16:42

It\'s possible to obtain public statistics of video?

Using something like this i can get just total views of video and like count:

https://www.google         


        
相关标签:
3条回答
  • 2021-01-14 17:05

    The only API call under Version 3 of the API that will get you statistics is the youtube.videos.list API

    Try this API Explorer link to try:

    https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.videos.list?part=snippet%252C+statistics&id=Ys7-6_t7OEQ&maxResults=50&_h=2&

    0 讨论(0)
  • 2021-01-14 17:06

    You would need to create YouTubeService object and can get search results for the keywords

    YouTubeService youtubeService = new YouTubeService(new BaseClientService.Initializer()
    {
      ApiKey = "dfhdufhdfahfujashfd",
      ApplicationName = this.GetType().ToString()
    });
    
     var searchListRequest = youtubeService.Search.List("snippet");
          searchListRequest.Q = "cute cats"; 
          searchListRequest.MaxResults = 10;
    
      var searchListResponse = await searchListRequest.ExecuteAsync();
      var videoId = searchListResponse.Items.First().Id.VideoId is the unique id of the video
    
    // Video Request    
    VideosResource.ListRequest request = new VideosResource.ListRequest(youTubeService, "statistics")
    {
      Id = videoId
    };
    
    VideoListResponse response = request.Execute();
    if (response.Items.First() != null && response.Items.First().Statistics != null)
    {
      Console.WriteLine(response.Items.First().Statistics.ViewCount);
    }
    
    0 讨论(0)
  • 2021-01-14 17:16

    You can get those using Analytics API

    Sample requests would help you understand.

    Analytics API is a different service but libraries come in same package and you can use same authorization with adding "https://www.googleapis.com/auth/yt-analytics.readonly" scope

    0 讨论(0)
提交回复
热议问题