user3297987
user3297987

Reputation: 41

YouTube API V3 search, related videos sort order doesn't work

When searching for related videos using the YouTube API V3 the sort order doesn't seem to work?

E.g. https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=50&order=date&relatedToVideoId=moSFlvxnbgk&type=video&key={YOUR_API_KEY}

and

https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=50&order=viewCount&relatedToVideoId=moSFlvxnbgk&type=video&key={YOUR_API_KEY}

both return the same result.

Bug or am I missing something?

Upvotes: 4

Views: 4930

Answers (2)

user4513271
user4513271

Reputation:

order=date is correct, however, the date is sorting by the creation date. That may be why they seem like they are in the wrong order. That doesn't explain why the view count didn't adjust the order you were getting. If it was an issue that was 2014 specific, I'm sure that's over by now. Here are the possibilities with the order parameter.

date – Resources are sorted in reverse chronological order based on the date they were created.

rating – Resources are sorted from highest to lowest rating.

relevance – Resources are sorted based on their relevance to the search query. This is the default value for this parameter.

title – Resources are sorted alphabetically by title. videoCount – Channels are sorted in descending order of their number of uploaded videos.

viewCount – Resources are sorted from highest to lowest number of views. For live broadcasts, videos are sorted by number of concurrent viewers while the broadcasts are ongoing.

Source: https://developers.google.com/youtube/v3/docs/search/list

Upvotes: 1

lingu
lingu

Reputation: 36

Try "order=published" (instead of "order=date"). That's how it was in v2, except it was "sort=published"

Upvotes: -2

Related Questions