Searching the youTube V3 API via channel name not username? - youtube

Youtube allows a username and channel name. They can be different from each other. The youtube API allows me to search via username but I can't see where or how to search by channel name. It is the channel name that is displayed under the videos.
Anyone shed some light onto how I can search via channel name/title and not username?
Thanks

If the channel search API didn't return a result I call the search API
https://www.googleapis.com/youtube/v3/search?part=snippet&type=channel&maxResults=1&q=(<# potential channel name #>)
So it runs a standard search for entered value "potential channel name". Google docs say the first returned result will be a channel so we only need 1 result which is why we set maxResults=1.
If that returns nothing then I assume channel does not exists and display error to user

This works with me, just change the key with your api-key
url1="[https://www.googleapis.com/youtube/v3/search?part=snippet&type=channel&maxResults=15&q=Inna&key=[YOUR-API-KEY]"
r = requests.get((url1))
print(r.content)
It returns all channels with names that contain the word Inna
Hope this can help you

Related

Youtube - ListChannels with Username(forUsername) is not working

I'm trying to get channels info with ChannelsList. This endpoint has a parameter the name is: forUsername but it does not work for this page: https://www.youtube.com/c/FolkartTr
This is my query and it returns empty data:
Somehow, I got this channelID in the page source and its: "channelId":"[UCnS--2e1yzQCm5r4ClrMJBg]".
When I try to query with this ID it's okay and returns with correct data.
and this is its payload: http://jsonblob.com/941253671862419456
How will I be able to reach this channel info using a username? I got a few links with usernames and I want to get their info with their username. I don't have any chance to get their channelID's for all.
Thanks for your help.
If I understood correctly, your problem is that you can't do anything from such a username with the Channels: list of the YouTube Data API v3. If you're just looking for the channel id linked to this username then because as YouTube Data API v3 doesn't work for this, I would recommend you to use my open-source YouTube operational API, indeed by requesting https://yt.lemnoslife.com/channels?part=snippet&forUsername=FolkartTr you'll receive a JSON with id equals to the channel id linked to the provided forUsername value.
If you have any question don't hesitate to comment or come to the Discord support.
Notice that the channel title and the channel customUrl might be different.
In your example - http://jsonblob.com/941253671862419456 -, the channel title is Folkart, but its customUrl - which is the value you get when view on YouTube - is: folkarttr.
Note the difference in both case-sensitive and additional letters.
For these reasons, you should not based your channel search by name, but, rather, by its channel_id.
If you really need to search by userName, the answer from Benjamin Loison can solve your requirement.
See if you can find a ticket on Issue Tracker or post your issue there too. Then, you might get some official answer.

Get all videos for a given user

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

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

youtube analytics ids value

I am trying to use Youtube analytics but I am not sure how to fill out the parameters properly
Here is the form I am trying to fill out: https://developers.google.com/apis-explorer/#s/youtubeAnalytics/v1/youtubeAnalytics.reports.query
How do you find out the value of ids?
It states: Unique channel or content owner ID for retrieving YouTube Analytic data. Either channel==C or contentOwner==O where 'C' is the encrypted channel ID and 'O' is the content owner name. (string)
I have tried contentOwner=={myapikey}
where {myapikey} is an api key for my google app
How do I get the proper value of ids?
My goal is to execute a query on the above link.
You can get the values for the currently logged in user that you can put into ids=channel==%here$% using an authenticated call to https://developers.google.com/youtube/v3/docs/channels/list
For ids=contentOwner==%here%:
This is for the case where your user is associated to a YT content owner. Right now you would need to ask your client (a YT content owner) to get this ID. The client can get it from their partner manager.

youtube analyticsService Report parameters

I am authenticating with google to try and get youtube analytics my problem is that i don't know how to filled you the parameters when quering youtube
here i am making a new service: and then try to query it
I am not sure what to put in the "ids" parameter or where to find it?
What do I put there?
_analyticService = new YoutubeAnalyticsService(_authenticator = CreateAuthenticator());
...
_analyticService.Reports.Query("ids", "2013-01-01", "2013-02-02", "views").Fetch();
The ids parameter is the an expression with the id of your channel. If you go to http://www.youtube.com/analytics and click on the title with your own channel name, you get a link like http://www.youtube.com/channel/UCYHMS8hN8s49F93iJuEgG6w The last part is the id of your channel. You have to use this as the ids parameter in an expression like "channel==UCYHMS8hN8s49F93iJuEgG6w". This is to query in the context of your own channel. This is needed as you might have access to several channels.
I can query views for one of my videos by: https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3DUCYHMS8hN8s49F93iJuEgG6w&start-date=2013-01-01&end-date=2013-02-02&metrics=views&dimensions=day&filters=video%3D%3D_iwmv6644dA&sort=day&key={YOUR_API_KEY}
Try to use the API explorer at the bottom of this page, there are some text explaining the different parameters there as well. https://developers.google.com/youtube/analytics/v1/
Hope it goes well!

Resources