Import Spotify Data to Google Sheets

In this guide, we’ll walk through how to pull Spotify data data directly into Google Sheets, using the API Connector add-on for Sheets. Spotify is arguably the best streaming music website and app so we’ll have some fun getting data out of it. The Spotify API only supports authentication via OAuth2, so we’ll be connecting using API Connector’s built-in OAuth2 integration for Spotify.

PART 1: CONNECT TO THE SPOTIFY API

If you haven’t connected API Connector to Spotify before, you’ll first need to initiate the connection as follows:

  1. Open up Google Sheets and click Add-ons > API Connector > Manage Connections.
  2. In the list of available connections, find Spotify and click Connect.
    spotify-img1
  3. You will be directed to spotify.com and asked to sign in, if you haven’t already. You’ll also be asked to authorize the connection.
    spotify-img2
  4. You’ll then be returned to your Google Sheet, and can verify that your Spotify connection is active in the Connections screen.
    spotify-img3

PART 2: CREATE YOUR SPOTIFY API REQUEST URL

For our first request, we’ll get some basic information about your Spotify account.

  • API root: https://api.spotify.com
  • Endpoint: /v1/me


Putting it all together, we get the full API Request URL.

https://api.spotify.com/v1/me

PART 3: PULL SPOTIFY API DATA INTO SHEETS

We can now enter our values into API Connector and start importing Spotify data into Google Sheets.

  1. In API Connector, click Create, and paste in the Request URL we created above.
    spotify-img4
  2. We don’t need any headers so just leave that section as is.
  3. Under Authentication, choose Spotify from the dropdown menu.
    spotify-img5
  4. Create a new tab and click ‘Set current’ to use that tab as your data destination.
  5. Name your request and click Run. A moment later you’ll see some information about yourself populate your sheet.
    spotify-img6

PART 4: MORE EXAMPLE API URLS

Now that we’ve got the basic handshake down, let’s get some more interesting data. Try the following URLs (one at a time).

  • Get your own most played tracks
    https://api.spotify.com/v1/me/top/tracks?time_range=long_term
    spotify-img7
  • Get your own most played artists
    https://api.spotify.com/v1/me/top/artists?time_range=long_term
  • Get your recently played tracks
    https://api.spotify.com/v1/me/player/recently-played
    spotify-img8
  • Search for artists matching a keyword
    https://api.spotify.com/v1/search?q=radio&type=artist
  • Search for tracks matching a keyword
    https://api.spotify.com/v1/search?q=radio&type=track
  • Get audio features of a list of track IDs
    https://api.spotify.com/v1/audio-features?ids=7ouMYWpwJ422jRcDASZB7P,4VqPOruhp5EdPBeR92t6lQ,37R0bQOQj5a7DOqh1TGzvB
    spotify-img9

To see more API endpoints and example responses, I suggest checking out out the Spotify Web API reference located at https://developer.spotify.com/documentation/web-api/reference-beta/.

Leave a Comment