4
votes

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?

2
i use your link and I have also this error, order=date dont sort the result by date in reverse chronological order. You have exactly the same result with order=date and no order sort parametertomboul

2 Answers

1
votes

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

-2
votes

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