nonerth
nonerth

Reputation: 569

Youtube search using the google API

I am using the google API and I wanted to do a youtube search.

I request a search with https://www.googleapis.com/youtube/v3/search?part=snippet&q=[word that I searched for]&key=my_keyto get the items array. I noticed though that the items array does not return the results in the same order as when you search youtube yourself.

Ex: if I search for the word 'bad' the first result in the items array is the "Young Lex ft AwKarin - BAD ( Official Music Video Clip )" while if I searched like a youtube user its the "Michael Jackson - Bad (Shortened Version)".

Perhaps they are not ordered and I have to order them using a property or something I have missed.

So my question is how can I make the items array return as the first item the first result that would have appeared in the youtube search.

edit: I have tried adding chart=MostPopular leaving to default videoCategoryId, but it still showed the same first result.

Upvotes: 0

Views: 682

Answers (1)

KENdi
KENdi

Reputation: 7761

Well, it seems that the YouTube acts like that and it is a natural behavior of it. The only possible way that you can do to match the API and the YouTube site itself is by passing the same filter for it. Example is upload date and viewCount.

Here is the example request for viewCount.

https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?part=snippet&maxResults=10&order=viewCount&q=spider&_h=1&

and this is for the YouTube site

https://www.youtube.com/results?q=spider&sp=CAM%253D

Hope this slight information helps you.

Upvotes: 1

Related Questions