我可以从 spotify API 保存哪些数据?

What data can I save from the spotify API?

我正在建立一个网站,我正在使用 Spotify API 作为音乐库。我想添加比 api 允许的更多过滤器和顺序选项来搜索 traks,所以我想知道我可以从 API 将哪些 track/song 数据保存到我的数据库中,就像艺术家一样名称或知名度。

我想保存:姓名、艺术家、专辑和其他一些东西。这可能还是违反条款和条件?

提前致谢!

是的,这是可能的。

数据存储在 Spotify API 端点中。

Spotify API endpoint reference here.

每个端点处理客户端(您)请求的特定类型的数据。

我举个例子。相同的逻辑适用于所有其他端点。

import requests

   """
   Import library in order to make api calls.
   Alternatively, ou can also use a wrapper like "Spotipy" 
   instead of requesting directely.
   """

# hit desired endpoint
SEARCH_ENDPOINT = 'https://api.spotify.com/v1/search'

# define your call
def search_by_track_and_artist(artist, track):

    path = 'token.json' # you need to get a token for this call
                        # endpoint reference page will provide you with one
                        # you can store it in a file

    with open(path) as t:
        token = json.load(t)

    # call API with authentication
    myparams = {'type': 'track'}
    myparams['q'] = "artist:{} track:{}".format(artist,track)
    resp = requests.get(SEARCH_ENDPOINT, params=myparams, headers={"Authorization": "Bearer {}".format(token)})
    return resp.json()

试一试:

search_by_track_and_artist('Radiohead', 'Karma Police')

存储数据并根据需要进行处理。但您必须遵守 Spotify 条款才能使其 public.

旁注:Spotipy docs.