在提出推荐请求时,例如:
recommend = sp.recommendations(target_energy = 0.5)
我收到错误:
Traceback (most recent call last):
File "script.py", line 62, in
recommend = sp.recommendations(target_energy = 0.5)
File "/usr/local/lib/python2.7/dist-packages/spotipy/client.py", line 804, in recommendations
return self._get('recommendations', **params)
File "/usr/local/lib/python2.7/dist-packages/spotipy/client.py", line 146, in _get
return self._internal_call('GET', url, payload, kwargs)
File "/usr/local/lib/python2.7/dist-packages/spotipy/client.py", line 124, in _internal_call
headers=r.headers)
spotipy.client.SpotifyException: http status: 400, code:-1 - https://api.spotify.com/v1/recommendations?target_energy=0.5&limit=20:
invalid request
为何提出无效请求的任何特殊原因?我试过咨询文档,但我找不到表达式
答案 0 :(得分:0)
您没有为recommendations
电话提供正确的参数。
您需要提供seed_artists
,seed_genres
或seed_tracks
参数,否则API很难找到推荐。
official docs是一个很好的资源。
以下是使用cURL
的示例调用curl -X GET "https://api.spotify.com/v1/recommendations?seed_artists=4NHQUGzhtTLFvgF5SZesLK&seed_tracks=0c6xIDDpzE81m2q797ordA&min_energy=0.4&min_popularity=50&market=US" -H "Authorization: Bearer {your access token}"