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?
hey,
is it possible to search the ID from pre-existing cells that have info on the song?
e.g. If A1 says the song title, and A2 says the artist, can I somehow search that in spotify's database, take the top result's ID, use it in a request, and have that request the audio features?
thanks!
Sure, you can run your request, then run a second request that takes the cell value(s) of the ID and plugs them into the next request: https://mixedanalytics.com/knowledge-base/use-cell-values-in-requests/
I'm trying to list all the tracks in an album while using the IMPORTAPI function to reference different album IDs. I see the response about this function above, but I am having trouble getting it to work. When I create the request with endpoint /albums/{id}/tracks and leave the id field blank the IMPORTAPI function returns "completed with errors". I can get the request to work if I enter an album id in the id field, but then the IMPORTAPI function only returns tracks for that album regardless of the album id in the cell it is referencing.
Hey Daniel, what exactly did you write in your IMPORTAPI function? Or if you'd like me to take a look at your sheet, please feel free to contact support.
Great tool! Is it possible to schedule the run, or refresh data from a playlist? It would be great to have real-time info if a playlist changes (e.g. a song is added or removed)
Thanks, Maarten! API Connector has the ability to schedule runs: https://mixedanalytics.com/knowledge-base/api-connector-scheduling/. However, it sounds like you might want something more like "run the API request when the playlist changes" and API Connector currently can not do that (possibly in the future).