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

To pull data from the Twitch 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 Twitch 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.

Apipheny Google Sheets add-on
Apipheny Google Sheets add-on

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 Apipheny
Open Apipheny

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 your console window, 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"

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.

Do not include the carrots “<>”.

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

Twitch bearer access token

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

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 (JSON / CSV), 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:

Key:
Authorization
Value:
Bearer <your_token>
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>.

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.

Related articles:

Related Posts

Leave a Comment