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

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.

Related

Youtube API search livestream stop to work

A few days that the youtube api stop to show a livestream videos, is this error only on my api key? if does, is there any other way to find a livestream videos?
I googled if there any message from youtube about this, and i didn't find.
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UC4R8DWoMoI7CAwX8_LjQHig&eventType=live&type=video&key={MY_API_KEY}
You are not alone.
It's broken for everybody, unfortunately, and it's been this way for over ten days now. As with all Google services, human support and feedback is non-existent, not even an acknowledgement of the issue.
Ref.: https://support.google.com/youtube/thread/14611425
As a workaround, I had to change the logic to use the q parameter along with eventType=live. This actually works, and, depending on keywords, can also return a whole lot of unrelated live material, which, I think, can be further filtered on the client. This also seems to incur higher quota usage.
Well, I guess the issue is you try to use a meta-channel. UC4R8DWoMoI7CAwX8_LjQHig refers to what you get when you click on live in the menu, but this only "sums up" what's live, it isn't a real channel itself. Just strip the channelId parameter you should get all active live streams (only tested at reference page https://developers.google.com/youtube/v3/docs/search/list but got me 14.5k at time of try).
Matt

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.

Youtube API Ratings

I am using YouTube API in one of my projects. In some cases I find that the "gd$rating" is not present in the response I receive . What can be the possible reasons for this ? Is there a work around to get the same ?
This sounds like a classic example of "don't always trust the API return values to be wholly complete or accurate". You will most likely have to anticipate this sort of thing happening in your code. Even if it is defined in the API.
For example: https://developers.google.com/youtube/2.0/reference#youtube_data_api_tag_gd:rating
From the docs: gd$rating This element is only returned if the video has been rated.

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.

gdata youtube feed for auto-generated channels

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.

Resources