Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Youtube API - Title only

I know that i can get the whole info about a video by using:

http://gdata.youtube.com/feeds/api/videos/ID

but that outputs a lot of information and im using a regular expression to get the title out of it. I was wondering if there was a way to let that page only output the title and not all the other stuff that i dont need.

like image 212
ted Avatar asked Jan 14 '11 12:01

ted


People also ask

Is YouTube API key free?

YouTube Data API costs are based on quota usage, and all requests will incur at least a 1-point quota cost. For each project, you're allowed 10,000 free quota units per day. You can use the quota calculator to determine your quota costs.

Does YouTube API have a limit?

Projects that enable the YouTube Data API have a default quota allocation of 10,000 units per day, an amount sufficient for the majority of our API users. You can see your quota usage on the Quotas page in the API Console.

Does YouTube API cost money?

The YouTube Data API, is a free API google does not charge you for accessing this api. You are free to use it. THere for no billing account is needed in order to access this api. You do have a quota which limits the number of request that you can make to the api over a period of time.

What is snippet in YouTube API?

The snippet object contains basic details about the video, such as its title, description, and category. The date and time that the video was published. Note that this time might be different than the time that the video was uploaded.


2 Answers

Not sure if this will help since I've never worked with youtube api before. I just ran across this info yesterday. According to http://dl.google.com/googleio/2010/googleapis-how-google-builds-apis.pdf you can do a Partial Get (just search that pdf for "Partial Response") by using fields=entry(title) (though I think it's for searching for videos). By querying for the actual video id instead of a string it will return just that one video.

Example:

http://gdata.youtube.com/feeds/api/videos?v=2&q=[video_id]&max-results=1&fields=entry(title)&prettyprint=true
like image 131
Aaron W. Avatar answered Sep 24 '22 19:09

Aaron W.


<?
$id = 'VIDEOID';
$xmlData = simplexml_load_string(file_get_contents("http://gdata.youtube.com/feeds/api/videos/{$id}?fields=title"));

$title = (string)$xmlData->title;

echo $title;
like image 40
Oliver O'Neill Avatar answered Sep 24 '22 19:09

Oliver O'Neill