AsyncSpotify
Documentation
The full documentation can be viewed here.
Why should you use this library
- 100% Code coverage
- Completely type annotated
- Completely async
- Scales up to (theoretically) unlimited requests per second (tested with 1000 simultaneous requests which lead to a 429)
- Customize the timeout, maximal simultaneous request
- Throws custom errors, so you can catch different errors easily + Token expiration + Rate limit violation + An invalid album id
- Gets rid of the client credential workflow if you provide spotify cookies
- Good for automated testing
- Offers a hook which gets called if the token expires, so you can automatically update the token
Installation
You need at least python3.6 to install the package
pip install async-spotify
Example
For more in depth examples take a look here or visit the documentation.
from async_spotify import SpotifyApiClient
from async_spotify.authentification import SpotifyAuthorisationToken
from async_spotify.authentification.authorization_flows import AuthorizationCodeFlow
# Create a auth_code_flow object and load the auth_code_flow from env variables
auth_flow = AuthorizationCodeFlow()
auth_flow.load_from_env()
# Create a new Api client and pass the auth_code_flow
api_client = SpotifyApiClient(auth_flow, hold_authentication=True)
# Get the auth token with your code
code: str = "Your Spotify Code"
auth_token: SpotifyAuthorisationToken = await api_client.get_auth_token_with_code(code)
# Create a new client
await api_client.create_new_client(request_limit=1500)
# Start making queries with the internally saved token
album_tracks: dict = await api_client.albums.get_tracks('03dlqdFWY9gwJxGl3AREVy')
# If you pass a valid auth_token this auth_token will be used for making the requests
album_tracks: dict = await api_client.albums.get_tracks('03dlqdFWY9gwJxGl3AREVy', auth_token)
# Every argument mentioned by the Spotify API can be passed as kwarg. The client will figure out if your provided kwarg
# should be added to the request body, or the url
await api_client.player.play(context_uri="spotify:album:5ht7ItJgpBH7W6vJ5BqpPr", device_id="whatever_id")
# ^ ^
# URL BODY
Tests
See here.
Metadata
Release files for async-spotify 0.4.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| async-spotify-0.4.4.tar.gz | 28.5 kB | Without provenance | Details |
Release files / async-spotify-0.4.4.tar.gz
| Download URL | async-spotify-0.4.4.tar.gz |
|---|---|
| Size | 28.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6ed9848a4e2d70c87ac07c0e386b52d84f1b845dfe932bc1b4451f239ec18731
|
|
BLAKE2b-256 checksum How to use checksums |
2d8b27a0b564b59f7ecccf5bb768fd4b49c3e96b4bfe33c59db6cdbfadeb8138
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
|
Security for async-spotify 0.4.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.