无法使用 youtube 数据获取 youtube 频道统计信息 api v3

Unable to get youtube channel statistics using youtube data api v3

我已经创建了 google 项目并使用了下面 url 中的 youtube 数据 api v3 密钥,但没有获得频道统计信息。

https://www.googleapis.com/youtube/v3/channels?parts=statistics&id=UCQ_jR_iUmDsR50GX33qWvog&key=AIzaSyBDEjJeaI2QEzNuFNrjPAsFHl1Jin9JWsw

输出如下

  "kind": "youtube#channelListResponse",
  "etag": "5PVGuDob8dxpfgpaJGWruEW8hV8",
  "pageInfo": {
    "resultsPerPage": 1
  },
  "items": [
    {
      "kind": "youtube#channel",
      "etag": "Z0A5YSAnQtcEnTTvtERboPwQAk0",
      "id": "UCQ_jR_iUmDsR50GX33qWvog"
    }
  ]
}

假设您正在使用 channel.list I think you should check your code I just tested this with your same request and it works fine from here. tryme

要求:

curl \
  'https://www.googleapis.com/youtube/v3/channels?part=statistics&id=UCQ_jR_iUmDsR50GX33qWvog&key=[YOUR_API_KEY]' \ 
  --header 'Accept: application/json' \
  --compressed

回应

{
  "kind": "youtube#channelListResponse",
  "etag": "1a3o4gpa3kaJyNIWXi2yvRgmk4s",
  "pageInfo": {
    "resultsPerPage": 1
  },
  "items": [
    {
      "kind": "youtube#channel",
      "etag": "S7lD_zHbbGaTaOHU3iEyjECpr0c",
      "id": "UCQ_jR_iUmDsR50GX33qWvog",
      "statistics": {
        "viewCount": "488",
        "commentCount": "0",
        "subscriberCount": "2",
        "hiddenSubscriberCount": false,
        "videoCount": "13"
      }
    }
  ]
}

来自评论问题的回答

How your project is able to access my youtube channel?

您正在使用授予访问 public 数据的 API 密钥。这也是我正在做的。您频道的统计数据是 public 数据。

Like you testing it on browser it is working but I copy the same python code to my local machine and try to run it is promoting for key.

您没有 post 您的代码我无法帮助您。你所展示的显示了一个硬编码的 public key= paramater.

how to bypass or get rid of prompt?

我正在使用 public api 键,在请求​​ public 数据时没有提示。