Youtube Data API: Retrieving multiple Video entries by IDs in a single request

有些话、适合烂在心里 提交于 2019-12-02 23:38:16

I too had exactly the same problem, I needed a list of video objects related to an arbitrary list of video id's, i.e. not conforming to any of the feeds.

The batch processing option is very tempting, but the implementation seems quite heavy for what should be pretty simple functionality.

At the end of the day, doing a basic video search for the id's separated by pipe "|" achieves the required result:

http://gdata.youtube.com/feeds/api/videos?q=h5jKcDH9s64|elzqvWXG1Y

Hope this helps

In Youtube Data API version 3.0 You can do it in a simple way like this.

https://www.googleapis.com/youtube/v3/videos?key=API_KEY&part=snippet&id=video_id1,video_id2

Just add your video ids separated by comma. It will fetch you the data for all videos in JSON

I dont know what is the limit on this, will update the answer once I find it.

RobD's answer works well. You can add something like this to the end of the URL to only retrieve the data you actually need, saving some bandwidth:

&fields=entry(id,title)

eg:

http://gdata.youtube.com/feeds/api/videos?q=h5jKcDH9s64|elzqvWXG1Y&fields=entry(id,title)

Here's a clearer explanation for the non PHP people

http://oktryitnow.com/?p=83

You can send multiple requests to youtube data api wrapped in a single request. YouTube allows you to send at most 50 multiple requests in a single request. This kind of request is known as a batch processing request. I have developed a working piece of code specifically for this problem. I had to do same kind of thing for a website I was working on. Anyways you can see how to do it from here (sample code is also present for download): http://www.ovaistariq.net/2010/06/youtube-batch-processing-requests-made-less-costly/

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