Reputation: 1249
I'm building a query to return a list of Youtube videos using the Youtube Data API v3. I need to order the results based on last week's (last 7 days) view count. Using the API I can only return videos sorted by total view count.
Here is the query I currently have:
https://www.googleapis.com/youtube/v3/search?part=snippet&category=comedy&order=viewCount&key=[MY KEY]
What parameters do I need to add or modify so that I only return a list sorted by the highest view count from the last 7 days?
Upvotes: 2
Views: 934
Reputation: 134
List<VideoInfo> videos = new List<VideoInfo>();
RestSharp.RestClient client = new RestClient(YT_BASE_URL +resource);
RestSharp.RestRequest request = new RestRequest();
request.AddParameter("key", APIKEY_YOUTUBE);
request.AddParameter("part", "snippet");
request.AddParameter("maxResults", (int)(maxqty));
request.AddParameter("videoCaption", "none");
request.AddParameter("type", "video");
request.AddParameter("order", "viewCount");
if (!string.IsNullOrEmpty(nextpagetoken))
{
request.AddParameter("pageToken", nextpagetoken);
}
foreach (KeyValuePair<string, string> param in parameters)
{
request.AddParameter(param.Key, param.Value);
}
Upvotes: 0
Reputation: 4185
Use the parameter publishedAfter for 7 days ago.
https://developers.google.com/youtube/v3/docs/search/list#publishedAfter
Upvotes: 1