Jazerix
Jazerix

Reputation: 4801

Getting YouTube Channel Views

I'm trying to get the channel views of the logged in user, through googles' oauth2. I'm able to get name and email via this url: https://www.googleapis.com/oauth2/v1/userinfo?alt=json&access_token=[GENERATED TOKEN]

Now, I'm having a hard time finding any information about how I would go about getting the users channel views. I know you can get a list of videos and such, but how would I do this?

Is there an equivalent to the link I posted above? :)

Upvotes: 0

Views: 271

Answers (1)

Ibrahim Ulukaya
Ibrahim Ulukaya

Reputation: 12877

You can do a channels->list

GET https://www.googleapis.com/youtube/v3/channels?part=contentDetails&mine=true&key={YOUR_API_KEY}

In response contentDetails.relatedPlaylists.watchHistory will have the playlist id of watched videos. You can iterate through that playlist with playlistItems->list.

GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet%2C+contentDetails&id={PLAYLIST_ID}&key={YOUR_API_KEY}

Upvotes: 1

Related Questions