Async Client

The async client class is the main entry point to start querying the Deezer API using async/await.

class deezer.asyncio.AsyncClient(access_token=None, headers=None)

An async client to retrieve some basic infos about Deezer resources.

Create a client instance with the given options. Options should be passed in to the constructor as kwargs.

>>> from deezer.asyncio import AsyncClient
>>> client = AsyncClient()

This client provides several async methods to retrieve the content of Deezer objects, based on their json structure.

Headers can be forced by using the headers kwarg. For example, use Accept-Language header to force the output language.

>>> from deezer.asyncio import AsyncClient
>>> client = AsyncClient(headers={'Accept-Language': 'fr'})
Parameters:
  • access_token (str | None) – user access token.

  • headers (HeaderTypes | None) – a dictionary of headers to be used.

async request(method, path, parent=None, resource_type=None, resource_id=None, paginate_list=False, **kwargs)

Make a request to the API and parse the response.

Parameters:
  • method (str) – HTTP verb to use: GET, POST, DELETE, …

  • path (str) – The path to make the API call to (e.g. ‘artist/1234’).

  • parent (AsyncResource | Resource | None) – A reference to the parent resource, to avoid fetching again.

  • resource_type (type[AsyncResource] | type[Resource] | None) – The resource class to use as top level.

  • resource_id (int | None) – The resource id to use as top level.

  • paginate_list – Whether to wrap list into a pagination object.

async get_artist(artist_id)

Get the artist with the given ID.

Returns:

an AsyncArtist object

Parameters:

artist_id (int)

Return type:

AsyncArtist

async get_album(album_id)

Get the album with the given ID.

Returns:

an AsyncAlbum object

Parameters:

album_id (int)

Return type:

AsyncAlbum

async get_track(track_id)

Get the track with the given ID.

Returns:

an AsyncTrack object

Parameters:

track_id (int)

Return type:

AsyncTrack

async get_genre(genre_id)

Get the genre with the given ID.

Returns:

an AsyncGenre object

Parameters:

genre_id (int)

Return type:

AsyncGenre

async get_radio(radio_id)

Get the radio with the given ID.

Returns:

an AsyncRadio object

Parameters:

radio_id (int)

Return type:

AsyncRadio

async get_podcast(podcast_id)

Get the podcast with the given ID.

Returns:

an AsyncPodcast object

Parameters:

podcast_id (int)

Return type:

AsyncPodcast

async get_episode(episode_id)

Get the episode with the given ID.

Returns:

an AsyncEpisode object

Parameters:

episode_id (int)

Return type:

AsyncEpisode

async get_editorial(editorial_id)

Get the editorial with the given ID.

Returns:

an AsyncEditorial object

Parameters:

editorial_id (int)

Return type:

AsyncEditorial

async get_playlist(playlist_id)

Get the playlist with the given ID.

Returns:

an AsyncPlaylist object

Parameters:

playlist_id (int)

Return type:

AsyncPlaylist

async get_user(user_id=None)

Get the user with the given ID.

Returns:

an AsyncUser object

Parameters:

user_id (int | None)

Return type:

AsyncUser

async get_chart(genre_id=0)

Get overall charts for the given genre ID.

Returns:

an AsyncChart object

Parameters:

genre_id (int)

Return type:

AsyncChart

async list_editorials()

List editorials.

Returns:

an AsyncPaginatedList of AsyncEditorial objects.

Return type:

AsyncPaginatedList

async list_genres()

List musical genres.

Returns:

a list of AsyncGenre instances

Return type:

list[AsyncGenre]

async list_radios()

List radios.

Returns:

a list of AsyncRadio instances

Return type:

list[AsyncRadio]

async get_radios_top()

Get the top radios.

Returns:

an AsyncPaginatedList of AsyncRadio objects.

Return type:

AsyncPaginatedList

Get user’s recommended tracks.

Return type:

AsyncPaginatedList

Get user’s recommended albums.

Return type:

AsyncPaginatedList

