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

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.

Related

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.

About YouTube search list API V3

In my application, I have used youtube.search.list API v3 for searching whole videos included in specific channel.
Example:
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=[CHANNEL_ID]&q=[KEYWORD]
'q' is parameter for search keyword.
In my case, I used only 'q=' without keyword because I'd like to search whole videos.
It's working well at least until yesterday(27.Aug). but now, the server response is always 'totalResults: 0'
Could you tell me whether it's temporary wrong operation or the policy about this API is changed?
You can test above problem in the below url :
http://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?part=snippet
The issue has been reported to the gdata issues list five times in the last 24 hours or so. Regardless of whether it's deliberate or not, there's a lot of people concerned.
The first instance report:
https://code.google.com/p/gdata-issues/issues/detail?id=6598

twitter api 1.1 url count alternative

I've been using the old url api(v1) to get the count of a given url, lately I needed to get also the re-tweets and started searching about that.
this is the exact url I'm using right now:
http://urls.api.twitter.com/1/urls/count.json?url=http://google.com
As I viewed with some reading the v1 api is deprecated but at least it's still working.
I found some questions on the dev page of twitter:
https://dev.twitter.com/discussions/12643
those are a little old questions and have no specific solving to the problem. I mean, the most near solution was using the search api(search/tweets) which could be good but not a exactly replacement for the urls/count method.
Please note that Twitter's search service and, by extension, the
Search API is not meant to be an exhaustive source of Tweets. Not all
Tweets will be indexed or made available via the search interface.
also it has a limit for 100 results at maximum per 'page', even it throws the link to get the next set of objects, thats good but when the search reaches 1 million of results I'll need to get page over page to now how much tweets I got and having to do to much request to the api...
I sought some question over the dev page on twitter suggested using the stream api, I've tried using (statuses/filter) but that don't work very well given a URL as track param(which they said that is the keyword to track).
So, anyone who's been using the old urls/count has found a reliable alternative with the new apiv1.1, especiffically to get the tweets and re-tweets for a given url ?
The official suggestion by Twitter staff is that either the search/tweets endpoint (having just the last 7 days data) or the Streaming API be used (handling yourself the counters, making everything just too complicated for a d*mn counter).
As an extra warning, the old endpoint (http://urls.api.twitter.com/1/urls/count.json?url=YOUR_URL) will stop working on November 20th, and according to this blog post from Twitter there are no plans to replace it with anything in the short term and they are even removing the count from their own buttons.

Pulling exhaustive watched video list from Youtube API (>1000 items)

I recently started exploring the Youtube API in order to pull some long-term data about what videos I've watched over the past year and when. I'm currently able to pull in my watched video list, but unfortunately I'm hitting the 1000 item cap. I think the issue is related to the ones found in Accessing an item beyond start_index=1000 in a YouTube user upload feed, where tweaking the request URL can change whether results are coming from the search cache or not.
Most of the similar questions on here deal with requesting urls that include some sort of sorting that would trigger the 1000 item cap, but I'm just running with basic URls such as https://gdata.youtube.com/feeds/api/users/default/watch_history?v=2&start-index=1000&max-results=49 . Why would I be encountering the caps?
For v3 the query quota adds up depending on how many returned items you have request or not being restrictive enough. Various query entries cost more and can multiple.
This might not apply for the OP but for the v3 API it is all layout in the reference. Maybe code in some quota keeping logic so you can get a better understanding.

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