【问题标题】:How to get YouTube channel statistics like last 28 days using data api?如何使用数据 api 获取最近 28 天的 YouTube 频道统计信息?
【发布时间】:2022-01-20 03:40:32
【问题描述】:

我正在尝试获取过去 28 天的 youtube 频道统计信息,例如

  1. 全视图
  2. 平均每日观看次数
  3. 频道国家
  4. 过去 28 天的观看次数
  5. 平均每日订阅人数
  6. 列表项

我得到了所有其他的东西,但这些没有。

目前我正在使用这个

https://www.googleapis.com/youtube/v3/videos?id=PBrEq9Wd6_U&key=[API_KEY]&part=snippet,contentDetails,statistics,status

收到回复

    {
  "kind": "youtube#videoListResponse",
  "etag": "xdV7ewWgCsOTS7cf0XUF8Fp9Xg4",
  "items": [
    {
      "kind": "youtube#video",
      "etag": "dZDlRrNH8pJOOeV8rPpuQcUaeKU",
      "id": "PBrEq9Wd6_U",
      "snippet": {
        "publishedAt": "2021-10-20T16:00:12Z",
        "channelId": "UC5DNytAJ6_FISueUfzZCVsw",
        "title": "Candy Crush in React",
        "description": "In this video I show you how to make a game of Candy Crush in React!\n\n00:00 Introduction\n01:37 Setting up our project\n07:25 Creating our Game Board\n24:48 Checking for matches\n42:46 Moving Candies down\n48:42 Dragging and Dropping in React\n01:07:20 Adding Images in React\n01:11:43 Adding the score\n01:17:25 Checking for blanks\n01:19:23 Suggestions for refactoring\n01:20:00 Where to go next? Saving High Scores (https://youtu.be/ARL0NuIQNjY)\n\nFinal code available here: https://github.com/kubowania/candy-crush-reactjs\nLearn how to add Game State in a database: https://youtu.be/ARL0NuIQNjY\n___\n⭐ Use promo code ANIAKUBOW for 3 months free of WebStorm IDE here (I get no commission from this link, but am in a partnership): https://jb.gg/get_webstorm\n\n⭐ New to code and none of this is making sense? Watch my '12hr+ YouTube Coding Bootcamp' in which you will learn HTML, CSS and JavaScript Fundamentals completely from scratch. It's on my channel and its 100% free.\n\n⭐ In most videos I use Tabnine as my A.I autocompletion tool. You can download it for free here (I get no commission from this link, but am in a partnership): ",
        "thumbnails": {
          "default": {
            "url": "https://i.ytimg.com/vi/PBrEq9Wd6_U/default.jpg",
            "width": 120,
            "height": 90
          },
          "medium": {
            "url": "https://i.ytimg.com/vi/PBrEq9Wd6_U/mqdefault.jpg",
            "width": 320,
            "height": 180
          },
          "high": {
            "url": "https://i.ytimg.com/vi/PBrEq9Wd6_U/hqdefault.jpg",
            "width": 480,
            "height": 360
          },
          "standard": {
            "url": "https://i.ytimg.com/vi/PBrEq9Wd6_U/sddefault.jpg",
            "width": 640,
            "height": 480
          },
          "maxres": {
            "url": "https://i.ytimg.com/vi/PBrEq9Wd6_U/maxresdefault.jpg",
            "width": 1280,
            "height": 720
          }
        },
        "channelTitle": "Code with Ania Kubów",
        "tags": [
          "candy crush",
          "react tutorial",
          "react game",
          "gamedev",
          "software engineering",
          "software development",
          "learn to code",
          "coding bootamp",
          "100daysOfcode",
          "javascript tutorial for beginners",
          "javascript tutorial",
          "react for beginners",
          "candy crush development"
        ],
        "categoryId": "27",
        "liveBroadcastContent": "none",
        "localized": {
          "title": "Candy Crush in React",
          "description": "In this video I show you how to make a game of Candy Crush in React!\n\n00:00 Introduction\n01:37 Setting up our project\n07:25 Creating our Game Board\n24:48 Checking for matches\n42:46 Moving Candies down\n48:42 Dragging and Dropping in React\n01:07:20 Adding Images in React\n01:11:43 Adding the score\n01:17:25 Checking for blanks\n01:19:23 Suggestions for refactoring\n01:20:00 Where to go next? Saving High Scores (https://youtu.be/ARL0NuIQNjY)\n\nFinal code available here: https://github.com/kubowania/candy-crush-reactjs\nLearn how to add Game State in a database: https://youtu.be/ARL0NuIQNjY\n___\n⭐ Use promo code ANIAKUBOW for 3 months free of WebStorm IDE here (I get no commission from this link, but am in a partnership): https://jb.gg/get_webstorm\n\n⭐ New to code and none of this is making sense? Watch my '12hr+ YouTube Coding Bootcamp' in which you will learn HTML, CSS and JavaScript Fundamentals completely from scratch. It's on my channel and its 100% free.\n\n⭐ In most videos I use Tabnine as my A.I autocompletion tool. You can download it for free here (I get no commission from this link, but am in a partnership):"
        },
        "defaultAudioLanguage": "en-GB"
      },
      "contentDetails": {
        "duration": "PT1H21M1S",
        "dimension": "2d",
        "definition": "hd",
        "caption": "false",
        "licensedContent": true,
        "contentRating": {},
        "projection": "rectangular"
      },
      "status": {
        "uploadStatus": "processed",
        "privacyStatus": "public",
        "license": "youtube",
        "embeddable": true,
        "publicStatsViewable": true,
        "madeForKids": false
      },
      "statistics": {
        "viewCount": "150594",
        "likeCount": "5017",
        "favoriteCount": "0",
        "commentCount": "232"
      }
    }
  ],
  "pageInfo": {
    "totalResults": 1,
    "resultsPerPage": 1
  }
}

