Prasad Raja
Prasad Raja

Reputation: 703

youtube api v3 - get videos from a public playlist. with out using api key

Youtube V2 where this code use to list top 50 videos from the play list

        var ytURL = "http://gdata.youtube.com/feeds/api/playlists/PLgtnUFn0ROBBPO2nC-bduEDDlxikKwZ6R?v=2&alt=json&callback=?&max-results=50";


    var thumbBase = "http://img.youtube.com/vi/";

    $.getJSON(ytURL, function (data) {
            $.each(data.feed.entry, function (i, item) {
                var itemTitle = item.title.$t; // Title of the video
                var itemdescription = item.media$group.media$description.$t; //Description of the Video
                itemdescription = itemdescription.replace(/"/g, "");
                var itemdate = item.published.$t;
                var fulldate = new Date(itemdate).toLocaleDateString();


                 var yobject = { 'title': itemTitle, 'description': itemdescription, 'gdate': itemdate };
               localStorage.setItem(videoID, JSON.stringify(yobject));

            });

Same code is not working now, since google update the youtube apis

i have referred the youtube documentation, after seeing that i came to know to use like this

https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=PLgtnUFn0ROBBPO2nC-bduEDDlxikKwZ6R&key={YOUR_KEY_HERE}&maxResults=50

Problem is, There was public : playlist id "PLgtnUFn0ROBBPO2nC-bduEDDlxikKwZ6R" here.

i want to list all the videos from the playlist without using API key..

how can i access this...

suggest me to how can i overcome from this solution

Upvotes: 2

Views: 2898

Answers (2)

weakish
weakish

Reputation: 29952

YouTube Data API v3 requires an API Key to get public information. However, it is possible to get videos from a public playlist via unofficial APIs.

For example, Invidious, an alternative front-end to YouTube, provides the following REST API for YouTube playlist, without requesting an API key:

GET /api/v1/playlists/

You can refer to its documentation for more information.

Upvotes: 0

orcaman
orcaman

Reputation: 6581

You cannot access even the public youtube data without an API key in v3.

From the docs:

You can request information about information about a channel's public playlists without authentication. When you submit an unauthenticated request, you need to include the key argument that specifies the unique API key for the application making the request. For example, this request retrieves the playlists associated with the GoogleDevelopers channel.

So you can perform the request to get the playlist data without authenticating the user (no need to go via the OAuth flow), but you still have to supply an API Key for your app (you can generate that in the Google Developer console quite easily). This allows Google to keep track of your app's requests.

Upvotes: 4

Related Questions