vivek
vivek

Reputation: 31

How can I get ID, name and all the stats for Channel in YouTube using their APIs

I'm a new developer not any experience with APIs. What I have to do is that I have an app. A chrome extension which gets attached to YouTube. Now what I want to achieve is that whenever I open a channel in YouTube I should get all the stats of that Channel.

I have to get the channel ID, channel name, other stats like the number of views of the channel, likes and comments of the channel. And after getting those values I have to display the channel name and all the stats I mentioned.

So how can I achieve this task.

Please help. Thanks in Advance.

Upvotes: 3

Views: 5589

Answers (1)

Ayazmon
Ayazmon

Reputation: 1380

First of all you need the channel's ID. If you want to access the datas via channel's urlname (Example : www.youtube.com/user/CHANNEL_URLNAME) first use this api to get the channel id.

https://www.googleapis.com/youtube/v3/channels?part=id&forUsername=CHANNEL_URLNAME&key=YOUR_API_KEY

Then use that ID to get channel's data and stats.

https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics&id=CHANNEL_ID&key=YOUR_API_KEY

Notice that the part parameter takes the name of the datas you want to retrieve. snippet will give you datas like channel's title, it's logo, description etc. while statistics will help you retrieve the datas like total views, subscribers count etc.

You can also look at this link for other information that you can retrieve from the API.

https://developers.google.com/youtube/v3/docs/channels/list

Note: If you see a "channel" segment on a youtube channels url the last part would be the channel's ID so you wouldn't need to use the first API call to get the channel's ID. (Example: youtube/channel/CHANNEL_ID).

Upvotes: 5

Related Questions