Need to get the Channels for a team

I am trying to found out the all channels which are related to a team. I am using this to get the list of channels.
https://api.twitch.tv/api/team/team-name/all_channels.json
But this is returning nothing to me.
or listing of members of a team.

http://api.twitch.tv/api/team/[teamname]/all_channels.json
This is not on kraken so may change at any point

I managed to get all channels in the ESL team for example.

https://github.com/justintv/Twitch-API/blob/master/v3_resources/teams.md

The above links show you how to get all teams, combine the two to get all channels related to a team.

I can make the query for the team to get the teams object or list. You have said combine two. What is the other one with which I can combine to get list of channels.

The link you provided.There is no equivalent API endpoint on kraken at the moment.

Can you give me something some example at your end that can help me to proceed? With channels related to team.

API isn’t really my ballpark, but I’ll give you the gist of my suggestion.

for every n teams from teams endpoint (up to m)

get each teams names
for every name

get all channels from team endpoint

The first line are consecutive calls to https://api.twitch.tv/kraken/teams with a moving offset. Say the first call is https://api.twitch.tv/kraken/teams?limit=150&offset=0, then the following should have offset 150, then 300 and so on. Do this until you either return less than your limit (end of the list), or until an arbitrary number. Note that it is important to do this at a reasonable rate, so a larger limit is preferred over smaller limits often.

The second line parses the returned JSON, preferably in a separate function asynchronously. Below is an abbreviated response. For every item in the array “teams”, parse and save their “name”.

{
  "teams": [
    {
      "_id": 2,
      "name": "eg",
      "info": "Team Info\n\n",
      "display_name": "Evil Geniuses",
      ...
    },
    {
      "_id": 7,
      "name": "carbon",
      "info": "Team Carbon - Gears of War 3",
      "display_name": "Carbon",
      ...
    },
    ...

Say you store each name in a map, with the name as a key and an array of associated channels as value. So for each team name, hit for example http://api.twitch.tv/api/team/carbon/all_channels.json like I did below (abbreviated), parse and get the channel names. Store the channel names as values in your map.

{
  "channels": [
    {
      "channel": {
        "name": "uleet",
        "description": "Join ULeeT as he travels the great world of games to find out if he really is the last white Mexican.",
        ...
      }
    },
    {
      "channel": {
        "name": "uorghostayame",
        "description": "GH057ayame",
        ...
    },
    ...
1 Like

Another similar approach, using two calls to kraken, would be to get streams from https://api.twitch.tv/kraken/streams. From these streams make calls to https://api.twitch.tv/kraken/channels/:channel/teams.

Example:

{
  "streams": [
    {
      ...
      "channel": {
        "name": "reynad27",
        ...
      }
    }
  ],
  ...
}

using https://api.twitch.tv/kraken/channels/reynad27/teams as the second call:

{
  "teams": [
    {
      "_id": 2418,
      "name": "cdsgaming", 
      "info": null,
      "display_name": "CDS Gaming",
      ...
    },
    {
      "_id": 1139,
      "name": "tempostorm",
      "info": null,
      "display_name": "Tempo Storm",
      ...
    }
  ]
}

I will go with first approach. Thanks for your suggestion.

You should have read these documents before you deploy.

https://github.com/justintv/Twitch-API/blob/master/authentication.md

The maximum limit seems to be 100, and the current number of teams are 2058. With the suggested rate limit of one call per endpoint per minute, your entire database should refresh in about 20 minute cycles. You shouldn’t be concerned about the time, since I figure this is a list that changes relatively slowly. Also, depending on your intended application, it shouldn’t need to always be up to date. You could either run this once per every [24h] or spread it out over [24h].

1 Like

The teams API still works, but if a team does not exist you get a redirect instead of an error.

See http://api.twitch.tv/api/team/team_kappa/all_channels.json for an example.

1 Like

You’ll need to make two HTTP requests: the first is to https://api.twitch.tv/kraken/teams/[team_name] to make sure the specified time exists; From there you can make the 2nd call against http://api.twitch.tv/api/teams/[team_name]/all_channels.json to get a list; if you do not verify the team exists, the 2nd call will result in a redirect

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.