Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Searching the youTube V3 API via channel name not username?

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

like image 569
RyanTCB Avatar asked Sep 02 '25 05:09

RyanTCB


2 Answers

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

like image 128
RyanTCB Avatar answered Sep 04 '25 23:09

RyanTCB


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

like image 36
Atika Avatar answered Sep 05 '25 01:09

Atika