Need to get the Channels for a 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