问题描述
对于YouTube API的channel.list功能,您可以调用YouTube上任何频道的统计信息吗?查看以下调用参数,似乎所有人都需要您成为该频道的所有者才能接收该频道上的任何信息。
我还尝试了API测试,以查看是否可以通过用户名获得通道的数据,但似乎不起作用。初学者,所以如果有人可以帮忙,我将不胜感激!
解决方法
您不必成为频道的所有者,只需要频道ID。您可以在公共channel.list上使用try me对其进行测试,以进行公共api调用。
请求
GET https://www.googleapis.com/youtube/v3/channels?part=snippet%2CcontentDetails%2Cstatistics&id=UCeY0bbntWzzVIaj2z3QigXg&key=[YOUR_API_KEY] HTTP/1.1
Accept: application/json
响应
{
"kind": "youtube#channelListResponse","etag": "y2BDT1Qkcr2Fm2FAHjDfG6Gn8Sc","pageInfo": {
"resultsPerPage": 1
},"items": [
{
"kind": "youtube#channel","etag": "VCwefXyl53bCqIREF0zJeTfxZXk","id": "UCeY0bbntWzzVIaj2z3QigXg","snippet": {
"title": "NBC News","description": "» Subscribe to NBC News:","customUrl": "nbcnews","publishedAt": "2006-07-19T20:46:03Z","thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/a/AATXAJzjPejETKc2lrL43-9gFFWRL9WKwEmOIvtbWyait1c=s88-c-k-c0xffffffff-no-rj-mo","width": 88,"height": 88
},"medium": {
"url": "https://yt3.ggpht.com/a/AATXAJzjPejETKc2lrL43-9gFFWRL9WKwEmOIvtbWyait1c=s240-c-k-c0xffffffff-no-rj-mo","width": 240,"height": 240
},"high": {
"url": "https://yt3.ggpht.com/a/AATXAJzjPejETKc2lrL43-9gFFWRL9WKwEmOIvtbWyait1c=s800-c-k-c0xffffffff-no-rj-mo","width": 800,"height": 800
}
},"localized": {
"title": "NBC News","description": "» Subscribe to NBC News: "
}
},"contentDetails": {
"relatedPlaylists": {
"likes": "","favorites": "","uploads": "UUeY0bbntWzzVIaj2z3QigXg","watchHistory": "HL","watchLater": "WL"
}
},"statistics": {
"viewCount": "1942288925","commentCount": "0","subscriberCount": "3700000","hiddenSubscriberCount": false,"videoCount": "25734"
}
}
]
}