Spotify Web API implementation that is fully asynchronous and object-oriented.
Project description
asyncspotify is an asynchronous, object-oriented python wrapper for the Spotify Web API.
Installation
Simply install the library from PyPI:
python -m pip install asyncspotify
Documentation
The documentation can be found at readthedocs.
Usage
To get going quickly, read the quickstart.
For complete examples, please check the documentation. Here’s some snippets:
Authenticating using the Client Credentials flow, and getting a playlist:
from asyncspotify import Client, ClientCredentialsFlow
auth = ClientCredentialsFlow(
client_id='your client id',
client_secret='your client secret',
)
async with Client(auth) as sp:
playlist = await sp.get_playlist('1MG01HhbCvVhH9NmXhd9GC')
async for track in playlist:
print(track.name)
Searching for and getting tracks:
results = await sp.search_tracks(q='involvers', limit=2)
# [<SimpleTrack id='5xoJhWwvzPJD9k8j8BE2xO' name='27'>, <SimpleTrack id='0WUTBejxPUhURFCFfSYbDc' name='Fighting My Fight'>]
track = await sp.get_track('0hqAWKZDhuOfFb6aK002Ph')
# <FullTrack id='0hqAWKZDhuOfFb6aK002Ph' name='Bone Dry'>
Fetching and creating playlists:
# get a playlist
playlist = await sp.get_playlist('1wPvaRtuI8mt10CpP2KnlO')
# <FullPlaylist id='1wPvaRtuI8mt10CpP2KnlO' name='my playlist'>
# iterate through playlist tracks
for track in playlist.tracks:
print(track)
# get current user
me = await sp.get_me()
# <PrivateUser id='runie13'>
# create new playlist
my_playlist = await me.create_playlist(name='My playlist!')
# <FullPlaylist id='0YTCnj0WE5gGb1lRqD6Ks9' name='My playlist!'>
# add tracks from previews playlist to the new playlist
await my_playlist.add_tracks(*playlist.tracks)
Reporting bugs
Please report issues here at GitHub.
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
asyncspotify-0.11.9.tar.gz
(24.9 kB
view hashes)
Built Distribution
Close
Hashes for asyncspotify-0.11.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a1c52a7008cae48dc6fd091aba528b80a14822d421cf91101323e44707490c9 |
|
MD5 | 6af1c29d2b2c213ba838dbda0cfd28ac |
|
BLAKE2b-256 | c43128c3c1c3b2d7499ad14d8d07df8cda16cce7941b77c1802995d62a730aa9 |