Skip to main content

A lightweight python client for the spotify

Project description

WrapperSpotify

This is light weight python wrapper for the spotify api. Ligh weight as it doesn't currently expose methods for all the endpoint functionality provided by sportify, just a few. This wrapper client uses the client credential workflow hence does not expose methods for any fuctionality that require user scope or authorization(yet).

Features

  • Handles token generation for you
  • Automatically refreshes tokens if they expire
  • Exposes methods to allow you to query the sportify api easily

Usage

  • Install with pip
pip install WrapperSpotify

search for artist

  • create a dictionary with client credentials
  • initialize client object
  • call method with artist name
    import WrapperSpotify 
    credentials = {
        "ClientID":os.getenv("ClientID"),
        "ClientSecret":os.getenv("ClientSecret")
    }

    client = WrapperSpotify.Client(credentials)
    results = client.artist_search("artist name")
    

The artist_search method takes some optional arguments

  • filter set to true by default. filters out the results returned from api inti a smaller size. providing only some info such as artist id, profile , images etch when set to false , results is not filtered and giant results from api is returned to you

results = client.artist_search("artist name", filter=False)

  • limit set to 1 by default so results for only one artist is returned. You can increase range of results returned by increasing it . check spotify api docs for detailed explanation

results = client.artist_search("artist name", Limit=5) will return results for 5 differents artist which matches your artist name argument

search for track

  • create a dictionary with client credentials
  • initialize client object
  • call method with track name
import WrapperSpotify
credentials = {
        "ClientID":os.getenv("ClientID"),
        "ClientSecret":os.getenv("ClientSecret")
    }

    client = WrapperSpotify.Client(credentials)
    results = client.track_search("track name")
    

The track_search method takes some optional arguments

  • filter set to true by default. filters out the results returned from api inti a smaller size. providing only some info such as artist id, profile , images etch when set to false , results is not filtered and giant results from api is returned to you

results = client.artist_search("artist name", filter=False)

  • limit set to 1 by default so results for only one artist is returned. You can increase range of results returned by increasing it . check spotify api docs for detailed explanation

results = client.artist_search("artist name", Limit=5)

search for related artist

  • create a dictionary with client credentials
  • initialize client object
  • call method with artist id
    import WrapperSpotify
    credentials = {
        "ClientID":os.getenv("ClientID"),
        "ClientSecret":os.getenv("ClientSecret")
    }

    client = WrapperSpotify.Client(credentials)
    results = client.get_related_artists("artist id")
    

check api docs for detailed explanation

search for track recommendations

  • create a dictionary with client credentials
  • initialize client object
  • call method with dictionary containing query parameter keys and their values
    import WrapperSpotify
    credentials = {
        "ClientID":os.getenv("ClientID"),
        "ClientSecret":os.getenv("ClientSecret")
    }

    client = WrapperSpotify.Client(credentials)

    options =  {
        "seed_artists":"5K4W6rqBFWDnAN6FQUkS6x",
        "seed_genres":"alt-rock",
        "seed_tracks":"6MXXY2eiWkpDCezVCc0cMH,"

    }

    results = client.get_recommendations(options)
    

seed_artists,seed_genres and seed_tracks are required parameters for this endpoint and have to be added or an exception will be thrown. you can specify other parameters to filter recommendations by . check api docs

search for available genres

  • create a dictionary with client credentials
  • initialize client object
    import WrapperSpotify
    credentials = {
        "ClientID":os.getenv("ClientID"),
        "ClientSecret":os.getenv("ClientSecret")
    }

    client = WrapperSpotify.Client(credentials)
    results = client.get_avilable_genres()
    

check api docs for detailed explanation

Project details


Download files

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

Source Distribution

WrapperSpotify-1.0.6.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

WrapperSpotify-1.0.6-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file WrapperSpotify-1.0.6.tar.gz.

File metadata

  • Download URL: WrapperSpotify-1.0.6.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for WrapperSpotify-1.0.6.tar.gz
Algorithm Hash digest
SHA256 7633049f24fca73142d850df351d0af40b84289b9d3998ddfe889e99ccadaaf3
MD5 8f4532e3fd849501bc0eda8f10cd7a75
BLAKE2b-256 6b27a87f971ed79dcca48fc5c61b22c6e9f8e4e7a5fdb3c0d7e2ee9016a66172

See more details on using hashes here.

File details

Details for the file WrapperSpotify-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: WrapperSpotify-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for WrapperSpotify-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 6e33df2b1014b1c9f067ea36298f2c2bf31be0c25057d86676fdb719a38a635d
MD5 3b9e72ab1b8cf222dba4f34ddcf041d9
BLAKE2b-256 0ff544ed02fd1c28331af007a793a4fb495c8bd8d9eb4bd38fe5cba3a3e134c3

See more details on using hashes here.

Supported by

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