【问题讨论】:

    标签: youtube-api youtube-data-api


    【解决方案1】:

    AFAIK 您无法向 YouTube Data API v3 请求过去的数据。但是,通过定期从 YouTube 检索数据,您将能够在未来获得这些统计信息。

    1. 总视图:使用Channels: list 确保在part 中包含statistics
    2. 平均每日浏览量:我让您在定期检索所需数据后进行数学计算。
    3. 频道国家/地区:AFAIK 频道国家/地区并未在所有 YouTube 频道上定义,但如果已定义,您可以使用 Channels: listsnippet part 中获取它
    4. 过去 28 天的观看次数:我让你算算
    5. 平均每日订阅者:如果您在part 中使用statistics,则可以使用Channels: list 检索subscriberCount。警告:众所周知,这个数字是由 YouTube 和 AFAIK 四舍五入的,没有任何方法可以得到更准确的计数器
    6. 列表项:我不明白你的意思,你能添加精确度作为评论,我会编辑我的答案吗?您的意思是列出您的视频吗?

    【讨论】:

    • 我正在创建一个应用程序,用户可以在其中查看所有详细信息,例如过去 30 天的订阅人数、过去 30 天的视频浏览量、按频道 ID 统计的任何 YouTube 频道的月收入
    • 是的,所以你需要一个应用程序的后端。但是我不明白你试图用你的评论让我理解的意思。
    • 我只创建前端应用程序以仅通过通道 id 获取这些数据
    • 那似乎是不可能的。很明显,您需要一个后端。
    • 所有数据都来自 YouTube api 那我为什么要创建呢?
    猜你喜欢
    • 2021-01-23
    • 2013-01-16
    • 1970-01-01
    • 2018-12-05
    • 2017-12-06
    • 2019-09-20
    • 2016-09-13
    • 2016-02-25
    • 2020-10-22
    相关资源
    最近更新 更多