Skip to main content

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.

Optionally, you can also configure the client authentication configuration one time in a setup script by using the Config class:

from spotify_client import SpotifyClient
from spotify_client.config import Config

SPOTIFY_CLIENT_ID = 'client_id_from_spotify'
SPOTIFY_SECRET_KEY = 'secret_key_from_spotify'

Config.configure(SPOTIFY_CLIENT_ID, SPOTIFY_SECRET_KEY)

client = SpotifyClient()

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.

Metadata

Release files for spotify-client 1.9.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spotify-client 1.9.1
File Size Uploaded
spotify-client-1.9.1.tar.gz 18.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spotify-client 1.9.1
File Interpreter ABI Platform
spotify_client-1.9.1-py3-none-any.whl Python 3 none any Details

Total release size: 36.8 kB

Release files / spotify-client-1.9.1.tar.gz

Download URL spotify-client-1.9.1.tar.gz
Size 18.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ec1218762f63190fa60b0c040aad33322ee4c9a42a316bbe88452e58192954f6
BLAKE2b-256 checksum
How to use checksums
70a29c51ed3e4d0929495cca6236adcea3348f25d8c26eaf8bc14b87cfbb1067
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.9

Release files / spotify_client-1.9.1-py3-none-any.whl

Download URL spotify_client-1.9.1-py3-none-any.whl
Size 18.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3479876464bf432e81f1ddf5295e21143e4ab3429a86010cc4a2e3196f832318
BLAKE2b-256 checksum
How to use checksums
33047e7fef74046221ecb82deec984cece6ec32d0e188133ea8f16d943f5be21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.9

Release history Release notifications | RSS feed

This release

1.9.1 This release

2 release files

1.9.0

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.0

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page