Basic Channel Details
Learn to fetch details of channels using the Twitch API.
Get channel information
Apart from the user's personal details, their channel itself also has some information associated with it. We can send a GET request to the channels endpoint and retrieve the details of any channel that we specify as a parameter.
The URL for this endpoint is as follows:
https://api.twitch.tv/helix/channels
All calls to this endpoint need to be authorized either with an app or a user access token. We'll use an app access token in this lesson.
Input parameters
We must provide a single query parameter to make a successful request. It doesn’t support any optional parameters. The table below gives an overview of this parameter:
Parameter | Type | Category | Description |
| String | Required | This is the ID of the user whose channel details we want to fetch. We can provide a maximum of 100 IDs. |
Example call
Let's make a request to this endpoint using several different IDs from the table below:
Channel Name | ID |
Twitch | 12826 |
TwitchDev | 141981764 |
twitchgaming | 527115020 |
Let's paste these IDs one by one into the broadcaster_id
parameter on line 7 in the code below:
Note: If your token has expired, return to this lesson and follow the steps to generate a new one.
headers = {'Authorization' : 'Bearer {{APP_ACCESS_TOKEN}}','Client-Id' : '{{CLIENT_ID}}'}parameters = {'broadcaster_id' : '{{USER_ID}}'}response = requests.get('https://api.twitch.tv/helix/channels',headers=headers, params=parameters).json()print(json.dumps(response, indent=4))
Response structure
A successful response to a call to this endpoint is in the form of a JSON object with a single top-level property, data
. This property is an array of objects where each object represents a single channel. The complete details of the channel object are discussed in the table below:
Property | Type | Description |
| String | This is the ID of the channel user. |
| String | This is the channel user's login name. |
| String | This is the channel's display name. |
| String | This is an ISO-639-1 code for the language in which the user broadcasts. |
| String | The ID of the game currently being played on stream. If the channel is offline, this is the game that was played in the last stream. |
| String | This is the name of the game currently being played on stream. If the channel is offline, this is the game that was played in the last stream. |
| String | This is the title of the ongoing stream. If the channel is offline, this is the title of the latest stream. |
| Integer | This is the stream delay time in seconds. |
Get channel editors
Each channel on Twitch may have more than one user with edit rights, apart from the channel owner. We can send a GET request to the Twitch API's channel editors endpoint and retrieve the list of users with edit permissions for a specified channel.
The URL for this endpoint is as follows:
https://api.twitch.tv/helix/channels/editors
All calls to this endpoint need to be authorized with a user access token that has the channel:read:editors
scope.
Input parameters
We must provide a single query parameter to make a successful request. It doesn’t support any optional parameters. The table below gives an overview of this parameter:
Parameter | Type | Category | Description |
| String | Required | This is the ID of the user whose channel we want to fetch the list of editors for. It must be of the same user authenticated with the access token. |
Example call
Let's make a request to this endpoint and authenticate ourselves with a user access token.
Note: If your token has expired, return to this lesson and follow the steps to generate a new one.
headers = {'Authorization' : 'Bearer {{USER_ACCESS_TOKEN}}','Client-Id' : '{{CLIENT_ID}}'}parameters = {'broadcaster_id' : '{{USER_ID}}'}response = requests.get('https://api.twitch.tv/helix/channels/editors',headers=headers, params=parameters).json()print(json.dumps(response, indent=4))
Response structure
A successful response to a call to this endpoint is in the form of a JSON object with a single top-level property, data
. This property is an array of objects where each object represents a single editor. The complete details of these objects are discussed in the table below:
Property | Type | Description |
| String | This is the ID of the editor. |
| String | This is the editor's display name. |
| String | This is the UTC timestamp of when the editor was given edit rights to the user's channel. |