Tobonaut
Tobonaut

Reputation: 2485

Get online status of stream of Twitch team members

I want to get a list of all online status (if it is streaming or not) of Twitch team members for a given team name.

My current approach

  1. Get team from API (https://api.twitch.tv/kraken/team/<team name>)
  2. Get stream status for each team member (https://api.twitch.tv/kraken/streams/<channel id>)

My problem with this

First request is okay and works as expected. but I have to request each channel / streamer by it self and not in bulk - and the responded data is more than I really need.

Question

Is there any Twitch API endpoint that I can use, that takes several channel ids and response just a flat dict of channel Id and flag if the streamer is online?

Like:

{[
    { id: 123, online: false },
    { id: 456, online: true}
}]

Upvotes: 1

Views: 462

Answers (1)

Tobonaut
Tobonaut

Reputation: 2485

Solution

  1. Get all of the members _idproperty
  2. Build url like https://api.twitch.tv/helix/streams?user_id=123&user_id=456
  3. Loop over response
  4. If a response's user_id matches an _id -> User is online

Source

discuss.dev.twitch.tv

Upvotes: 1

Related Questions