In this tutorial, you will learn how to connect Twitch to Google Sheets using the Twitch API.
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.
Tip: you can open a new Google Sheet by entering this URL in your browser: sheet.new
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 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 Twitch Bearer Access Token will then be displayed in the response:
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.
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, 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
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.
Crypto API Tutorials: