Youtube API search - youtube-api

I have been trying out the youtube API with Java. When I do a search using the API I don't get the same results as when I just type the keyword in the browser, any logical explanation why this is?
Compare: http://www.youtube.com/results?search_query=blah+&aq=f
http://pastebin.com/FVRd3URT (list of video Titles)
I also noticed that some videos (or at least their title) are duplicated.

YouTube API version 3 gets the same search results. Version 3 is still experimental, according to the documentation. https://developers.google.com/youtube/v3/docs/search/list

No, it's just how it is. Trying to match up the two is a futile exercise.
Amazon search has the same problem.

This demo might help.
https://github.com/bitsabhi/YouTubeDemo
A java project to return title, album, you tube link when the user searches for any songs. Uses You tube search API.

I have the same problem.
It is as if the API queries don't support full text search - results through the API are the same as if you enter "my search query" in quotes.
Although, try setting a slightly larger time frame: 'today' might be different from 'last_week', and you may get more relevant results.

Related

YouTube API is not giving accurate video results

Getting video in the results even though it didn't match query parameter(q)
The parameter i passed didn't exists in body,title,tags, But the video is relavant. Is API looks any other metadata of video.
For Example: i have given parameter as "mobile", this video https://www.youtube.com/watch?v=j8UNo3vRIB0 is coming as result, here video title and description not contain mobile as parameter
Latest data not coming consistently in youtube api
Some times latest data not coming in youtube data api.
For Example: i have given rule as "amazon". This video https://www.youtube.com/watch?v=6zygd1iW-f4 is showing in youtube website's latest videos but not coming in youtube api result.
Example query: https://www.googleapis.com/youtube/v3/search?part=snippet&order=date&q=amazon&maxResults=50&type=video&key=xyz
W.r.t. point (1), Youtube is working OK, since the content of that video is related to the keyword mobile (please convince yourself by watching the first couple of minutes of that video).
For what concerns your point (2), I cannot in any way make the Youtube site to produce the video 6zygd1iW-f4 near the top of its search result set for the query term amazon.
All in all, I deem your claims above unsustainable.
Please note that one cannot expect crisp results from Youtube when queried with such general terms as yours is. One should not expect Youtube's searching feature to work similarly to say a full-text search in single computer-stored database. There will always be a degree of fuzziness associated to querying Youtube for broad terms.
You are actually stumbling on a very tricky scenario. Your goal is to get the same results via the API that you also see on YouTube’s website, right?
First, make sure that you configured the search endpoint as identical to your YouTube user account as possible:
order: relevance
relevanceLanguage: Same as the language that you set in the menu of YouTube’s website (Use a ISO 639-1 2-letter Code)
regionCode: Same as the country that you set in the menu of YouTube’s website (Use a ISO 3166-1 2-letter Code)
With these settings you will see that the results will be quite similar. But still not identical. Not because the API is not working or is still not properly configured but rather because YouTube’s search results change all the time. Just do the same exact search on YouTube’s website just 10 seconds apart. You’ll see that you get different search results.

how to get youtube `search instead` feature in youtube api version 3?

In youtube interface if we search for a term with spelling mistake, Interface provides an option to "search instead" for a similar term. for example
poovin maarile search gives you results for poovin marile
but while using youtube api version 3, poovin maarile gives zero results and poovin marile gives 230+ results. But there is no way in the api to get this very closely related term.
I am aware of spelling suggestions feature in version 2 but since version 2 is deprecated I am not interested in using it. Is there something similar for youtube data api version 3?
I don't think there's an official API for this at the moment.
You probably shouldn't rely on this being available in the future, but I think the only alternative at the moment is querying the same URL that YouTube and other pages use.
From another question: Youtube API search auto-complete
A page detailing the query parameters: Google Autocomplete API

YouTube API "q" Parameter Broken?

According to the YouTube API documentation, the "q" parameter searches through the metadata for the videos. This includes the title, description, and keywords.
However, just recently (since yesterday to my knowledge) the "q" parameter is only searching the titles.
Here is the feed for NBA:
http://gdata.youtube.com/feeds/api/users/nba/uploads
There is a video with the title "Top 5 Plays of the Night: April 16th" with the description "Check out the best plays from Tuesday`s action in the NBA".
If I search for "Tuesday" the video doesn't come up: http://gdata.youtube.com/feeds/api/users/nba/uploads?q=Tuesday
If I search for "Top" it does: http://gdata.youtube.com/feeds/api/users/nba/uploads?q=top
I believe Google monitors this forum. What has gone wrong? I really need to search all fields for my application. I've been using it for the past year or two and for it to suddenly just break is crippling! Please provide guidance.
That does indeed appear to be broken. I know that YouTube doesn't publicly expose tags (keywords) anymore and now refers to them as tags so I am guessing this Documentation is old. I would recommend that you switch to using this query from the V3 Data API to get your desired results.

Youtube Search Results as Playlist, Need Advise

Hi guys, this is my first time to post on this awesome community so
please bear with me.
I am working with a Wordpress Plugin that can display a Youtube Search Results into Video Playlist.
My settings are:
Keywords
Author
Content- channel/keyword
My first Approach was this:
with this api as reference,
search for the keyword > display the relevant results according to the author as playlist
*I'm in doubt if I this is possible, coding 30%
*I'm not sure where could I use my settings for Content
but then when my coding is in progress I recently bumped an article that says Youtube Search is differrent on Searching a Youtube Playlist
Now I can't continue my coding because I'm not sure If I'm doing it
right. Can you give me some advise with this situation or show me some
similar project/examples?
You don't have to write any YouTube Data API code for this; it's a built-in feature of the YouTube Player.
This blog post has an example of loading a list player that takes its content from the recent uploads of a channel. You can do something similar by setting listType=search&list=SEARCH_TERM, where SEARCH_TERM is whatever string you want to search for (be sure to URL escape it). You can read more in the documentation.

YouTube safe search and rating via API

YouTube API v2 allows you to a) search for safeSearch only and b) get the media rating (eg PG-13) https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_media:rating .
Is there a way to do this in the v3 API?
If not: Why was this omitted? Are there plans to remove it from v2?
In general, what's the best way using the API to tell if a video is safe?
You should be able to use the safeSearch parameter as described at the following link:
https://developers.google.com/youtube/v3/docs/search/list
I hope that answers the first half of your question.
Furthermore, you can find the getRating method at
https://developers.google.com/youtube/v3/docs/videos/getRating
under the list of video methods (this section also lists the various ratings such as pg13 etc):
https://developers.google.com/youtube/v3/docs/videos

Resources