user2150279
user2150279

Reputation: 475

How to get most popular videos on a daily basis for a date range using YouTube API?

I understand there is a similar question asked 7 years ago. I wonder if there is any changes in the YouTube API.

Basically, I want to get the video statistics from YouTube using the API below on a GET request:

https://www.googleapis.com/youtube/v3/videos?part=id,statistics,snippet{page_token}chart=mostPopular&regionCode={country_code}&maxResults=50&key={api_key}.

However, I want to get:

I have checked the YouTube API page here, but there is no parameter for me to get the most popular videos statistics from previous date range.

Any advise how to do so? Is it possible?

Upvotes: 1

Views: 583

Answers (1)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116868

I don't think there has been any changes to the YouTube API in years. Personally i would sort by rating and not view count but I think that depends on what you count as popularity.

curl \
  'https://youtube.googleapis.com/youtube/v3/search?part=snippet&maxResults=200&order=rating&publishedAfter=2021-03-06T00%3A00%3A01Z&publishedBefore=2021-03-06T23%3A59%3A01Z&fields=*&key=[YOUR_API_KEY]' \
  --header 'Accept: application/json' \
  --compressed

If you want previous date range you just need to build up a different call with different dates.

You can test it in the try me

Upvotes: 0

Related Questions