【问题标题】:How to get subscriber count and videos count for a given YouTube channel?如何获取给定 YouTube 频道的订阅者数量和视频数量?
【发布时间】:2015-08-16 18:09:52
【问题描述】:

到目前为止,我一直在使用此 URL 来检索频道的订阅人数:

http://gdata.youtube.com/feeds/api/users/<channel_id>?v=2&alt=json

还有这个获取频道视频数量的 URL:

https://gdata.youtube.com/feeds/api/users/<channel_id>/uploads?v=2&alt=jsonc&max-results=0

但从今天起,Google 停止使用它的 v2 API,我找不到这些数据的替代选项。

【问题讨论】:

    标签: youtube youtube-api youtube-data-api


    【解决方案1】:

    您将希望使用 Channels/list 端点作为 statistics 的传递 part 参数。

    请求:

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

    回复(id=UCt7iVnJwjBsof8IPLJHCTgQ):

    {
     "kind": "youtube#channelListResponse",
     "etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/WNxXCvycTyqTjTn9sLJ5toVjBRY\"",
     "pageInfo": {
      "totalResults": 1,
      "resultsPerPage": 1
     },
     "items": [
      {
    
       "kind": "youtube#channel",
       "etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/jijTuA_iWn2Kv9aRnqeAWNAcQ6I\"",
       "id": "UCt7iVnJwjBsof8IPLJHCTgQ",
       "statistics": {
        "viewCount": "796662",
        "commentCount": "20",
        "subscriberCount": "257",
        "hiddenSubscriberCount": false,
        "videoCount": "126"
       }
      }
     ]
    }
    

    您可以为id 参数传入以逗号分隔的频道ID 列表。因为我只传入了一个id,所以items 数组的第一个对象将具有您需要的值。在 statistics 字典中为您想要的数据获取 subscriberCountvideoCount 值的对象。

    【讨论】:

    • 有没有不认证的api?
    • @VivekSancheti 没有密钥就没有 api
    猜你喜欢
    • 1970-01-01
    • 2015-09-27
    • 1970-01-01
    • 2021-06-05
    • 2021-02-19
    • 2018-04-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多