Spotify is one of the most popular music streaming platforms in the world.

In this tutorial, I’ll show you how to connect the Spotify REST API to Google Sheets in 8 steps:

  1. Install the Apipheny Add-on
  2. Create a Spotify API App
  3. Add a Redirect URI
  4. Obtain an Authorization Code
  5. Obtain a Spotify API Token
  6. Choose a Spotify API URL Endpoint
  7. Enter Your Spotify API request into Apipheny
  8. Run the Spotify API request

Step 1.) Install and open the Apipheny Add-on in Google Sheets

To pull data from the Spotify API to Google Sheets easily and without writing any code, first install and open the Apipheny Google Sheets add-on.

Apipheny is a no-code API integrator for Google Sheets that you can use to make unlimited API requests, connect to unlimited APIs (including the Spotify API), save API requests, schedule API requests, and more. Click here if you want to learn more about Apipheny.

1. Install Apipheny by clicking the Install button on this page.

Install Apipheny to connect the Spotify API
Install Apipheny to connect the Spotify API

2. After you’ve installed Apipheny, open a Google Sheet and then click on the Add-Ons option in the top menu. In the add-ons menu, you should see Apipheny.

Click Apipheny > Import API to open the Apipheny sidebar in your Google Sheets.

Open the Apipheny add-on directly in your Google Sheet, after installing it
Open the Apipheny add-on directly in your Google Sheet, after installing it

Step 2.) Create a Spotify API app

Next, make sure you’re logged in to your Spotify developer account.

Then, in your Spotify developer account’s Dashboard, click the Create an App button:

Spotify developer account
Spotify developer account

Complete the App name and description fields, check the two checkboxes, and then click the Create button:

Fill out the fields, click the checkboxes, and then click "Create"
Fill out the fields, click the checkboxes, and then click “Create”

Your app will then be created. Under the app name, you should see the “client id”. Under it, click the Show Client Secret link to display the client secret:

Click "Show Client Secret"
Click “Show Client Secret”

Copy and paste the values of both your Client ID and Client Secret to a safe location, because you will need them in the next steps.

Step 3.) Add a Redirect URI

After you’ve created the app, click the Edit Settings button in your Developer account:

Click "Edit Settings"
Click “Edit Settings”

In the Edit Settings section, complete the Redirect URIs field then click the Add button:

Add a Redirect URI and click "Add"
Add a Redirect URI and click “Add”

The redirect URI is now added:

Redirect URI added in Spotify Developer Account
Redirect URI added in Spotify Developer Account

Click the Save button to complete this step:

Don't forget to Save!
Don’t forget to Save!

Step 4.) Obtain an Authorization Code

In your internet browser’s address/URL bar, copy and paste the following link:

https://accounts.spotify.com/authorize?client_id=<your_client_id>&response_type=code&redirect_uri=https://apipheny.io/&scope=user-read-private%20user-read-email&state=34fFs29kd09

Make sure to replace the <your_client_id> parameter with your client id from Step 2. Do not include the carrots “<>”.

After copying and pasting the URL into your browser, and clicking Enter, you will be prompted to log in to your Spotify platform account.

After logging in, the browser will then redirect and display a dedicated authorization page:

Authorize your Spotify account to access the Spotify app you created
Authorize your Spotify account to access the Spotify app you created

After you authorize the app, you’ll then see your “Code” in the URL/address bar.

Copy and paste the code value somewhere safe, because you’ll need it in the next steps.

Step 5.) Obtain a Spotify API Access Token

To get your API access token, open a console window and enter in the following command:

curl -d grant_type=authorization_code -d code=<code> -d redirect_uri=<redirect_URI> -d client_id=<client_id> -d client_secret=<client_secret> https://accounts.spotify.com/api/token

Don’t forget to replace the values between brackets (code, redirect_URI, client_id and client_secret) with their actual values. These are the same values you’ve obtained in previous steps. Do not include the carrots “<>” around any of the values.

After running the command, your access token will then be displayed in the response:

Obtaining the Spotify access token
Obtaining the Spotify access token

Step 6.) Choose a Spotify API URL Endpoint

In this section, we’ll show you how to browse the Spotify API documentation to find an API endpoint URL that retrieves the information you need. If you already know your URL, or you want to use the same example URL as us, just skip to Step 7.

First, open the Spotify API documentation page: https://developer.spotify.com/documentation/web-api/reference/

The menu on the left contains a list of categories for the Spotify API endpoints:

Spotify API documentation
Spotify API documentation

If you click on an API category, for example Artists, a list of that category’s endpoints will be displayed:

Spotify API endpoint documentation example
Spotify API endpoint documentation example

An example endpoint is the Get Several Artists endpoint from the Artists category, which returns Spotify catalog information for several artists, based on their Spotify IDs. The URL for this endpoint is:

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

Each endpoint’s documentation contains a descriptive title, a paragraph describing the endpoint’s purpose, a table with the required headers and parameters, followed by a response format section. In a distinct section on the right, you will see the endpoint’s HTTP method (GET) and URL:

Spotify API endpoint documentation example
Spotify API endpoint documentation example

Step 7.) Enter your Spotify API request into Apipheny

Now, to get your Spotify data in your Google Sheet, go back to your Google Sheet and make sure that you’ve installed the Apipheny add-on and you have it opened to the “Import” tab. In the Import Tab of Apipheny, enter the following details into the add-on:

Method: At the top of the Apipheny sidebar, select the HTTP method (GET or POST) required by your Spotify API endpoint. For this example, we are using the “GET” method.

API URL: In Step 6, we explained how you can find the Spotify API endpoint that you need. Now copy your complete Spotify API URL into the Apipheny add-on, in the field that says API URL Path (JSON / CSV), followed by any GET parameters required for your query (if applicable).

For this example, we are using the Get a List of New Releases endpoint that returns a list of new releases. The URL for this specific endpoint is:

https://api.spotify.com/v1/browse/new-releases

If you’re following the same example as us, just copy and paste the above URL into Apipheny where it says “API URL”.

Headers: In the Headers section of the Apipheny add-on, add one row with the following key and value:

Header
Key:
Authorization
Value:
Bearer <your_token>

Just copy and paste “Authorization” into Apipheny, where it says “Key”. And copy and paste Bearer <your_token> into Apipheny, where is says “Value”. But make sure to replace <your_token> with the same value of the token that you generated previously, in Step 5. Do not include the carrots “<>” around your token, but do leave a space between “Bearer” and your token in the “Value” field.

Here’s what your Spotify API should look like when entered into Apipheny, if you’re following the same example as us:

Spotify API request entered into Apipheny in Google Sheets
Spotify API request entered into Apipheny in Google Sheets

Step 8.) Run the Spotify API Request in Your Google Sheet

The last step is to click the Run button at the bottom of the Apipheny add-on and then your Spotify data will be imported into your Google Sheets. Congratulations!

Click "Run" to import your Spotify data into your Google Sheet
Click “Run” to import your Spotify data into your Google Sheet

After making a successful request to the Spotify API, try querying a different Spotify API endpoint, or try using one of the more advanced features in the Apipheny add-on, such as:

  • Save and schedule your Spotify API request
  • Make a POST request to the Spotify APi (if available)
  • Use the custom =APIPHENY() function to call the Spotify API request inside your spreadsheet
  • Create a Spotify API request by referencing the value of a cell in the API URL with three curly braces eg. {{{Sheet1!A1}}}

Related articles:

Related Posts