使用aiohttp的spotifyapi的异步Python接口
aiohttp-spotif的Python项目详细描述
使用aiohttp指向SpotifyAPI的异步Python接口。在
注意:这是alpha软件。使用风险自负。
安装
要安装,请使用pip:
python -m pip install aiohttp_spotify
最好同时安装并使用aiohttp-session。在
使用
要将OAuth流添加到应用程序中,请执行以下操作:
^{pr2}$然后可以按如下方式调用API:
fromaiohttpimportClientSessionasyncdefcall_api(request:web.Request)->web.Response:asyncwithClientSession()assession: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:ifresponse.auth_changed:awaithandle_auth(request,response.auth)returnweb.json_request(response.json())
其中auth
是上面的SpotifyAuth
对象。在
查看the demo directory以获得更完整的示例。在
- 项目
标签: