We are a content owner who has multiple channels rolled up into our analytics
We are pulling each day's earnings from the Youtube API to store in our database, but we want the data available per-video and not just per-channel.
The only way I've found to get a single video's earnings for a particular day is to do it for each individual video, like so
GET https://www.googleapis.com/youtube/analytics/v1/reports?ids=contentOwner%3D%3D<contentownerid>&start-date=2013-10-01&end-date=2013-10-01&metrics=views%2Cearnings&dimensions=day&filters=video%3D%3D<videoid>&sort=day&key={YOUR_API_KEY}
This, obviously, is not ideal. We have over 5000 videos we're trying to keep track of, and the number will only grow, so making thousands of API calls every morning is not a good solution.
Is there a way to get earnings reports for the whole channel, separated by video, for a given date range with a single API call? I would think I would set "dimension" to video, but that won't work with anything involving the monetary fields like earnings.
Related
I'm looking at the YouTube API doc to get video statistics, and I can't seem to find how many videos can I pull at once. For example, can I do 1,000 or 10,000 video IDs and get all of it back? Would the params allow that?
https://developers.google.com/youtube/v3/docs/videos/list#try-it
Also, is there a way to get historical view count for a given video over a course of time?
Though not specified, it seems the max number of comma-separated list of ids is 50.
The API does not provide a historical view count. You would have to make one yourself on the client end by saving the views on a periodic basis.
While the subscription count in
www.googleapis.com/youtube/v3/channels?part=statistics
seems to be updated instantly, the views update around daily.
A workaround that I found was to list all videos in the "uploaded" playlist with
www.googleapis.com/youtube/v3/playlistItems?part=contentDetails
and iterate through them, calling
www.googleapis.com/youtube/v3/videos?part=statistics
for each. This seems to get the most accurate results, though it requires more than 3 credits for every uploaded video, thus using my quota up relatively fast.
Is there a faster way around the problem?
I would like to implement it on an ESP8266 so it would be preferable not to require a lot of storage or processing power.
You can get the view count by getting the liveStreamingDetails, the liveStreamingDetails object contains metadata about a live video broadcast. The object will only be present in a video resource if the video is an upcoming, live, or completed live broadcast. Then, under this, you will get the concurrentViewers. It will show the number of viewers currently watching the broadcast. The property and its value will be present if the broadcast has current viewers and the broadcast owner has not hidden the viewcount for the video
EDIT
Specific to your use case, I believe a 2-part API would help with your inquiry.
I'm thinking of you calling a search query to retrieve all videos of the channel. The Search resource will have the id.videoId that you'll concatenate as part of the list call. This will give you the statistics.viewCount of each video, which you'll need to add up to get the total channel view count.
Hopefully this helps with your inquiry.
Happy coding!
I've been playing around with the Twitter API using Twitter4j. I am trying to pull data given a keyword and date, and example of a query I would run using the REST API would be
bagels since:2014-12-27
Which would give me all tweets containing the keyword 'bagels' since 2014-12-27.
This works in theory, but I've quickly exceeded the rate limits since each query allows up to 100 results, and only 180 queries are allowed within a 15-minute interval. There are many keywords that return more than 18k results.
Is there a better way to pull large amounts of data from Twitter? I looked at the Streaming API but I don't know if I can pull data from a certain date range.
There are a few things you can do to improve your rates:
Make sure your count is maxed at 100, which it looks like you're doing.
Use Application-Only authorization - it increases your rate limit to 450.
Use the max_id, since_id parameters to page through data and avoid querying for results you're already received. See the Working with Timelines docs to see what I mean.
Consider using Gnip if you're willing to pay to remove rate limits.
I'm trying to construct a YouTube Analytics API query to return the total views across multiple channels owned by a single content owner (a YouTube network).
My request looks like this: GET https://www.googleapis.com/youtube/analytics/v1/reports?ids=contentOwner%3D%3D{MY_CONTENTOWNER_ID}&start-date=2000-01-01&end-date=2012-12-06&metrics=views&filters=claimedStatus%3D%3Dclaimed&key={MY_API_KEY}
The query must include a filter, so I've included claimedStatus=claimed.
Two questions:
The value returned is off by a significant factor (almost 1/2) compared to the number reported for claimed videos in the YouTube Content Manager > Video Report.
How can I get at the view count for all videos, not just claimed videos?
I have the same question about querying total subscribers across channels.
TIA
Can you try filters=uploaderType==self instead of filters=claimedStatus==claimed? Does that give you metrics closer to what you'd expect?
I am storing in a database, every 30 minutes, Twitter's trending topics of a country Y. No problem with that.
Now, I want to get as much tweets as possible matching those trending topics for research purposes.
Since I would like to study the patterns of the trends, I would like continuous tweet data of at least 3 days centered in the day the trend peak was detected, for every trending topic. In order to achieve that, I thought of doing the following:
Suppose I am in day X. I could retrieve the unique trends of day X-2, and for every trend, look for tweets matching the trend in the interval [X-3, X-1], that is 3 days. However, the problem here is Twitter rate limitations. If I have 100 trending topics in day X-2, and I make 20 GET search requests/trend, I would end up doing a total of 2,000 requests, which overpasses Twitter's 350 hourly rate limit. If make 300 req/hour, it would take more than 6 hours to get the data for only one day...
Does anybody know any other (better) way for getting tweets associated with trends?
Thanks in advance
Twitter Streaming API?
Twitter Streaming API doesn't deliver any past tweets. You only receive tweets starting from the time the server connection is established. The search API will return tweets matching the current query up to 7 days old in theory, but that is entirely up to Twitter’s current load. (Note*-At times this interval has been as short as 24 hours. In addition, you are limited by the ability to only receive up to 1,500 tweets regardless of how old they are.)
Is there any way to get more tweets from the streaming?
None that I know. But, do refer the below mentioned information if you are considering to switch among search or streaming API.
Please choose your case:
If you need real time data and your number of requests are high:
Go for Streaming API
The streaming API requires that you keep the connection active. This requires a server process with an infinite loop, to get the latest tweets.
Advantage
1)Lag in retrieving results: Tweets delivered with this method are basically real-time, with a lag of a second or two at most between the time the tweet is posted and it is received from the API
2)Not rate limited.
If you need aggregate data regardless of its time range and your number of requests are not high:
Go for Search API
The search API is the easier of the two methods to implement but it is rate limited .Each request will return up to 100 tweets, and you can use a page parameter to request up to 15 pages, giving you a theoretical maximum of 1,500 tweets for a single query.
Advantage
1)Finding tweets in the past:The search API wins by default in this area, because the streaming API doesn’t deliver any past tweets
2)Easier to implement