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 for Google Sheets

Apipheny is an API connector for Google Sheets. You can use Apipheny to connect your Google Sheets to unlimited API data sources, make unlimited API requests, and more. There is a 30 day free trial included.

1.) Install Apipheny by opening the following link on desktop and then clicking the Install button in the Google Marketplace: https://apipheny.io/install

2.) After you’ve installed Apipheny, open a Google Sheet and then click on the Extensions dropdown in the menu at the top.

In the dropdown list you should see Apipheny. Click Apipheny then click Import API to open the Apipheny sidebar in your Google Sheet.

open apipheny

Tip: you can open a new Google Sheet by entering this URL in your browser: sheet.new

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.

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.
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 command prompt window for Windows OS or a terminal for Mac OS and enter in the following command:

curl -d grant_type=authorization_code -d code=your_code -d redirect_uri=your_redirect_URI -d client_id=your_client_id -d client_secret=your_client_secret https://accounts.spotify.com/api/token
Note: For Mac OS you may need to use single quotes ( ' ) instead of double quotes ( " ).

Don’t forget to replace the values for your_code, your_redirect_URI, your_client_id and your_client_secret with their actual values. These are the same values you’ve obtained in previous steps.

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

Obtaining the Spotify access token
Obtaining the Spotify access token
Note: If the token/key that you generate has an expiration time, you will need to complete this same process again to get a new token when the old one expires.

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, 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.

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

Make sure to replace your_token with the same value of the token that you generated previously, in Step 5. Leave a space between Bearer and your_token.

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.


API Tutorials



API Knowledge

What is an API?
What is an API URL?
What are parameters?
What is an endpoint?
What is an API key/token?
What is basic authentication?
What are headers?
What is a GET request?
What is a POST request?