Importing Twitch data into Google Sheets via the Twitch API

In this tutorial, you will learn how to connect Twitch to Google Sheets using the Twitch API.

  1. Install the Apipheny Add-on
  2. Create a Twitch App
  3. Obtain your Twitch Access Token
  4. Choose your API Endpoint URL
  5. Enter Twitch API Endpoint into Apipheny
  6. Run the Twitch API Endpoint 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 Twitch App

To create a Twitch app, go to https://dev.twitch.tv/console/apps/create and complete the Name, the OAuth Redirect URLs and the Category fields.

Click the Add button next to the redirect URL to add it to a list, as many of them can be added:

Create a Twitch app
Create a Twitch app

Lastly, click the Create button:

Register a new Twitch app
Register a new Twitch app

Your app will be created and its details now appear in the Console screen’s Applications tab. In the app’s details row, click the Manage button to display the client id:

Twitch developer console
Twitch developer console

An extended view of the app’s details will open. To reveal the client’s secret, click the New Secret button:

Create Twitch Secret
Create Twitch Secret

Your client id and client secret will be displayed on the screen:

Twitch client ID and client secret
Twitch client ID and client secret

Copy them to a safe location, because you’ll need them in the next steps.

Step 3.) Obtain your Twitch Access Token

In a command prompt window for Windows OS or a terminal for Mac OS, type the following command:

curl -X POST "https://id.twitch.tv/oauth2/token?client_id=your_client_id&client_secret=your_client_secret&grant_type=client_credentials"
Note: For Mac OS you may need to use single quotes ( ' ) instead of double quotes ( " ).

Don’t forget to replace these values:

  • your_client_id is your client id from Step 2
  • your_client_secret is your client secret from Step 2

Your Twitch Bearer Access Token will then be displayed in the response:

Twitch bearer access token

Copy your access token to a safe location, because you’ll need it in the next steps.

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 4.) Choose your Twitch Endpoint URL

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

First, open the Twitch API documentation page: https://dev.twitch.tv/docs/api/reference

The menu on the left of the page contains a list of endpoints for the Twitch API:

Twitch API endpoints
Twitch API endpoints

An example endpoint is the Get clips endpoint, that returns clip information by clip ID (one or more), broadcaster ID (one only), or game ID (one only):

https://api.twitch.tv/helix/clips

The documentation for this endpoint contains a paragraph describing the endpoint’s purpose, a section detailing the authentication and scope requirements, the endpoint’s HTTP method (GET) and URL and a table describing the accepted parameters:

Get clips - Twitch API endpoint
Get clips – Twitch API endpoint

All API calls to Twitch should be made to the Twitch base/root domain:

https://api.twitch.tv/

Step 5.) Enter the Twitch API Endpoint URL Into Apipheny

Now go back to your Google Sheet and make sure that the Apipheny add-on is open on the “Import” tab.

With the Import Tab open, enter these details into the add-on:

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

API URL: In Step 4, we explained how you can find the Twitch API endpoint that you need. Now copy the complete URL into the Apipheny add-on, where it says API URL Path, followed by any GET parameters required for your query.

For this example, we are using the Get All Stream Tags endpoint that gets the list of all stream tags defined by Twitch. The corresponding API URL is:

https://api.twitch.tv/helix/tags/streams

In the Headers section of the Apipheny add-on, add two rows with the following keys and values:

Header 1
Key:
Authorization
Value:
Bearer your_token
Header 2
Key:
Client-ID
Value:
your_client_id
  • your_token value is the token you generated previously, in Step 3. There should be a space between Bearer and your_token.
  • your_client_id is the value that you previously obtained
Twitch API URL and headers entered into the Apipheny add-on
Twitch API URL and headers entered into the Apipheny add-on

Step 6.) Run the Twitch API Endpoint Request

Click the Run button at the bottom of the Apipheny add-on and then wait for the Twitch API data to be added to your Google Sheet:

Twitch API data in Google Sheets
Twitch API data in Google Sheets

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


Crypto API tutorials and more:


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?