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
headerskwarg. For example, useAccept-Languageheader 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
AsyncArtistobject- Parameters:
artist_id (int)
- Return type:
- async get_album(album_id)¶
Get the album with the given ID.
- Returns:
an
AsyncAlbumobject- Parameters:
album_id (int)
- Return type:
- async get_track(track_id)¶
Get the track with the given ID.
- Returns:
an
AsyncTrackobject- Parameters:
track_id (int)
- Return type:
- async get_genre(genre_id)¶
Get the genre with the given ID.
- Returns:
an
AsyncGenreobject- Parameters:
genre_id (int)
- Return type:
- async get_radio(radio_id)¶
Get the radio with the given ID.
- Returns:
an
AsyncRadioobject- Parameters:
radio_id (int)
- Return type:
- async get_podcast(podcast_id)¶
Get the podcast with the given ID.
- Returns:
an
AsyncPodcastobject- Parameters:
podcast_id (int)
- Return type:
- async get_episode(episode_id)¶
Get the episode with the given ID.
- Returns:
an
AsyncEpisodeobject- Parameters:
episode_id (int)
- Return type:
- async get_editorial(editorial_id)¶
Get the editorial with the given ID.
- Returns:
an
AsyncEditorialobject- Parameters:
editorial_id (int)
- Return type:
- async get_playlist(playlist_id)¶
Get the playlist with the given ID.
- Returns:
an
AsyncPlaylistobject- Parameters:
playlist_id (int)
- Return type:
- async get_user(user_id=None)¶
Get the user with the given ID.
- async get_chart(genre_id=0)¶
Get overall charts for the given genre ID.
- Returns:
an
AsyncChartobject- Parameters:
genre_id (int)
- Return type:
- async list_editorials()¶
List editorials.
- Returns:
an
AsyncPaginatedListofAsyncEditorialobjects.- Return type:
- async list_genres()¶
List musical genres.
- Returns:
a list of
AsyncGenreinstances- Return type:
list[AsyncGenre]
- async list_radios()¶
List radios.
- Returns:
a list of
AsyncRadioinstances- Return type:
list[AsyncRadio]
- async get_radios_top()¶
Get the top radios.
- Returns:
an
AsyncPaginatedListofAsyncRadioobjects.- Return type:
- async get_user_recommended_tracks(**kwargs)¶
Get user’s recommended tracks.
- Return type:
- async get_user_recommended_albums(**kwargs)¶
Get user’s recommended albums.
- Return type:
- async get_user_recommended_artists(**kwargs)¶
Get user’s recommended artists.
- Return type:
- async get_user_recommended_playlists(**kwargs)¶
Get user’s recommended playlists.
- Return type:
- async get_user_flow(**kwargs)¶
Get user’s flow.
- Return type:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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: