Skip to content

Instantly share code, notes, and snippets.

@badalnabizade
Created August 19, 2019 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save badalnabizade/348cd1993b7f6248b2ddaad544e44826 to your computer and use it in GitHub Desktop.
Save badalnabizade/348cd1993b7f6248b2ddaad544e44826 to your computer and use it in GitHub Desktop.
Getting artists data from Spotify API:
def get_artist(name):
"""
----------
name: 'Name of Spotify artist'
----------
Returns: dictionary object.
Given Spotify Artist's information.
"""
results = sp.search(q='artist:' + name, type='artist')
items = results['artists']['items']
if len(items) > 0:
return items[0]
else: # If this artist does't exsists.
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment