jhonatan santos
jhonatan santos

Reputation: 1

Perform only search on a genre with web api spotify

I have a script that performs search on spotify. however I would like to just have a genre on my site, thus limiting the search in just one genre to specific. for example: rock.

When typing the name of any band in the search field, if it is in the Rock genre it will appear, otherwise nothing happens.

I'm going to put the spotify link that has this support:

https://developer.spotify.com/web-api/console/get-search-item/#complete

my code that I am trying to modify is this:

<?php namespace App\Services\Search;

interface SearchInterface {

    /**
     * Search database using given params.
     *
     * @param string  $q
     * @param int     $limit
     * @param string  $type
     *
     * @return array
     */
    public function search($q, $limit = 10);
}

Upvotes: 0

Views: 3617

Answers (1)

Rach Sharp
Rach Sharp

Reputation: 2434

From https://developer.spotify.com/documentation/web-api/reference/#endpoint-search/

Other possible field filters, depending on object types being searched, include genre (applicable to tracks and artists), upc, and isrc. For example, q=lil%20genre:%22southern%20hip%20hop%22&type=artist. Use double quotation marks around the genre keyword string if it contains spaces.

When you submit your search query, include genre:"your genre" alongside any other terms you are searching on in the query.

Upvotes: 1

Related Questions