Skip to content

Personalization

Module with the personalization endpoint

Personalization (Endpoint)

Personalization endpoint

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

    async def get_top(self, content_type: str, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> dict:
        """
        Get the current user’s top artists or tracks based on calculated affinity.

        Notes:
            [https://developer.spotify.com/documentation/web-api/reference/personalization/get-users-top-artists-and-tracks/](https://developer.spotify.com/documentation/web-api/reference/personalization/get-users-top-artists-and-tracks/)

        Args:
            content_type: Do you want to have the top `artists` or `tracks`
            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 top tracks and artists
        """

        url, _ = self._add_url_params(URLS.PERSONALIZATION.TOP, {'type': content_type})
        return await self.api_request_handler.make_request('GET', url, kwargs, auth_token)

get_top(self, content_type, auth_token=None, **kwargs) async

Get the current user’s top artists or tracks based on calculated affinity.

Parameters:

Name Type Description Default
content_type str

Do you want to have the top artists or tracks

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 top tracks and artists

Source code in async_spotify/api/_endpoints/personalization.py
async def get_top(self, content_type: str, auth_token: SpotifyAuthorisationToken = None, **kwargs) -> dict:
    """
    Get the current user’s top artists or tracks based on calculated affinity.

    Notes:
        [https://developer.spotify.com/documentation/web-api/reference/personalization/get-users-top-artists-and-tracks/](https://developer.spotify.com/documentation/web-api/reference/personalization/get-users-top-artists-and-tracks/)

    Args:
        content_type: Do you want to have the top `artists` or `tracks`
        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 top tracks and artists
    """

    url, _ = self._add_url_params(URLS.PERSONALIZATION.TOP, {'type': content_type})
    return await self.api_request_handler.make_request('GET', url, kwargs, auth_token)

Last update: April 27, 2020