go back  53 - Query the Spotify API

This challenge write-up first appeared on PyBites.

It's not that I'm so smart, it's just that I stay with problems longer. - A. Einstein

Hey Pythonistas,

We bet this one's going to be music to your ears (another quality pun!).

This week, query the Spotify API and write some code that performs the set of tasks we've listed below.

If you have another music service you'd rather use, feel free!

The Challenge

Now for the challenge tasks:

  • Query Spotify and grab a list of album names for any given artist. Bonus points if the script allows the user to specify the artist!

  • Create a playlist on your account if you don't already have one. Write a script that queries Spotify for the playlist and returns all tracks/songs in the playlist.

  • This one's tricky: write a script that obtains a list of the top tracks for an artist and see if any of those songs exist in your playlist.

  • Feel free to dig into the API and go wild!

If you don't have an existing playlist, just create one with random artists and use it as your data set.

Hint: Check out the Spotipy Python Library to make this a little easier on yourself.

If you need help getting ready with Github, see our new instruction video.

PyBites Community

A few more things before we take off:

  • Do you want to discuss this challenge and share your Pythonic journey with other passionate Pythonistas? Confirm your email on our platform then request access to our Slack via settings.

  • PyBites is here to challenge you because becoming a better Pythonista requires practice, a lot of it. For any feedback, issues or ideas use GH Issues, tweet us or ping us on our Slack.

>>> from pybites import Bob, Julian

Keep Calm and Code in Python!
We use Python 3.8