user1849133
user1849133

Reputation: 527

Does Youtube API have "AND and OR" search and explicit match search?

Does Youtube API allow me to do searches like

Search videos which have (in their title) strings both Lady Gaga AND (Cyrus OR Muse)

And does Youtube API allow me to do searches like

Search videos which have (in their title) string exactly Katy Perry. I don't want titles which have Katy Elizabeth Perry.

What's the most efficient code to write that type of search request? I want to code it using Ruby on rails.

I've gone through various introduction about how to search Youtube but they were mainly talking about other filtering things like relevance and view counts filtering.

Upvotes: 0

Views: 335

Answers (1)

Ibrahim Ulukaya
Ibrahim Ulukaya

Reputation: 12877

And is supported with include and exclude just like the search query in the Web UI.

You can use -{query term} to exclude a query term. Or |{gaga} to OR.

like {lady -gaga} or in decoded form

https://www.googleapis.com/youtube/v3/search?part=snippet&q=lady+-gaga&key={YOUR_API_KEY}

You can also make separate calls, put results into sets and do all these operations in your client.

Upvotes: 2

Related Questions