How to get data by date using Youtube API? - youtube-api

Im new to yt api and i was wondering how can i get for example top 50 channels by subscriber count with defined date, or in interval like 2018-2019?

Related

How to specify dates when retrieving a stocktwits stream

I am retrieving streams from the https://api.stocktwits.com/api/2/streams/symbol/:id.json endpoint, but so far I have been getting the latest 30 posts. I'm wondering if it's possible to specify a date in the past to get posts for that date, or a range of dates.

Youtube api to get advance statistics per video per day

I have been trying to get the video list of our youtube channel and advance statistics like avg view duration, subscribers gained, watch time, etc.
These statistics do exist in Youtube analytics Web GUI. But I could not find how I can implement that per video via API.
I have tried youtubeAnalytics.reports.query API - but unable to get the advanced statistics.
with these parameters
ids : channel==MINE
filter = video==
startdate: 2019-02-15
enddate: 2019-02-20
metrics likes- dislikes avgviewDuration,
dimension: day
and other try with
dimension day,video
I am getting null data or query not implemented.

YouTube Data Api v3 consistently returns invalid statistics

I'm using YouTube Data v3 in order to get statistics of a certain channel. To be precise I'm following this documentation.
I can get all data properly except for commentCount property. For example GET request:
https://www.googleapis.com/youtube/v3/channels?part=statistics&forUsername=Kurzgesagt&key={YOUR_API_KEY}
Which results in commentCount = 23
This is obviously not correct as this channel has much more than that.
Same thing happens to almost all other channels (not all of them). Is there any particular reason for this behaviour? Why does it return this number?
I've been monitoring this value for more than a week and it hasn't changed once in that time period.
Edit: I know that commentCount property should return number of comments on that channel (not sum of all videos), but for some reason this doesn't really match. You can compare the commentCount I mentioned with real comments for Kurzgesagt channel on YT directly.
CommentCount returns the number of comments in the channel, not the sum of all comments in the channel's videos, this has already been answered here Youtube Data Api has commentCount field and is this the number of comments on channel?
There seems to be more than one channels for that user, so is the link that you provided actually supposed to bring back the expected feedback ? There is no specified channel id on your URL.
Try the following:
GET https://www.googleapis.com/youtube/v3/commentThreads?part=snippet%2Creplies&allThreadsRelatedToChannelId=ChannelId&key={YOUR_API_KEY}

How to get duration of videos from URLs in spreadsheet

I have a very loooong list of YouTube videos (in Google sheets) and want to get their duration.
You can pull it using importxml:
=IMPORTXML("youtube url","//*[#itemprop='duration']/#content")
the format comes back as PT7M54S which means 7 min 54 seconds so if you want to transform it you can do this:
=REGEXREPLACE(IMPORTXML("youtube url","//*[#itemprop='duration']/#content"),"(PT)(\d+)M(\d+)S","$2:$3")

youtube api v3 - get videos from a playlist with view count data ordered by number of views

I want to get all the videos from a playlist with statistics data like viewCount and the videos should be ordered by number of video views. So far I have managed the following:
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=UUbW18JZRgko_mOGm5er8Yzg&key={YOUR_KEY_HERE}&maxResults=50
In the youtube api v2 we can pass part=statistics to get the view count but this is not working with v3 playlists. How can I get the above the video data in the above mentioned format.
From the results of playlistItems.list call, collect the video ids, make a comma-separated list and set it as id parameter of videos.list call. That call will give you the data you need.

Resources