Skip to main content

A python SDK for the Deezer API

Project description

This is a python sdk to manipulate the deezer's API

Installation

pip install deezersdk

Import

import deezersdk

Authentication to the API

  • You need to have a Deezer account to use the API.

  • You have to go on https://developers.deezer.com/myapps and create an a new app

  • You will need, your Application ID, Secret Key and the Redirect URL.

  • First we use the get_oauth_login_url method to get a login url

    url = Deezer.get_oauth_login_url(
        app_id=DEEZER_APP_ID, 
        redirect_uri=DEEZER_REDIRECT_URI
    )
    
  • We have to go the url (if the pop up will open and we will be able to login to your deezer account.)

  • You will then be redirected to your redirect url with an authorization code in your url.

  • With this code you can, request your access token

    Deezer.get_oauth_token(app_id=DEEZER_APP_ID, app_secret=DEEZER_APP_SECRET, code=code)
    
  • You now have your access token, and can use the SDK.

Using the sdk

Instantiate the Deezer object

dz = Deezer(app_id=DEEZER_APP_ID,
                          app_secret=DEEZER_APP_SECRET,
                          code=YOUR_URL_CODE,
                          token=YOUR_ACCESS_TOKEN)

Query the API

Get my playlists

dz.get_my_playlists()

Will return an array of Playlist objects witch contains the title of the playlist, the url of the picture, and a boolean is_loved_track to True if it's your loved playlist

Play a music with the Deezer plugins

playlists = dz.get_my_playlists()
url = dz.get_widget(playlist=playlists[0])

This will give an of the plugin loaded with your playlist. You can add the url in an iframe to display the plugin or you can open it directly with :

import webbrowser
webbrowser.open(url)

You call also play a list of tracks

playlists = dz.get_my_playlists()
url = dz.get_widget(tracks=tracks)

Get your Flow

tracks = dz.get_flow()

Get my favorites artists

artists = dz.get_my_favorite_artists()

Methods on a Track

album = tack.get_album()
artist = tack.get_artist()

Methods on an Album

tracks = album.get_tracks()
artist = album.get_artist()

Methods on an Artist

tracks = artist.get_tracks()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

deezersdk-0.18-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file deezersdk-0.18-py3-none-any.whl.

File metadata

  • Download URL: deezersdk-0.18-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for deezersdk-0.18-py3-none-any.whl
Algorithm Hash digest
SHA256 2e7648ba1cce44f2a5585091191b864bfa6c17b03be5c06bdc5c738c988bea2e
MD5 d393c4db12eb9769f9ee2ebf0912bc17
BLAKE2b-256 8a9a6d3ecb47c168e82f163bedc87a02c6f67570479ccf18a1fe99f4e008f344

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page