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, useAccept-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
(terms, relation=None, index=0, limit=25, **kwargs)¶ 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_object
(object_t, object_id=None, relation=None, parent=None, **kwargs)¶ Actually query the Deezer API to retrieve the object
Returns: json dictionary
-
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.