An async spotify api client
Project description
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 = SpotifyApiClient(auth_flow, hold_authentication=True)
# Get the auth token with your code
code: str = "Your Spotify Code"
auth_token: SpotifyAuthorisationToken = await api.get_auth_token_with_code(code)
# Create a new client
await api.create_new_client(request_limit=1500)
# Start making queries with the internally saved token
album_tracks: dict = await api.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.albums.get_tracks('03dlqdFWY9gwJxGl3AREVy', auth_token)
Tests
See here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
async-spotify-0.4.1.tar.gz
(27.6 kB
view details)
File details
Details for the file async-spotify-0.4.1.tar.gz
.
File metadata
- Download URL: async-spotify-0.4.1.tar.gz
- Upload date:
- Size: 27.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fccc0de213a148acfa12322a3ad7a06a36836a85c832eed06d1b4a5655b1ea4 |
|
MD5 | 71246df885e3246dd9520964ea2b1519 |
|
BLAKE2b-256 | c8ab578cb13769614785f35d3fb3235d33e7929cadc0772866931d7d9c3e0eab |