Search API Connector Documentation
Import Spotify Data to Google Sheets
In this guide, we’ll walk through how to pull Spotify music data directly into Google Sheets, using the API Connector add-on for Sheets.
Contents
- Before You Begin
- Part 1: Connect to the Spotify API
- Part 2: Pull Data from Spotify to Sheets
- Part 3: Create a Custom API Request
- Part 4: API Documentation
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Connect to the Spotify API
The easiest way to get started with the Spotify API is through API Connector’s built-in integration.
- Open Google Sheets and click Extensions > API Connector > Open > Create request.
- Select Spotify from the drop-down list of applications
- Under Authorization, click Connect to Spotify
- You will be directed to spotify.com and asked to authorize the connection. Click Agree.
- You'll then be returned to your Google Sheet, and can verify that your Spotify connection is active.
Part 2: Pull Data from Spotify to Sheets
Now that we’re connected, let’s pull some data into Sheets.
- Under Endpoint, choose
/search
to search Spotify's catalog of music. - Fill out the required
q
andtype
parameters to indicate your search query and the type of resource to search. - Select a destination sheet, name your request, and click Run.
Part 3: Create a Custom API Request
Alternatively, you can create a custom request instead of using API Connector’s built-in integration, using any of the endpoints and parameters shown in the API documentation. For example:
- Application:
Custom
- Method:
GET
- Request URL:
https://api.spotify.com/v1/me
- OAuth:
Spotify
Part 4: API Documentation
To see more API endpoints and example responses, check out the Spotify Web API reference located at https://developer.spotify.com/documentation/web-api/reference
To view/disconnect API Connector on Spotify's side, navigate to https://www.spotify.com/us/account/apps/.
Can I get the entire music library this way? I want to compare which songs I have offline the same as ones present in Spotify and delete only them and probably add the rest as a separate playlist.
You should be able to get all the music in your own library this way, I don't think you could get all the music in Spotify's library though (Sheets would run out of space before you got there!).
Oh. ok. Thanks for the reply. Do you know whether there is an online Spotify catalogue which is viewable?
I only see this: https://explore.spotify.com/us/pages/mobile-feature-discover-catalog
I think you can import your music library by selecting the "Get User's Saved Tracks" endpoint from the "Library" menu in the Console tab.
This is the the endpoint: https://api.spotify.com/v1/me/tracks.
This should work I believe.
Thanks Matt!
awesome
Will i be able to import data regarding streams to my sheet, to get frequently updated data on my own portfolio (music producer)?
As far as I know, Spotify's API doesn't provide stream count numbers. There are quite a few comments/complaints about it on their forum, e.g. here. Based on that thread, it seems some third party tools have found a way to offer this, maybe by scraping Spotify's interface (where it seems like this data is provided). So maybe you can try using an unofficial API for Spotify instead, RapidAPI has quite a few: https://rapidapi.com/search/spotify
When trying to pull an artist's top tracks, I am getting an error saying "missing country parameter". However I don't see a place to enter the country id?
Thanks for letting me know! I just added a country selector to that endpoint so you should be able to select it now.
I'm trying to have the sheet list every album from a specific artist, as well as the year released and the genre. Is there a way I can have it list ONLY this information without any of the other stuff?
Sure, click Edit fields to open the field editor and filter out any fields you don't want to see in your report.
Thank you! Do you know if there'd be any way to make it so that you can type an album ID into a sheets cell, and then have it automatically list the album name, artist, release date, and genre? I'm trying to make a list of albums that I want to/have listened to, and this would make the process super fast for sorting everything I already have as well as adding new albums.
You could use the IMPORTAPI custom function for this. For example, first save your request (let's call it Albums) with all your edited fields and othe configurations. Then, enter your album ID in A1, and the following function in B1:
=importapi("Albums","https://api.spotify.com/v1/albums?ids="&A1
). This will automatically run the Albums request for whatever ID you enter in cell A1, and you can copy the function down the sheet to run it for any ID you enter.Hey -
Running into an issue. if a song has multiple artists, each artists gets their own row (using 'grid'). With this, each row does not represent a song, and the data is not lined up.
Any thoughts on how to fix this?
Cheers.
Generally the 'single row' report style should help resolve this type of issue. The main drawback is that it produces extra columns (one for each market), but you can filter those out via the field editor. If that doesn't help, can you please share your endpoint so I can check it on this side?