gdata youtube feed for auto-generated channels - youtube-api

I'm trying to figure out if it's possible to get a gdata feed for an auto-generated youtube channel, aka a "Topic."
For example, here's the JPop Channel:
http://www.youtube.com/channel/HC9BkB0bbvR-4
Were this a user, I know I could get a feed like: http:// gdata.youtube.com/feeds/base/users/{username}/uploads. But since it's not a user, that doesn't work.
I know I could do a search like: http:// gdata.youtube.com/feeds/api/videos?v=2&q=jpop, but that's not exactly the same thing.
This question was asked before on the old Youtube Developer Forum, but at the time it wasn't available.
I've looked all through the API docs to see if that's changed, but can't find any reference to it.
I was hoping someone here might know if it's changed, and the docs haven't been updated, or if there's an expected ETA for that feature?

You can interact with auto-generated topic channels (those that begin with HC) by subscribing to them like any other channel.
If you just want to get a list of videos associated with the channel, though, you need to use the forthcoming v3 of the API, and you can do a search based on the underlying topic. You can get the topic id(s) related to a given channel using channels.list(id=CHANNEL_ID):
https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channels.list?part=topicDetails&id=HC9BkB0bbvR-4
(v3 isn't publicly released as of right now, so you need to use the Google APIs Explorer.)
That returns (Freebase) topic id /m/025g__, which you can then use to do a search.list(topicId=TOPIC_ID, q=BLAH, type=video)
https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?part=snippet&type=video&q=j+pop&topicId=%252Fm%252F025g__
Unfortunately, you can't do a search that just specifies a topicId= without a q= right now in v3, but that's a bug that will hopefully be fixed soon. So you do need to specify something meaningful for the q= parameter for the time being, and I'm just using j pop.

Related

YouTube API v3 Search not returning all videos

I'm trying to retrieve all videos for a channel, and some are not being returned by the api. I cannot find anything in the spec that indicates why some would not be in the result set.
The call I'm making is:
https://www.googleapis.com/youtube/v3/search?type=video&key=__key_here__&channelId=UCxS2lX7728bTnmK1t21bYlA&part=id,snippet&maxResults=50&order=title
[To test this you'll need your own api key]
The first page of results is missing at least one video. The one from 8-15-2018, titled I LEARNED HOW TO DO A NEW TRICK!, which is located here, is not in the result set, even though it falls within the date range, and the first 50 results.
Does anyone know if this is a known issue?
I have verified that if I add the q parameter, with the video id, it will retrieve it.
You may refer with this link.
The API call that you should make if you want to get the videos in a channel is a youtube.playlistItems.list() with the playlistId of the "uploads" playlist for the channel. (This usually stars with UU..., but that's an implementation detail that might change in the future.
Here's an example of the call in the API Explorer.
Getting the same data via a search operation isn't guaranteed to return everything; the search index isn't a replacement for the backend data that you can obtain via the youtube.playlistItems.list() call. It's very much the same point raised in this blog post (though the focus there is on v2).
To summarize, to get all the uploads from a channel, you need to get the items from the uploads playlist for the channel using playlistItems.list on that playlist's ID rather than calling search.list on the channel ID.

YouTube API "mostPopular" requests doesn't seem to give updated results

It seems that the YouTube API doesn't give updated results for mostPopular videos in my country since few days.
Example:
This request (https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails&chart=mostpopular&regionCode=FR) doesn't give me the same videos results than the ones displayed directly on YouTube for the French most popular channel (https://www.youtube.com/channel/UCmzy72gDEpfXoFV9Xdtd0DQ). It seems that the results of this request is not updated since the 1th of february. Results was real time updated before this.
Does someone know if something is wrong with my API request, or if there are some issues with the YouTube API at this moment?
There is nothing wrong with your request. This is a known issue with the YouTube API reported here for Saudi Arabia (but also applicable to multiple regions), and another related issue here with regard to content from France.
Your best bet would be to follow up with the YouTube team on one of those defects, or potentially (and dangerously) scrape the YouTube site for the correct results.
Problem seems to be solved since 13th of february (maybe someone from Google have seen my post..)
YouTube Channels and chart=mostPopular parameter data are separate data entities, aka you will get different results. They may be related but there is no guarantee you will get the same data. To get the data that you want you may need to query for channel itself and its videos.
I got this information from the thread #Jal linked, there was an update by matthewc...#google.com a few days ago:
The most popular channel for Saudia
Arabia and
the mostPopular chart parameter in the video.list
call
are separate and distinct entities. If you'd like to get the content
of the most popular channel for Saudia
Arabia
please use the Data API video.list call to list the videos with the
channel ID (in this case "UCWY-_j1MCth6yf24m58Bh_Q") by setting the
items/snippet/channelId parameter.
My current concern right now is that there is supposedly a way to get video information from the videos.list endpoint using a channelId, which does not seem the case in the API Explorer. I will update my answer once I figure out what this person meant exactly.

Trouble migrating from V2 to V3 of YouTube API - can't list uploads of a channel

First off, apologize to post this, I don't think it is a duplicate since I kept crawling YouTube API tagged questions since yesterday and I couldn't find a fix.
My Question is, Can I keep using V2 of YouTube API even if it is officially deprecated ? the reason why is because I have 2 issues I still couldn't find a fix for them in V3 and I already have them in V2 : listing a channel's last uploads and popular uploads.
For the last uploads, in V2 I use http://gdata.youtube.com/feeds/api/users/youtube/uploads?prettyprint=true , while I add ?orderby=viewCount to list the popular ones. I couldn't find an alt in V3 [ Tough I tried https://www.googleapis.com/youtube/v3/videos?part=snippet&chart=mostPopular&forUsername={Username}&maxResults=5&key={key} but it keeps listing videos from a channel I visited yesterday even if I change the username, making me think there is problem with the link or my key, a server key by the way ]
Any ideas ?
Thanks a lot !
Rather than using the videos->list endpoint, you should instead use the search endpoint, like this:
https://www.googleapis.com/youtube/v3/search?order=viewCount&part=snippet&channelId=UCuo5NTU3pmtPejmlzjCgwdw&maxResults=25&key={YOUR_API_KEY}
You can do order=date to have them ordered chronologically rather than by popularity if you'd rather. There are also a lot of other parameters you can use ... see https://developers.google.com/youtube/v3/docs/search/list for more details.
If you don't know the channel IDs, but only the usernames, you'll have to have multiple calls ... a call to this endpoint:
https://www.googleapis.com/youtube/v3/channels?part=snippet&forUsername={username}&key={YOUR_API_KEY}
This will return a packet with the channel ID in it. If you'd like to avoid making multiple calls or storing the username/channelID on your own, you could do the video search with the 'q' parameter set to be the username. It often works but you can get extraneous channels that way.

How can you determine the URL of a youtube channel based on the channel ID?

It seems that there should be a way to do youtube.com/user/{channel id} . but I can't figure it out. I also have the GooglePlusUserId (when available) to use.
Since channel URLs aren't returned in any of the parts of the channels resource, your best bet is to construct it yourself as http://www.youtube.com/channel/UC..., where UC... is the channel id.
I'd think that would be fairly future-proof.
Edit: I hear that YouTube.com URLs might get added to v3 responses at some point in the near future, and if they do, I'd obviously recommend using that instead of constructing them manually. I'll try to remember to update this answer if they are, but you can follow https://developers.google.com/youtube/v3/revision_history to check as well.

Is it possible to get the YouTube author name for a video using the v3 api?

So I'm working on switching to using the v3 version of the YouTube api (which is so much better it's like a completely different product), but I'm either missing something or it is ...
Being able to fetch an arbitrary list of videos, and their details, in one call is going to make life significantly better, but in the videos list method, the the video details "snippet" contains the "channelId", not the "author".
I've spent quite a bit of time looking through the documentation, but can't find any way of getting from a channelId to the human readable author name.
How am I expected to map a video to an author?
It's not possible to get back a display name (either legacy YouTube name or Google+ name) for a channel as part of the video.snippet response. You need to take the channelId and perform a channels.list(id=channelId1,channelId2,...,part=snippet) operation to get that information. The good part is that you can pass in up to 50 channel ids in a single call.
This sort of separation of information into different resources with ids effectively serving as keys linking the resources was a deliberate decision. The engineering team is aware that it will require developers to make an additional API call, but they're in favor of that design.
At the same time, the API is still in an experimental release, and if you have any feedback about using the API while doing real-world development, feel free to open a feature request in the issue tracker. If enough people give feedback about a certain aspect of the API, that could factor in to the final revision's design.
The accepted answer may have been correct at the time of writing, but as of 2/2018 the snippet part now includes a channelTitle property.

Resources