How does one pull statistics (either daily or over time) from the YouTube API

匆匆过客 提交于 2020-01-04 21:39:48

问题


I'm looking through the documentation for the YouTube API and they talk about statistics in their list of things that a user can pull, but I'm at a loss as to how to do the following.

The specific data I need is views per day for a given video. I am happy to pull this one-by-one, or as an entire channel, and either in large chunks of time (with each one saying what date it was viewed on) or day by day, where I'd run a report daily to see what the view count is for that day. However, the only param I see in there relating to this is "time" and when I give it a param of "today" it returns the same global all-time view count for a given video. In any event, time appears to apply only to live video (at least in how it's placed in the doc) so, I'm totally stumped. Maybe there's another doc that I just haven't found that details how one does this exact thing?

All help greatly appreciated.


回答1:


As polynomial said, since the video data isn't constrained by any time periods you should really pull the data every every day if you want day by day statistics.

However, it is possible to retrieve Youtube's video statistics which show historical data (ex: http://sente.cc/misc/yt_video_stats.png) This data isn't available through the API but it can be scraped without too much difficulty.

I didn't have any trouble creating this tool: http://sente.cc/scripts/yt_stats?tcquYYKurJ8




回答2:


The "time" field is used to constrain results formatted as a list, for example comments or live events. You cannot use it to constrain view counts for a video.

You may want to look into retrieving live events for a video to produce the data you want, though it will be constrained to time periods between defined events.



来源:https://stackoverflow.com/questions/7650767/how-does-one-pull-statistics-either-daily-or-over-time-from-the-youtube-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!