When using the API for retrieving aggregated metrics for the channel's content the report returns a single row of data that contains totals for each requested metric during the specified date
range.
Here's an API Example link.
Sometimes not even account information is received; the object rows is not present in the response but only columnHeaders, even though the account has the appropriate fields populated (I can see it on the profile available on youtube).
I have made the same observations as jay. Somehow some metrics returned no result rows. But for me it turned out that those missing rows were also not available in youtube's Analytics integration.
As you can see, all "Interaktionen (Interactions)" have 0 values, but the "Geteilte Inhalte (shares)" column differs from the rest. It has no values attached. If you click on the metric you get the following notification
It says: "There is no data available at the moment, chose a diffrent time range or wait some more days".
So for me the API data was always corresponding with youtube's analytics integration.
Related
I want to append a row of cells to a google sheet and also attach some developer metadata to that row.
In the Google Sheets v4 API, I know you can use batchUpdate to append a row with the appendCells request, and you can add developer metadata using the createDeveloperMetadata request.
My issue is that I wanna set some developer metadata to specifically the newly appended cells atomically. There's not really a way to specifically ensure the range of the newly added row in createDeveloperMetadata, and if I use two different requests, someone else may insert a row between those requests which could shift all the rows, causing the appended cell's range to be pointing to an incorrect row.
Is there a way to attach developer metadata to a newly added cell atomically?
Answer:
There is not currently way of ensuring that the sheet structure hasn't changed between requests.
More Information:
Your The best option, I think, is to make two sequential requests in the same batch. Though this isn't foolproof, in very unlucky circumstances. Even inserting the row directly using an UpdateCellsRequest isn't foolproof either, as simply knowing which row you inserted the data doesn't exclude the possibility that someone else may insert/delete a row before it between the two requests.
Feature Request:
You can however let Google know that this is a feature that is important for the Sheets API and that you would like to request they implement it. Google's Issue Tracker is a place for developers to report issues and make feature requests for their development services.
The page to file a Feature Request for the Google Sheets API is here.
References:
Requests - UpdateCellsRequest | Sheets API | Google Developers
Requests - AppendCellsRequest | Sheets API | Google Developers
The solution I figured out was essentially:
Fetch the dimensions of the sheet
Perform a batch update with insertDimension, updateCells, and createDeveloperMetadata all performed for the same sheet dimension index at the end of the sheet
This basically ensures that the dimension index will point to the same row for all 3 operations in the batch update, and if the index points out of bounds, all 3 operations will fail
I am trying to get video metrics for each video under my channel using Java SDK.
videoMetrics = analytics.reports()
.query("channel==" + channelId, video_start_date, video_end_date, "views,comments,likes,dislikes,estimatedMinutesWatched")
.setDimensions("day")
.setSort("-estimatedMinutesWatched")
.setFilters("video==" + videoId)
.setFilters("country==US")
.execute();
This request not providing the metrics for each video on a particular day. Can anyone suggest the issue and solution in the code.
You're looking for reports.query.
The YouTube Analytics
API's
reports.query method lets you retrieve many different Analytics
reports. Each request uses query parameters to specify a channel ID or
content owner, a start date, an end date, and at least one metric. You
can also provide additional query parameters, such as dimensions,
filters, or sorting instructions.
Metrics are individual measurements of user activity, such as video
views or ratings (likes and dislikes). Dimensions are common criteria
that are used to aggregate data, such as the date on which the user
activity occurred or the country where the users were located. Filters
are dimension values that specify the data that will be retrieved. For
example, you could retrieve data for a specific country, a specific
video, or a group of videos.
Through a script I can collect a sequence of videos that search list returns. The maxresults variable was set to 50. The total number items are big in number but the number of next page tokens are not enough to retrieve all the desired results. Is there any way to take all the returned items or it is YouTube restricted?
Thank you.
No, retrieving the results of a search is limited in size.
The total results that you are allowed to retrieve seems to have been reduced to 500 (in the past it was limited to 1000). The api does not allow you to retrieve more from a query. To try to get more, try using a number of queries with different parameters, like: publishedAfter, publishedBefore, order, type, videoCategoryId, or vary the query tags and keep track of getting different video id's returned.
See for a reference:
https://code.google.com/p/gdata-issues/issues/detail?id=4282
BTW. "totalResults" is an estimation and its value can change on the next page call.
See: YouTube API v3 totalResults field is returning 1 000 000 when it shoudn't
The YouTube V3 Data API provides "page tokens" for paging result sets from search endpoints.
Is the dataset being viewed consistent if you make use of the page tokens?
e.g. if there is an ordering on view count, which is likely to change with time, then is the ordering over the total result set guaranteed across multiple queries, so the lowest result on the first page is guaranteed to be ordered greater than the highest result on the following page?
The ordering is not guaranteed when using page tokens. (Nor was it guaranteed when using start-index in v1/v2.) If something changes with the backend data source's ordering in between fetching one page and the next page, then retrieving the next page would reflect the updated ordering.
I am currently trying to pull data about videos from a YouTube user upload feed. This feed contains all of the videos uploaded by a certain user, and is accessed from the API by a request to:
http://gdata.youtube.com/feeds/api/users/USERNAME/uploads
Where USERNAME is the name of the YouTube user who owns the feed.
However, I have encountered problems when trying to access feeds which are longer than 1000 videos. Since each request to the API can return 50 items, I am iterating through the feed using max_length and start_index as follows:
http://gdata.youtube.com/feeds/api/users/USERNAME/uploads?start-index=1&max-results=50&orderby=published
http://gdata.youtube.com/feeds/api/users/USERNAME/uploads?start-index=51&max-results=50&orderby=published
And so on, incrementing start_index by 50 on each call. This works perfectly up until:
http://gdata.youtube.com/feeds/api/users/USERNAME/uploads?start-index=1001&max-results=50&orderby=published
At which point I receive a 400 error informing me that 'You cannot request beyond item 1000.' This confused me as I assumed that the query would have only returned 50 videos: 1001-1051 in the order of most recently published. Having looked through the documentation, I discovered this:
Limits on result counts and accessible results
...
For any given query, you will not be able to retrieve more than 1,000
results even if there are more than that. The API will return an error
if you try to retrieve greater than 1,000 results. Thus, the API will
return an error if you set the start-index query parameter to a value
of 1001 or greater. It will also return an error if the sum of the
start-index and max-results parameters is greater than 1,001.
For example, if you set the start-index parameter value to 1000, then
you must set the max-results parameter value to 1, and if you set the
start-index parameter value to 980, then you must set the max-results
parameter value to 21 or less.
I am at a loss about how to access a generic user's 1001st last uploaded video and beyond in a consistent fashion, since they cannot be indexed using only max-results and start-index. Does anyone have any useful suggestions for how to avoid this problem? I hope that I've outlined the difficulty clearly!
Getting all the videos for a given account is supported, but you need to make sure that your request for the uploads feed is going against the backend database and not the search index. Because you're including orderby=published in your request URL, you're going against the search index. Search index feeds are limited to 1000 entries.
Get rid of the orderby=published and you'll get the data you're looking for. The default ordering of the uploads feed is reverse-chronological anyway.
This is a particularly easy mistake to make, and we have a blog post up explaining it in more detail:
http://apiblog.youtube.com/2012/03/keeping-things-fresh.html
The nice thing is that this is something that will no longer be a problem in version 3 of the API.