Youtube API get video length and views

2019-08-15 04:43发布

问题:

Is this possible? Using Youtube API v3.0 to get video length and views? I can't seem to find anything on it as all the results are for v2.0.

回答1:

The search endpoint doesn't have a way to return this info yet, but the videos endpoint can if you request the contentDetailsand the statistics in the part parameter ... something like this:

https://www.googleapis.com/youtube/v3/videos?part=contentDetails%2Cstatistics&id=voNEBqRZmBc&key={YOUR_API_KEY}

The returned object will have a duration attribute that's in ISO 8601 format (under the contentDetails), and a views attribute under the statistics.



标签: youtube-api