Jahongir Rahmonov
Jahongir Rahmonov

Reputation: 13723

Get a list of live streaming users in Twitch

I want to retrieve a list of users who are live streaming code.

This endpoint will give a list of live streams:

curl -H 'Accept: application/vnd.twitchtv.v3+json' -X GET https://api.twitch.tv/kraken/streams?stream_type=live

A stream (one of the responses) has a channel which has a name:

{
        "_id": 21413418816,
        "_links": {
            "self": "https://api.twitch.tv/kraken/streams/nervarien"
        },
        "average_fps": 60.0490196078,
        "channel": {
            "_id": 25452510,
            "_links": {
                "chat": "http://api.twitch.tv/kraken/chat/nervarien",
                "commercial": "http://api.twitch.tv/kraken/channels/nervarien/commercial",
                "editors": "http://api.twitch.tv/kraken/channels/nervarien/editors",
                "features": "http://api.twitch.tv/kraken/channels/nervarien/features",
                "follows": "http://api.twitch.tv/kraken/channels/nervarien/follows",
                "self": "http://api.twitch.tv/kraken/channels/nervarien",
                "stream_key": "http://api.twitch.tv/kraken/channels/nervarien/stream_key",
                "subscriptions": "http://api.twitch.tv/kraken/channels/nervarien/subscriptions",
                "teams": "http://api.twitch.tv/kraken/channels/nervarien/teams",
                "videos": "http://api.twitch.tv/kraken/channels/nervarien/videos"
            },
            "background": null,
            "banner": null,
            "broadcaster_language": "pl",
            "created_at": "2011-10-14T16:36:04Z",
            "delay": null,
            "display_name": "Nervarien",
            "followers": 205381,
            "game": "League of Legends",
            "language": "pl",
            "logo": "https://static-cdn.jtvnw.net/jtv_user_pictures/nervarien-profile_image-8a488c78bf3d3082-300x300.png",
            "mature": false,
            "name": "nervarien",
            "partner": true,
            "profile_banner": null,
            "profile_banner_background_color": null,
            "status": "PI\u0104TEK 12:00!",
            "updated_at": "2016-05-20T11:02:47Z",
            "url": "https://www.twitch.tv/nervarien",
            "video_banner": "https://static-cdn.jtvnw.net/jtv_user_pictures/nervarien-channel_offline_image-8b8038246b36a5d6-1920x1080.jpeg",
            "views": 22045728
        },
        "created_at": "2016-05-20T10:08:00Z",
        "delay": 0,
        "game": "League of Legends",
        "is_playlist": false,
        "preview": {
            "large": "https://static-cdn.jtvnw.net/previews-ttv/live_user_nervarien-640x360.jpg",
            "medium": "https://static-cdn.jtvnw.net/previews-ttv/live_user_nervarien-320x180.jpg",
            "small": "https://static-cdn.jtvnw.net/previews-ttv/live_user_nervarien-80x45.jpg",
            "template": "https://static-cdn.jtvnw.net/previews-ttv/live_user_nervarien-{width}x{height}.jpg"
        },
        "video_height": 720,
        "viewers": 2776
    }

Is that name a user's name?

What is the difference between channel and user?

How can I know whether they are streaming code or not?

Upvotes: 3

Views: 2256

Answers (1)

Matt C
Matt C

Reputation: 83

Every user on twitch has their own channel, which in general (except in some circumstances) is the one they stream under. In the example given above, the user's display name, eg. the one that shows in the stream title and in the chat is "Nervarien", indexed under json['channel']['display-name'].

Officially, there is no difference between the channel and the user. They should both be identical.

That user is not streaming code, as seen under json['game'], they are streaming League of Legends. On Twitch, there is no official programming/code section, only a hashtag under the "game" Creative which is a catch all directory for pretty much all non-gaming content. The only way to parse if a user is streaming code on twitch is to check if json['game'] is "Creative" and if this is matched, check json['channel']['status'] and search it for the string #programming, as the tags are located under the stream title.

I hope this answers your question.

Upvotes: 4

Related Questions