Search in youtube by using youtube api - youtube

I need to retrieve videos that contain some topic in title or description ,
I use the following request
https://www.googleapis.com/youtube/v3/search?part=snippet&q=???&channelId=???&key=???
it return result that not related to the query that I mentioned
Where is the problem?
How api retrieve the result ??

Related

Youtube API not returning liked videos

I have a problem with the Youtube API, I want to get all my liked videos.
Using this : https://developers.google.com/youtube/v3/docs/channels/list
I find all my playlist but not the liked one..
Do you know if it's protected ?
So there is no way i can get my liked videos ?
There's no search filter for Youtube API that says 'get only my liked videos'. But there's a "part" property called 'statistics' that returns how many likes your videos has.
https://www.googleapis.com/youtube/v3/channels?part=statistics&key={YOUR_API_KEY}
If you want to get a list of all your "Liked" YouTube videos, regardless of where they are then you need to use:
"Videos : list"
You are using:
"Channels : list"
The URL for "Videos : list" is:
https://www.googleapis.com/youtube/v3/videos
See documentation at:
https://developers.google.com/youtube/v3/docs/videos/list#request
There is a sample of Request Parameters for:
list (my liked videos)
An option parameter of:
myRating=like
must be included in the URL search string if you are using the REST API.

YouTube API v3 Channels: list method doesn't work for some channels names

For some reason I can't get any information for some channels via API. For example this channel: http://youtube.com/vithorvascovv and API request
GET https://www.googleapis.com/youtube/v3/channels?part=id&forUsername=vithorvascovv&key={YOUR_API_KEY}
gives me empty response. Why? You can try here with part=id and forUsername=vithorvascovv.
Even if I use search method like this:
GET https://www.googleapis.com/youtube/v3/search?part=id&q=vithorvascovv&type=channel&key={YOUR_API_KEY}
I have empty response but in same time channel can be found by using regular search on Youtube.
One more channel name with the same problem: Nsamurail
It looks like the user "vithorvascovv" merged with another channel. I'm not exactly sure why the username lookup no longer works, but I see that http://youtube.com/vithorvascovv redirects to https://www.youtube.com/channel/UCsLprVocGZ9mUl6SGBZ91Ng. Using part=id and id=UCsLprVocGZ9mUl6SGBZ91Ng, I was able to return the proper results from the API.
For your second question, it looks like user "Nsamurail" changed their username to "xRidan" (http://www.youtube.com/Nsamurail redirects to https://www.youtube.com/user/xRidan). Using part=id and forUsername=xRidan, I was able to return the channel information from the API.
Question : How Can Fetch Playlists From Any Youtube Channel Name/User By Using YOUTUBE DATA API ?
Answer : When You Try To Do This We Always Face A Problem to apply "FILTER" in order to fetch Playlists , here you can use two different filters (forUsername,Id) in two different Youtube channel urls such as :
1. https://www.youtube.com/user/flashbuilding/playlists
Here channel name is : flashbuilding
Required Filter For API is: forUsername
Code Structure :
forUsername:flashbuilding
2. https://www.youtube.com/channel/UCJUmE61LxhbhudzUugHL2wQ/playlists
Here Chanel Name is not clear in this case:-
Required filter for API is : Id
Code Structure :
Id:UCJUmE61LxhbhudzUugHL2wQ
Note : use Id in API Filter section instead of API part Section

Fetch youtube video line from freebase result id

I need to fetch the video link to show trailer of a movie which I am searching using freebase API. SO is it possible to fetch the link using freebase result mid/id
You can do a freebase topic related video search on youtube via search->list call.
Set the part = "snippet" type = "video" and topicId = "YOUR_TOPIC_ID"

youtube api v3 - multiple search author + keyword

like this : http://gdata.youtube.com/feeds/api/videos?alt=rss&q=irem%20ya%C4%9Fc%C4%B1&author=ewakolik
I can search author and keyword together,
but I could not find it in v3 version
https://www.googleapis.com/youtube/v3/search?part=snippet&q=irem+ya%C4%9Fc%C4%B1&key={YOUR_API_KEY}
Author was the YouTube user who uploaded this video. This translates to channelID which the video is uploaded in v3.
So in your search you can define channelId.
GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId= UC1oFl9_Y7LM5tjCcpTpqA1g&q=irem+yagci&key={YOUR_API_KEY}
To get channelId of any legacy username you can use:
GET https://www.googleapis.com/youtube/v3/channels?part=id&forUsername=ewakolik&key={YOUR_API_KEY}

How to get all comments on a YouTube video?

Since Google has deprecated the YouTube v2 API, I cannot find a way to get all the comments from a video.
Is it possible to use a single, non-deprecated API (Google+, YT v3) to do that?
I am not concerned about maintaining threading.
Believe me it works
https://www.googleapis.com/youtube/v3/commentThreads?key=******************&textFormat=plainText&part=snippet&videoId=kffacxfA7G4&maxResults=50
Key will be provided by the google developer console and 50 denotes 50 comments in form of a json, video id is the id of the video. For any type of queries comment below.
You can get only 100 at most at a time with the comments API. But you get a nextPageToken from the comment api response. Pass &pageToken={nextPageToken} to next api call, until the nextPageToken is undefined. Then you can get all comments if you like.
https://www.googleapis.com/youtube/v3/commentThreads?key={your_api_key}&textFormat=plainText&part=snippet&videoId={video_id}&maxResults=100&pageToken={nextPageToken}
Apparently it is now possible to fetch comment threads.
(old answer)
Currently that's impossible with a first-party tool.
Source:
While v3 offers the majority of v2 functionality, there are currently
a couple of tasks that can only be done with the older API.
Specifically, applications that manage captions or that work with
video comments still need to use the v2 API until modern equivalents
are available. Our goal is to provide similar functionality well
before the April 2015 shut-off date—please subscribe to this blog, the
YouTube Data API v3 revision history page, or follow +YouTubeDev on
Google+ to keep up-to-date. -
http://apiblog.youtube.com/2014/03/committing-to-youtube-data-api-v3.html
TubeKit (YouTube crawling toolkit) might be of help to some.
You can fetch all the comments using https://www.googleapis.com/youtube/v3/commentThreads
The Youtube API v3.0 allows you the following parameters.
textFormat - This parameter indicates whether the API should return comments formatted as HTML or as plain text. The default value is html.
videoId - The Youtube Video ID you want to fetch comments for ( if you dont know your Youtube Video ID, you can get one from Youtube Video ID Finder )
maxResults - The maxResults parameter specifies the maximum number of items that should be returned in the result set.
pageToken - The pageToken parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken property identifies the next page of the result that can be retrieved.
$.ajax({
dataType: "jsonp",
type: 'GET',
url: "https://www.googleapis.com/youtube/v3/commentThreads?key=PUT-YOUR-KEYXXXXXXX&textFormat=plainText&part=snippet&videoId=PUT-YOUR-VIDEO-ID",
success: function(result){
data = result;
$('.data').text(data);
console.log(data);
}});
To find PUT-YOUR-KEY(API key) ---> https://console.developers.google.com/apis/credentials then click on blue color button select API key option you can get

Resources