Status of live stream

Hello!
When I call:
https://api.twitch.tv/kraken/channel
Using GET I have a json object where I can extract the stream key

"rtmp://live.twitch.tv/app/" + __stream_key__

After I start my app stream (for sample ffmpeg command line) how I can get the status of stream?

Will return a stream

Or just test the RTMP feed you are sending.

Hello!

I am trying:

            string url = "https://api.twitch.tv/helix/streams?first=1&client_id=__MY_CLIENT_ID__&token=" + tokenTwitch;

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.KeepAlive = false;
        request.ProtocolVersion = HttpVersion.Version11;
        request.Headers.Add("Authorization:OAuth " + tokenTwitch);
        request.Headers.Add("client_id: __MY_CLIENT_ID__");
        request.Method = "GET";
        request.Timeout = 2000;
        request.ContentType = "application/json; charset=UTF-8";

        //request.Accept = "application/json";
        request.Accept = "application/vnd.twitchtv.v5+json";
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();

What scope I need to add?

When I try it I have info ‘unauthorized’ as return. (code 401)

You should include a space between : and OAuth

Also for Helix, it’s Bearer Not OAuth

No scopes are required for this endpoint

The URL is JUST https://api.twitch.tv/helix/streams?first=1

This’ll return the Top 1 Stream.

Helix does not require this header.

It’s Client-ID not client_id

Is your token still valid?

Documentation for endpoint

Hello again!

I need to know when my stream_key is sending a valid streaming…

For sample, I have:
“rtmp://live.twitch.tv/app/” + stream_key

I need to know when I have an active streaming. Do you understand?

Your RTMP sending software will either error/be disconnected or start sending stream data.

This endpoint lets you see if the Stream is fully up/live according to Twitch

You can pass a user_login or user_id as documented to lookup a single stream/channel

About this… I don’t have info of statistics of RTMP?

Refer to the documentation for the library you are using to transmit over RTMP

But as I said if the stream key is wrong you’ll get DC’ed and the library should error.
If the stream key is right, then your library will start sending data.

FFmpeg for example will just not start sending data and error out:

For example.

This is the only way to know.

Either poll the API to see if the stream started OK according to Twitch
Or listen to events emiitted by your RTMP library.

Hello again!

I need to get using API ‘OFFLINE’ or ‘ONLINE’ or another value.

I covered this already. Poke the Streams API

Sorry, but, I am confusion :frowning:

Using Facebook API I have:

{

“title”: “ee”,
“status”: “LIVE”,
“stream_url”: “rtmps://live-api-s.facebook.com:443/rtmp/801530220349061?s_bl=1&s_sw=0&s_vt=api-s&a=Aby0xjlCrYkFYyCJ”,
“secure_stream_url”: “rtmps://live-api-s.facebook.com:443/rtmp/801530220349061?s_bl=1&s_sw=0&s_vt=api-s&a=Aby0xjlCrYkFYyCJ”,
“embed_html”: “<iframe src=“https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Fcarlos.alberto.phelippe%2Fvideos%2F801530217015728%2F&width=1920” width=“1920” height=“1080” style=“border:none;overflow:hidden” scrolling=“no” frameborder=“0” allowTransparency=“true” allowFullScreen=“true”>”,
“id”: “801530220349061”
}

Where I have same value using Twitch API?

As documented:

curl -H 'Client-ID: uo6dggojyb8d6soh92zknwmi5ej1q2' \
-X GET 'https://api.twitch.tv/helix/streams?user_id=USERID'

Where USERID is the user_id for the channel you are broadcasting to.
or you can use ?user_login=login if you don’t have the user ID

Hi!

My object json is

{
“data”: ,
“pagination”: {}
}

My C# code:

            string url = "https://api.twitch.tv/helix/streams?user_login="+myUserTwitch;

        try
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.KeepAlive = false;
            request.ProtocolVersion = HttpVersion.Version11;
            //request.Headers.Add("Authorization: OAuth " + tokenTwitch);
            request.Headers.Add("Client-ID: MY___CLIENT__ID__");
            request.Method = "GET";
            request.Timeout = 2000;
            request.ContentType = "application/json; charset=UTF-8";

            //request.Accept = "application/json";
            request.Accept = "application/vnd.twitchtv.v5+json";
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            string result;
            using (StreamReader rdr = new StreamReader(response.GetResponseStream()))
            {
                result = rdr.ReadToEnd();
            }

            JObject json = JObject.Parse(result);

            textBox1.Text = json.ToString();
        }
        catch(Exception ex)
        {
            textBox1.Text = ex.Message;
        }

You do not need

request.Accept = “application/vnd.twitchtv.v5+json”;

With helix.

I called https://api.twitch.tv/helix/streams?user_login=carlosalbertophelippe

And I got data:

You need to give it 3/5 minutes after starting the stream before it will show up in helix. Due to caching.

You may also consider using webhooks https://dev.twitch.tv/docs/api/webhooks-guide

Thank you!

I need to wait more time :slight_smile:
Code is correct and return is correct too.

Sorry and thanks!

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