Skip to main content

Client for interacting with the Spotify API

Project description

spotify-client

Client for interacting with the Spotify API

Full documentation for the library is available on Read the Docs

Usage

First install the package with pip:

pip install spotify-client

Then import the client for usage in your application:

from spotify_client import SpotifyClient

SPOTIFY_CLIENT_ID = 'client_id_from_spotify'
SPOTIFY_SECRET_KEY = 'secret_key_from_spotify'

client = SpotifyClient(SPOTIFY_CLIENT_ID, SPOTIFY_SECRET_KEY, identifier='test-spotify-client')

You'll need to generate your client ID and secret keys for authenticating with Spotify from their API console. You can find the steps for doing that in the Spotify documentation.

The client will make a request to generate the access_token the first time it makes a call to the API. It will then cache the access token as an instance variable, to use in future requests by that client instance. This avoids the overhead of having to make a request for the access token on each request to the API.

You can optionally pass an identifier to the constructor. This will be used in logging messages by the client to uniquely identify logs for the client instance.

Developing

To work on this library, you'll first need to clone the repository:

git clone git@github.com:Moody-Tunes/spotify-client.git

Next, create a virtual environment and install the dependencies for development:

virtualenv -p $(which python3) venv
source venv/bin/activate
(venv) pip install -r dev.txt

pre-commit

We use pre-commit for running hooks during git commits. This will help immensely with developer workflow by running linters, checkers, and other tools when you make commits. To install pre-commit, create a virtual environment and install pre-commit:

(venv) pip install pre-commit

Next, install the pre-commit packages we use in our project:

(venv) pre-commit install

This should run the pre-commit hooks when you make a commit to the spotify-client repository.

Running Tests

We use pytest for running tests. You can run the spotify-client test suite by invoking pytest in the virtual environment:

(venv) pytest

We also use pytest-cov for reporting test coverage of the library. This will be displayed after the tests have finished running and report lines in the code that have test coverage.

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

spotify-client-1.1.0.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

spotify_client-1.1.0-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file spotify-client-1.1.0.tar.gz.

File metadata

  • Download URL: spotify-client-1.1.0.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for spotify-client-1.1.0.tar.gz
Algorithm Hash digest
SHA256 391a3f52879fbb402ebd5ef1da11e81ef7357a14b1001ef82f7a862360865094
MD5 bee14b9b87b052b7240e1b6a3b80991c
BLAKE2b-256 4cd4d80747252cc021d3f4f238b6d827bbe853bea284e4be5add6f08bbcd5a79

See more details on using hashes here.

File details

Details for the file spotify_client-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: spotify_client-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for spotify_client-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 16a8c3c8f1e3c9d39714018a353e62bc114dd530d6b29e5ecf6d37b746226bfc
MD5 120ef1bacfc17ed269559b4bf18db692
BLAKE2b-256 748911b4fb9e148c30d5d4a6f2dc567e6b25a4986c0843ec45485bb969b99cc7

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