Skip to content

Search

Module with the search endpoint

Search (Endpoint)

Search endpoint

Source code in async_spotify/api/_endpoints/search.py
class Search(Endpoint):
    """
    Search endpoint
    """

    async def start(self, query: str, query_type: List[str], auth_token: SpotifyAuthorisationToken = None,
                    **kwargs) -> dict:
        """
        Make a search

        Notes:
            [https://developer.spotify.com/documentation/web-api/reference/search/search/](https://developer.spotify.com/documentation/web-api/reference/search/search/)

        Args:
            query: The search query
            query_type: A comma-separated list of item types to search across.
                Valid types are: album , artist, playlist, track, show and episode.
                Search results include hits from all the specified item types.
                For example: q=name:abacab&type=album,track returns both albums and tracks with
                “abacab” included in their name.
            auth_token: The auth token if you set the api class not to keep the token in memory
            kwargs: Optional arguments as keyword args

        Returns:
            The search result
        """

        args = {**{'q': query, 'type': query_type}, **kwargs}
        return await self.api_request_handler.make_request('GET', URLS.SEARCH, args, auth_token)

start(self, query, query_type, auth_token=None, **kwargs) async

Make a search

Parameters:

Name Type Description Default
query str

The search query

required
query_type List[str]

A comma-separated list of item types to search across. Valid types are: album , artist, playlist, track, show and episode. Search results include hits from all the specified item types. For example: q=name:abacab&type=album,track returns both albums and tracks with “abacab” included in their name.

required
auth_token SpotifyAuthorisationToken

The auth token if you set the api class not to keep the token in memory

None
kwargs

Optional arguments as keyword args

{}

Returns:

Type Description
dict

The search result

Source code in async_spotify/api/_endpoints/search.py
async def start(self, query: str, query_type: List[str], auth_token: SpotifyAuthorisationToken = None,
                **kwargs) -> dict:
    """
    Make a search

    Notes:
        [https://developer.spotify.com/documentation/web-api/reference/search/search/](https://developer.spotify.com/documentation/web-api/reference/search/search/)

    Args:
        query: The search query
        query_type: A comma-separated list of item types to search across.
            Valid types are: album , artist, playlist, track, show and episode.
            Search results include hits from all the specified item types.
            For example: q=name:abacab&type=album,track returns both albums and tracks with
            “abacab” included in their name.
        auth_token: The auth token if you set the api class not to keep the token in memory
        kwargs: Optional arguments as keyword args

    Returns:
        The search result
    """

    args = {**{'q': query, 'type': query_type}, **kwargs}
    return await self.api_request_handler.make_request('GET', URLS.SEARCH, args, auth_token)

Last update: April 27, 2020