Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

youtube

video

I am wondering if there is a way to query YouTube for multiple random videos (video id's are known) in a single query? I am storing video id's in the local db and need to show multiple details(list with thumbs, rating, author name,etc.) in the web page.

I am looking at the Youtube Data API and see that I can a single entity data like this:

Uri  videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/video_id");
Video video = request.Retrieve<Video>(videoEntryUrl);

Repeating this in the loop seems to be a bad idea, because of the quotas.

There is also "batch processing" available - http://code.google.com/apis/youtube/2.0/developers_guide_dotnet.html#Batch_processing. Seems like I can issue up to 50 random request, but it expects some feed I don't have as a parameter, when executing batch. There is an overload with some Uri, but it is not documented well - google-gdata.googlecode.com/svn/docs/folder59/M_Google_GData_Client_FeedRequest_1_Batch__1_2.htm

Does anybody have any ideas on how to retrieve multiple video entries by id's? Any help would be appreciated.

like image 252
Juri Avatar asked Jan 16 '10 16:01

Juri


1 Answers

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.

like image 134
harishannam Avatar answered Oct 12 '22 01:10

harishannam