Recover most viewed videos from youtube channel

Asked

Viewed 540 times

4

There is how I recover the 5 most viewed videos from my Youtube channel to put on my website?

  • It can be in Jquery or PHP.

1 answer

2


The method search.list allows you to search for videos, channels or playlists that match specified criteria. You can search based on video properties, keywords or topics (or a combination of these), and you can sort the results based on factors such as creation date, views, etc.

My most viewed videos: This request retrieves all of the authenticated user’s video and lists them in descending order per view (viewCount), See the example below.

GET {base_URL}/search?part=snippet
                     &forMine=true
                     &order=viewCount
                     &maxResults=5
                     &type=video

Like other Youtube data API requests, the method search.list returns the default JSON representation.

If you need more details about the Request Apis: Youtube API Requests

  • friend what I should put in this base_URL for kindness. and something else has to limit the amount of data returned like the 10 videos?

  • 1

    @Joaonivaldo updated the answer with the option maxResults limiting the quantity. On the base_URL, you trade for https://www.googleapis.com/youtube/v3. Everything is explained in the link documentation at the end of my reply.

  • look I took a look and am using this url get: https://www.googleapis.com/youtube/v3/search?part=snippet&forMine=true&type=video&maxResults=2&key={YOUR_API_KEY}. I created a browser application key and put it in the cited URL, but generating the following error: Invalid combination of search filters and/or restrictions. What I did wrong?

  • friend I removed the forMine from the url and it all worked out. I hope I have done little ceretinho. If I did not please correct me. Thank you

  • I believe without the forMine It automatically identifies your channel, no problem. The error that was happening before was because some part of the URL requests was not correct. I’m glad it worked, if the answer was helpful consider marking it as correct answer. :-)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.