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.
- 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, **params)¶
Actually query the Deezer API to retrieve the object.
- Returns
an
Resource
or subclass.
- object_url(object_t, object_id=None, relation=None)¶
Helper method to build the url to query to access the object passed as parameter
- Raises
TypeError – if the object type is invalid
- search(query, relation=None, index=0, limit=25, **kwargs)¶
Search track, album, artist or user
- Returns
a list of
Resource
objects.
- static url(request_path='')¶
Build the url with the appended request if provided.