Khang .NT
Khang .NT

Reputation: 1589

YouTube API V3 - Get recommended video for new feed

As YouTube official documentation about implement and immigrate to API V3, they said:

YouTube Data API (v2) functionality: Retrieve video recommendations
The v3 API does not retrieve a list that only contains videos recommended for the current API user. However, you can use the v3 API to find recommended videos by calling the activities.list method and setting the home parameter value to true.

But now the parameter home has been deprecated too. Currently, when I set the home parameter to true, I only retrieve the recently uploaded video in the channel: Popular video in YouTube. There are no video with snippet.type=recommendation at all.

I need to show recommended videos of authenticated user in new feed, but seem like this feature is completely deprecated by YouTube. Anyone has solution for that?
Thanks first!

Upvotes: 14

Views: 14883

Answers (5)

Sarwang Jain
Sarwang Jain

Reputation: 1

To retrieve viewing statistics, popularity metrics, and demographic information for YouTube videos and channels, you use the YouTube Analytics API. The Sample API Requests page shows how to retrieve common reports from YouTube Analytics.

Got this from the Youtube Data API Documentation, you can try this

GET {base_URL}/activities?part=snippet,contentDetails&home=true

Upvotes: 0

Nischit Pradhan
Nischit Pradhan

Reputation: 440

I found this youtubes search api. All we need to do is put a video id in the relatedToVideoId and it'll giveout a list of videos related to it.

Upvotes: 1

金馆长
金馆长

Reputation: 217

You can retrieve them using the following API call:

GET https://www.googleapis.com/youtube/v3/activitiespart=snippet%2CcontentDetails&channelId={channel—_Id}&maxResults=25&regionCode=tw&key={YOUR_API_KEY}

Upvotes: 0

keepTrackOfYourStack
keepTrackOfYourStack

Reputation: 1255

The docs for the api include a way to test the request. code samples there show how to set 'mine' for an authenticated request.

youtube activities

This is android sample code. it would need to be in some background thread. The setmine = true on the channelList response is like the home (I think). Was not sure if your implementation was for the web or an app.

this is android code:

 YouTube youtube = new YouTube.Builder(transport, jsonFactory,
                    credential).setApplicationName(getString(R.string.app_name))
                    .build();

            YouTube.Activities.List activities;
            ActivityListResponse activityListResponse = null;
            List<ActivityData> activitiesData = new ArrayList<ActivityData>();

            try {
                /*
                 * Now that the user is authenticated, the app makes a
                 * channels list request to get the authenticated user's
                 * channel. Returned with that data is the playlist id for
                 * the uploaded videos.
                 * https://developers.google.com/youtube
                 * /v3/docs/channels/list
                 */

                ChannelListResponse clr = youtube.channels().list("contentDetails")
                        .setMine(true).execute();


               activities  = youtube.activities().list("id,snippet,subscriberSnippet");
                activities.setChannelId(clr.getItems().get(0).getId());

                activities.setMaxResults((long) 50);
                activityListResponse = activities.execute();

                ArrayList<String> subscriptionListIdentifier = new ArrayList<String>()
                        ,listTitles = new ArrayList<String>()
                        ,listThumbnails = new ArrayList<String>();

                List<Activity> results = activityListResponse.getItems();

                for (Activity activity : results) {
                    listTitles.add(activity.getSnippet().getTitle());
                    listThumbnails.add(activity.getSnippet().getThumbnails().getDefault().getUrl());
                    subscriptionListIdentifier.add(activity.getId());
                    //if ("public".equals(playlist.getStatus()
                    //        .getPrivacyStatus())) {
                    ActivityData data = new ActivityData();
                    data.setActivity(activity);
                    activitiesData.add(data);
                    //}
                }

                return activitiesData;

Upvotes: 0

abielita
abielita

Reputation: 13494

Unfortunately, I can't find any documentation or example about this feature. It seems that this has been deprecated. However, you may check this documentation with sample JSON structure that shows the format of a activities resource such as recommendation:

"recommendation": {
      "resourceId": {
        "kind": string,
        "videoId": string,
        "channelId": string,
},

Hope this helps!

Upvotes: 2

Related Questions