Client module

Implements a client class to query the Deezer API

class deezer.client.Client(app_id=None, app_secret=None, access_token=None, headers=None, **kwargs)

A client to retrieve some basic infos about Deezer resourses.

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

>>> import deezer
>>> client = deezer.Client(app_id='foo', app_secret='bar')

This client provides several method to retrieve the content of most sort 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.

>>> import deezer
>>> client = deezer.Client(headers={'Accept-Language': 'fr'})
Parameters:
  • app_id – appliication ID.
  • app_secret – application secret.
  • access_token – user access token.
  • headers – a dictionary of headers to be used.

Deprecated since version 1.4.0.

The following parameters will be removed in the next major version:

  • host - override the default hostname.
  • use_ssl - connect using HTTP if set to False.

Advanced search of track, album or artist.

See Search section of Deezer API for search terms.

Returns:a list of Resource objects.
>>> client.advanced_search({"artist": "Daft Punk", "album": "Homework"})
>>> client.advanced_search({"artist": "Daft Punk", "album": "Homework"},
...                        relation="track")
get_album(object_id, relation=None, **kwargs)

Get the album with the provided id

Returns:an Album object
get_artist(object_id, relation=None, **kwargs)

Get the artist with the provided id

Returns:an Artist object
get_chart(relation=None, index=0, limit=10, **kwargs)

Get chart

Returns:a list of Resource objects.
get_comment(object_id)

Get the comment with the provided id

Returns:a Comment object
get_genre(object_id)

Get the genre with the provided id

Returns:a Genre object
get_genres()
Returns:a list of Genre objects.
get_object(object_t, object_id=None, relation=None, parent=None, **kwargs)

Actually query the Deezer API to retrieve the object

Returns:json dictionary
get_playlist(object_id)

Get the playlist with the provided id

Returns:a Playlist object
get_radio(object_id=None)

Get the radio with the provided id.

Returns:a Radio object
get_radios()

Get a list of radios.

Returns:a list of Radio objects
get_radios_top()

Get the top radios (5 radios).

Returns:a Radio object
get_track(object_id)

Get the track with the provided id

Returns:a Track object
get_user(object_id)

Get the user with the provided id

Returns:a User object
object_url(object_t, object_id=None, relation=None, **kwargs)

Helper method to build the url to query to access the object passed as parameter

Raises:TypeError – if the object type is invalid
scheme

Get the http prefix for the address depending on the use_ssl attribute

search(query, relation=None, index=0, limit=25, **kwargs)

Search track, album, artist or user

Returns:a list of Resource objects.
url(request='')

Build the url with the appended request if provided.