Get user’s recommended artists.

Return type:

AsyncPaginatedList

Get user’s recommended playlists.

Return type:

AsyncPaginatedList

async get_user_flow(**kwargs)

Get user’s flow.

Return type:

AsyncPaginatedList

async get_user_albums(user_id=None)

Get the favourites albums for the given user_id or current user.

Parameters:

user_id (int | None)

Return type:

AsyncPaginatedList

async add_user_album(album_id)

Add an album to the user’s library.

Parameters:

album_id (int)

Return type:

bool

async remove_user_album(album_id)

Remove an album from the user’s library.

Parameters:

album_id (int)

Return type:

bool

async get_user_artists(user_id=None)

Get the favourites artists for the given user_id or current user.

Parameters:

user_id (int | None)

Return type:

AsyncPaginatedList

async add_user_artist(artist_id)

Add an artist to the user’s library.

Parameters:

artist_id (int)

Return type:

bool

async remove_user_artist(artist_id)

Remove an artist from the user’s library.

Parameters:

artist_id (int)

Return type:

bool

async get_user_followers(user_id=None)

Get the followers for the given user_id or current user.

Parameters:

user_id (int | None)

Return type:

AsyncPaginatedList

async get_user_followings(user_id=None)

Get the followings for the given user_id or current user.

Parameters:

user_id (int | None)

Return type:

AsyncPaginatedList

async add_user_following(user_id)

Follow the given user ID as the currently authenticated user.

Parameters:

user_id (int)

Return type:

bool

async remove_user_following(user_id)

Stop following the given user ID as the currently authenticated user.

Parameters:

user_id (int)

Return type:

bool

async get_user_history()

Get the recently played tracks for the current user.

Return type:

AsyncPaginatedList

async get_user_tracks(user_id=None)

Get the favourites tracks for the given user_id or current user.

Parameters:

user_id (int | None)

Return type:

AsyncPaginatedList

async add_user_track(track_id)

Add a track to the user’s library.

Parameters:

track_id (int)

Return type:

bool

async remove_user_track(track_id)

Remove a track from the user’s library.

Parameters:

track_id (int)

Return type:

bool

async add_user_playlist(playlist_id)

Add a playlist to the user’s library.

Parameters:

playlist_id (int)

Return type:

bool

async remove_user_playlist(playlist_id)

Remove a playlist from the user’s library.

Parameters:

playlist_id (int)

Return type:

bool

async create_playlist(playlist_name)

Create a playlist on the user’s account.

Returns:

the ID of the playlist that was created

Parameters:

playlist_name (str)

Return type:

int

async delete_playlist(playlist_id)

Delete a playlist from the user’s account.

Parameters:

playlist_id (int)

Return type:

bool

async search(query='', strict=None, ordering=None, artist=None, album=None, track=None, label=None, dur_min=None, dur_max=None, bpm_min=None, bpm_max=None)

Search tracks.

Advanced search is available by either formatting the query yourself or by using the dedicated keywords arguments.

Parameters:
  • query (str)

  • strict (bool | None)

  • ordering (str | None)

  • artist (str | None)

  • album (str | None)

  • track (str | None)

  • label (str | None)

  • dur_min (int | None)

  • dur_max (int | None)

  • bpm_min (int | None)

  • bpm_max (int | None)

Return type:

AsyncPaginatedList

async search_albums(query='', strict=None, ordering=None)

Search albums matching the given query.

Parameters:
  • query (str)

  • strict (bool | None)

  • ordering (str | None)

Return type:

AsyncPaginatedList

async search_artists(query='', strict=None, ordering=None)

Search artists matching the given query.

Parameters:
  • query (str)

  • strict (bool | None)

  • ordering (str | None)

Return type:

AsyncPaginatedList

async search_playlists(query='', strict=None, ordering=None)

Search playlists matching the given query.

Parameters:
  • query (str)

  • strict (bool | None)

  • ordering (str | None)

Return type:

AsyncPaginatedList