获取YouTube视频的观看次数和观看时间记录通常需要通过YouTube Data API来实现。以下是使用YouTube Data API v3来获取视频统计信息的步骤:
你可以使用以下API端点来获取视频的统计信息:
GET https://www.googleapis.com/youtube/v3/videos?part=statistics&id=VIDEO_ID&key=YOUR_API_KEY
VIDEO_ID
是你想要查询的视频ID。YOUR_API_KEY
是你在Google Cloud Console中创建的API密钥。GET https://www.googleapis.com/youtube/v3/videos?part=statistics&id=dQw4w9WgXcQ&key=YOUR_API_KEY
{
"kind": "youtube#videoListResponse",
"etag": "ETAG",
"items": [
{
"kind": "youtube#video",
"etag": "ETAG",
"id": "dQw4w9WgXcQ",
"statistics": {
"viewCount": "123456789",
"likeCount": "1234567",
"dislikeCount": "12345",
"favoriteCount": "123456",
"commentCount": "12345"
}
}
]
}
领取专属 10元无门槛券
手把手带您无忧上云