I'm trying to find a way to retrieve all videos posted by a given user (eg: https://www.youtube.com/user/laliga/videos).
All the examples I've found online or the doc (https://developers.google.com/youtube/v3/docs/) seems to require either a playlist ID, channel ID or video ID.
Is there any way I can directly query the author's videos or am I forced to retrieve all playlists and then iterate over?
Thanks
You just need to map the user name to its channelID first via the YouTube API like so:
https://www.googleapis.com/youtube/v3/channels?forUsername=USER_NAME&part=id&key=API_KEY
Full docs: https://developers.google.com/youtube/v3/docs/channels/list
Then you can make a Videos:List call with that channelID to get the videos.
1)take your google key id and channel id and put inside below url
https://www.googleapis.com/youtube/v3/search?key=APIKEY&channelId=CHANNELID&part=snippet,id&order=date&maxResults=20
ex
https://www.googleapis.com/youtube/v3/search?key=adsjsdakhkjshd&channelId=sdahghsadhgj&part=snippet,id&order=date&maxResults=20
Related
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
I have two "Live streaming/live broadcast saved playlists" in following youtube channel --> https://www.youtube.com/user/swaminarayanlive.
I am trying to retrieve all the "live streaming / live broadcast playlists" of a channel using new youtube v3 api by using the below link-->
https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=UCBkNpeyvBO2TdPGVC_PsPUA&key={YOUR_API_KEY}
here i can get the info of playlists which are not live streams or live broadcast. and not able to get the same for the live one.
Please help me how can i get that for live one using youtube v3 api
I was researching another issue with the API when finding this, and when I saw that this was never resolved, I decided to look into it. It turns out that this is related to that other issue.
The YouTube API v3 lacks support for saved playlists. The channel swaminarayanlive did not create the playlists, only saved them from the channel BhujMandir.
The workaround in your case would be to retrieve the playlists of BhujMandir and extract the response snippets with "title" parameters containing the word "Live".
You would need to go through the pages and search each one for this, since there is a limit to how many results an API response can show at once. Currently it's 50.
So, you would use the following to get the first page of playlistItems:
GET https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=UCVItNtUctAknegvmYcMhUQg&maxResults=50&key={YOUR_API_KEY}
This will return an API response containing the properties "kind" (which will have the value "youtube#playlistListResponse") and "etag". If there are more than 50 results, there will also be a "nextPageToken" property. (On a page that is not the first, there would also be a "prevPageToken" property.)
After these properties, there are two blocks. One called "pageInfo", containing info about how many results (playlists) there are and how many are shown per page, and one block called "items", containing the resulting playlistItems.
You would look through the items block for any playlistItem with a title property (which is a string) containing the substring "Live" and get the id properties of those. You would then look on the next page by using the nextPageToken's value in a new HTTP request, like so:
GET https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=UCVItNtUctAknegvmYcMhUQg&maxResults=50&pageToken=[nextPageToken_value_here]&key={YOUR_API_KEY}
As of now, the two playlists you're looking for are on the pages with tokens CJYBEAA and CMgBEAA.
I think that where is the {YOUR_API_KEY} you should change this code and insert the name of your application program interface
Been searching for the API to embed a Youtube channel's user_uploads for channels which have the new channel_id (starting with UC) instead of a user name but did not find any working solution. According to the API, there is only the possibility to embed a player with user_uploads for a USER ID. Are there any (undocumented?) parameters to achieve this?
Example of working iframe embed with user_id:
http:// www.youtube.com / listType=user_uploads&list=USERNAME
Not working:
http:// www.youtube.com / embed?listType=user_uploads&list=UC....xxxxx (Google + style channel id)
The posted answer does not work anymore.
Now you should use:
http://www.youtube.com/embed/videoseries?list=USERID
And the USERID is your youtube user id with 'UU' appended.
For example, if your user id is TlQ5niAIDsLdEHpQKQsupg then you should put UUTlQ5niAIDsLdEHpQKQsupg.
If you only have the channel id (which you can find in your channel URL) then just replace the first two characters (UC) with UU.
So in the end you would have an URL like this:
http://www.youtube.com/embed/videoseries?list=UCTlQ5niAIDsLdEHpQKQsupg
BTW. you can append &index=1 to specify which video should be played.
See answer on duplicate
Never seen such a username. Do you have a link to a user (youtube website) with such a username ?
Update.
It looks like it is a part of the new V3 api from youtube and I filed a bug report at the youtube dev forum since it wont't work withe the user_uploads iframe
http://code.google.com/p/gdata-issues/issues/detail?id=6463
For example this channel
https://www.youtube.com/channel/UCpAOGs57EWRvOPXQhnYHpow
then ID is UCpAOGs57EWRvOPXQhnYHpow
Now try to load this
http://www.youtube.com/embed/?listType=user_uploads&list=UCpAOGs57EWRvOPXQhnYHpow
This isn't working, Only with real usernames
I am retrieving all of the videos for a given channel by:
'https://gdata.youtube.com/feeds/api/users/{username}/uploads'
When I go to a channel, such as: http://www.youtube.com/channel/UCXIyz409s7bNWVcM-vjfdVA I have the channel ID and I can quite clearly see the videos. Also, if I click on the 'Videos' tab I can see all the videos, but the URL changes to: http://www.youtube.com/user/majesticcasual/videos
I would like to take the channel ID and retrieve the username for the given channel such that I can query YouTube's API for the videos by channel ID. Is this possible?
If you retrieve this feed:
https://gdata.youtube.com/feeds/api/users/[channel_id]/
You'll get a response that includes an <author> element -- the <name> child of that <author> element is the username. It's also repeated in that same feed as <yt:username>.
Of course, that's kind of moot, because you can query by channelID directly:
https://gdata.youtube.com/feeds/api/users/[channel_id]/uploads
is the same feed as if you'd used the username. This works because the channel_id really is just the unique ID of someone's username.
If you want to use v3 of the API (Which is highly encouraged, as it's at production level now), you could use this feed:
GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=UUXIyz409s7bNWVcM-vjfdVA&key={YOUR_API_KEY}
Note that I've changed the channel id so instead of starting with UC (as all channel ids do), I'm passing in a value that starts with UU ... this is so you get back the uploads feed of the channel (you could also have it start with LL instead to get back the 'likes' feed, for example ... or even do a request to:
GET https://www.googleapis.com/youtube/v3/channels?part=snippet%2CcontentDetails&id=UCXIyz409s7bNWVcM-vjfdVA&key={YOUR_API_KEY}
To retrieve, in the contentDetails parameter, all of the playlists associated with that particular channel.
I am trying to get a list of video ids for all uploaded videos to a channel. I would also like to use the new version of the YouTube Data API (V3). How do I do this?
You have to get the upload playlist id to get each videos uploaded. To get that, you need to get the channel id. After you have the playlist id from the channel id, it is pretty simple. I have written out the steps for all three below.
Also, we offer PubSubHubBub which allows you to be alerted every time a new video is added to a channel, or you could use SUP (V2) to see which resources have changed before making the calls.
Instructions to get video ids for all uploaded videos for a channel in V3
Get the channel id for the channel you want (you probably only need to do this once, then you can save it)
Use search.list
Set type to channel
Set q to the name of the channel you want
Grab the channel id (something like this: "channelId": "UC0X2VuXXXXXXXXXXXXXXXX")
Get the playlist id for the channel uploads using the channel id from step 1 (you probably only need to do this once, then you can save it)
Use channels.list
Set id to UC0X2VuXXXXXXXXXXXXXXXX from step 1
Grab the uploads key from contentDetails (something like this: "uploads": "UU0XXXXXXXXXXXXXXXXXXXX")
Get the videos via the playlistitems in the playlist using the playlist id from step 2
Use playlistItems.list
Set playlistId to UU0XXXXXXXXXXXXXXXXXXXX from step 2
Go through each PlaylistItem and pull out the video id
In the meantime, there is a much easier way:
Use the channels.list
set forUsername = [CHANNELNAME]
set part = contentDetails
grab $data->items[0]->contentDetails->relatedPlaylists->uploads --> [PLAYLISTID]
Use playlistItems.list
Set playlistId = [PLAYLISTID] from step 1
Go through each PlaylistItem and pull out the video ids