# Need to get the Channels for a team

**URL:** <https://discuss.dev.twitch.com/t/need-to-get-the-channels-for-a-team/4072>\
**Category:** Chat and IRC\
**Created:** [December 3, 2015, 5:53pm UTC](https://discuss.dev.twitch.com/t/need-to-get-the-channels-for-a-team/4072 "2015-12-03T17:53:54Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![pradeep\_kumar](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@pradeep\_kumar](https://discuss.dev.twitch.com/u/pradeep_kumar)\
**Post date:** [December 3, 2015, 5:53pm UTC](https://discuss.dev.twitch.com/t/need-to-get-the-channels-for-a-team/4072/1 "2015-12-03T17:53:54Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![pradeep\_kumar](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@pradeep\_kumar](https://discuss.dev.twitch.com/u/pradeep_kumar)\
**Post date:** [December 3, 2015, 6:25pm UTC](https://discuss.dev.twitch.com/t/need-to-get-the-channels-for-a-team/4072/2 "2015-12-03T18:25:13Z")

</div>

[http://api.twitch.tv/api/team/[teamname]/all\_channels.json](http://api.twitch.tv/api/team/%5Bteamname%5D/all_channels.json)  
This is not on kraken so may change at any point

---

<div class="post-metadata">

**Author:** ![livewhiletrue](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/livewhiletrue/32/348_2.png) [@livewhiletrue](https://discuss.dev.twitch.com/u/livewhiletrue)\
**Post date:** [December 3, 2015, 6:34pm UTC](https://discuss.dev.twitch.com/t/need-to-get-the-channels-for-a-team/4072/3 "2015-12-03T18:34:16Z")

</div>

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

[https://github.com/justintv/Twitch-API/blob/master/v3\_resources/teams.md](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.

---

<div class="post-metadata">

**Author:** ![pradeep\_kumar](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@pradeep\_kumar](https://discuss.dev.twitch.com/u/pradeep_kumar)\
**Post date:** [December 4, 2015, 2:49am UTC](https://discuss.dev.twitch.com/t/need-to-get-the-channels-for-a-team/4072/4 "2015-12-04T02:49:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![livewhiletrue](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/livewhiletrue/32/348_2.png) [@livewhiletrue](https://discuss.dev.twitch.com/u/livewhiletrue)\
**Post date:** [December 4, 2015, 7:26am UTC](https://discuss.dev.twitch.com/t/need-to-get-the-channels-for-a-team/4072/5 "2015-12-04T07:26:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pradeep\_kumar](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@pradeep\_kumar](https://discuss.dev.twitch.com/u/pradeep_kumar)\
**Post date:** [December 4, 2015, 7:41am UTC](https://discuss.dev.twitch.com/t/need-to-get-the-channels-for-a-team/4072/6 "2015-12-04T07:41:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![livewhiletrue](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/livewhiletrue/32/348_2.png) [@livewhiletrue](https://discuss.dev.twitch.com/u/livewhiletrue)\
**Post date:** [December 4, 2015, 9:08am UTC](https://discuss.dev.twitch.com/t/need-to-get-the-channels-for-a-team/4072/7 "2015-12-04T09:08:02Z")

</div>

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](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](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](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",
        ...
    },
    ...

```

---

<div class="post-metadata">

**Author:** ![livewhiletrue](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/livewhiletrue/32/348_2.png) [@livewhiletrue](https://discuss.dev.twitch.com/u/livewhiletrue)\
**Post date:** [December 4, 2015, 9:42am UTC](https://discuss.dev.twitch.com/t/need-to-get-the-channels-for-a-team/4072/8 "2015-12-04T09:42:06Z")

</div>

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

Example:

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

```

using [https://api.twitch.tv/kraken/channels/reynad27/teams](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",
      ...
    }
  ]
}
```

---

<div class="post-metadata">

**Author:** ![pradeep\_kumar](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@pradeep\_kumar](https://discuss.dev.twitch.com/u/pradeep_kumar)\
**Post date:** [December 4, 2015, 10:28am UTC](https://discuss.dev.twitch.com/t/need-to-get-the-channels-for-a-team/4072/9 "2015-12-04T10:28:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![livewhiletrue](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/livewhiletrue/32/348_2.png) [@livewhiletrue](https://discuss.dev.twitch.com/u/livewhiletrue)\
**Post date:** [December 4, 2015, 11:00am UTC](https://discuss.dev.twitch.com/t/need-to-get-the-channels-for-a-team/4072/10 "2015-12-04T11:00:25Z")

</div>

You should have read these documents before you deploy.

> <https://github.com/justintv/Twitch-API/blob/master/README.md>

[https://github.com/justintv/Twitch-API/blob/master/authentication.md](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].

---

<div class="post-metadata">

**Author:** ![night](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/night/32/1613_2.png) [@night](https://discuss.dev.twitch.com/u/night)\
**Post date:** [December 7, 2015, 5:33pm UTC](https://discuss.dev.twitch.com/t/need-to-get-the-channels-for-a-team/4072/11 "2015-12-07T17:33:04Z")

</div>

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](http://api.twitch.tv/api/team/team_kappa/all_channels.json) for an example.

---

<div class="post-metadata">

**Author:** ![SReject](https://avatars.discourse-cdn.com/v4/letter/s/13edae/32.png) [@SReject](https://discuss.dev.twitch.com/u/SReject)\
**Post date:** [December 10, 2015, 3:04pm UTC](https://discuss.dev.twitch.com/t/need-to-get-the-channels-for-a-team/4072/12 "2015-12-10T15:04:15Z")

</div>

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](http://api.twitch.tv/api/teams/%5Bteam_name%5D/all_channels.json) to get a list; if you do not verify the team exists, the 2nd call will result in a redirect

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [January 9, 2016, 3:04pm UTC](https://discuss.dev.twitch.com/t/need-to-get-the-channels-for-a-team/4072/13 "2016-01-09T15:04:26Z")

</div>

Closed on January 9, 2016, 3:04pm UTC

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