An async Python interface to the Spotify API using aiohttp.
Note: This is alpha software. Use at your own risk.
Installation
To install, use pip:
python -m pip install aiohttp_spotify
It's best if you also install and use aiohttp-session.
Usage
To add the OAuth flow to your app:
from aiohttp import web
import aiohttp_spotify
async def handle_auth(request: web.Request, auth: aiohttp_spotify.SpotifyAuth):
# Store the `auth` object for use later
app = web.Application()
app["spotify_app"] = aiohttp_spotify.spotify_app(
client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
redirect_uri=REDIRECT_URI,
handle_auth=handle_auth,
)
app.add_subapp("/spotify", app["spotify_app"])
Then you can make calls to the API as follows:
from aiohttp import ClientSession
async def call_api(request: web.Request) -> web.Response:
async with ClientSession() as session:
response = app["spotify_app"]["spotify_client"].request(
session, auth, "/me"
)
# The auth object will be updated as tokens expire so you should
# update this however you have it stored:
if response.auth_changed:
await handle_auth(request, response.auth)
return web.json_request(response.json())
where auth is the SpotifyAuth object from above.
Take a look at the demo directory for a more complete example.
Metadata
Release files for aiohttp-spotify 0.0.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 | Actions |
|---|---|---|---|---|
| aiohttp_spotify-0.0.4.tar.gz | 11.2 kB | Without provenance | Details for aiohttp_spotify-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aiohttp_spotify-0.0.4-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for aiohttp_spotify-0.0.4-py2.py3-none-any.whl |
Total release size: 19.5 kB
Release files / aiohttp_spotify-0.0.4.tar.gz
| Download URL | aiohttp_spotify-0.0.4.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5195f7e341113318f1a3b298b32144e9cbd54328d9a82b6b6a7090ee31ec35e4
|
|
BLAKE2b-256 checksum How to use checksums |
445050e01c89969f45249b501888de1a736a990f96c9457b146ce21f56eb4a0e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.1.post20200323 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1
|
Release files / aiohttp_spotify-0.0.4-py2.py3-none-any.whl
| Download URL | aiohttp_spotify-0.0.4-py2.py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
d6ad1191b4771bfa5c89a21e8c0c575d0ecf2a7366f2617db66c67536c038200
|
|
BLAKE2b-256 checksum How to use checksums |
a2d8f9c4c8f9524736dbfe873d5fa81abe43b98a83322a78461f0a7ec41f9276
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.1.post20200323 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1
|
Security for aiohttp-spotify 0.0.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.