In this tutorial, you will learn how to connect Twitch to Google Sheets using the Twitch API.
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.
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.
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:
Lastly, click the Create button:
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:
An extended view of the app’s details will open. To reveal the client’s secret, click the New Secret button:
Your client id and client secret will be displayed on the screen:
Copy them to a safe location, because you’ll need them in the next steps.
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:
Copy it to a safe location, because you’ll need it in the next steps.
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:
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:
All API calls to Twitch should be made to the Twitch base/root domain:
https://api.twitch.tv/
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>.
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:
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:
Meelad Mashaw