streams - YoYoGames/GMEXT-Twitch GitHub Wiki

Streams

Functions

These are the functions of this module:



Back To Top

twitch_streams_get_stream_key

Twitch Endpoint: Get Stream Key

This function gets the channel's stream key.

Note

Requires a user access token that includes the TWITCH_SCOPE: TWITCH_SCOPE_CHANNEL_READ_STREAM_KEY.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_streams_get_stream_key(broadcaster_id, callback_success, callback_failed)
Argument Type Description
broadcaster_id String The ID of the broadcaster that owns the channel. The ID must match the user ID in the access token.
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
data Array A list that contains the channel's stream key.
 └── stream_key String The channel's stream key.

Failure Callback

This method is triggered on failure.




Back To Top

twitch_streams_get_streams

Twitch Endpoint: Get Streams

This function gets a list of all streams. The list is in descending order by the number of viewers watching the stream. Because viewers come and go during a stream, it's possible to find duplicate or missing streams in the list as you page through the results.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_streams_get_streams(optionals, callback_success, callback_failed)
Argument Type Description
optionals Struct The optional parameters to be passed into the function:

- user_id : String or Array of String : A user ID used to filter the list of streams. Returns only the streams of those users that are broadcasting. You may specify a maximum of 100 IDs. Pass an array of IDs to specify multiple.
- user_login : String or Array of String : A user login name used to filter the list of streams. Returns only the streams of those users that are broadcasting. You may specify a maximum of 100 login names. To specify multiple names, pass an array of user names.
- game_id : String or Array of String : A game (category) ID used to filter the list of streams. Returns only the streams that are broadcasting the game (category). You may specify a maximum of 100 IDs. Pass an array of IDs to specify multiple game IDs.
- type : String : The type of stream to filter the list of streams by. Possible values are: "all", "live". The default is "all".
- language : String : A language code used to filter the list of streams. Returns only streams that broadcast in the specified language. Specify the language using an ISO 639-1 two-letter language code or "other" if the broadcast uses a language not in the list of supported stream languages. You may specify a maximum of 100 language codes. To specify multiple languages, pass an array with the codes of each language you want to include.
- first : Real : The maximum number of items to return per page in the response. The minimum page size is 1 item per page and the maximum is 100 items per page. The default is 20.
- before : String : The cursor used to get the previous page of results. The Pagination struct in the response contains the cursor's value. Read more
- after : String : The cursor used to get the next page of results. The Pagination struct in the response contains the cursor's value. Read more
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
data Array The list of streams.
 ├── id String An ID that identifies the stream. You can use this ID later to look up the video on demand (VOD).
 ├── user_id String The ID of the user that's broadcasting the stream.
 ├── user_login String The user's login name.
 ├── user_name String The user's display name.
 ├── game_id String The ID of the category or game being played.
 ├── game_name String The name of the category or game being played.
 ├── type String The type of stream. Possible values are: "live". If an error occurs, this field is set to an empty string.
 ├── title String The stream's title. Is an empty string if not set.
 ├── tags Array of String The tags applied to the stream.
 ├── viewer_count Real The number of users watching the stream.
 ├── started_at String The UTC date and time (in RFC3339 format) of when the broadcast began.
 ├── language String The language that the stream uses. This is an ISO 639-1 two-letter language code or "other" if the stream uses a language not in the list of supported stream languages.
 ├── thumbnail_url String A URL to an image of a frame from the last 5 minutes of the stream. Replace the width and height placeholders in the URL ({width}x{height}) with the size of the image you want, in pixels.
 ├── tag_ids Array of String IMPORTANT As of February 28, 2023, this field is deprecated and returns only an empty array. If you use this field, please update your code to use the tags field. The list of tags that apply to the stream. The list contains IDs only when the channel is streaming live. For a list of possible tags, see List of All Tags. The list doesn't include Category Tags.
 └── is_mature Boolean A Boolean value that indicates whether the stream is meant for mature audiences.
pagination Struct The information used to page through the list of results. The struct is empty if there are no more pages left to page through. Read More
 └── cursor String The cursor used to get the next page of results. Set the request's after or before parameter to this value depending on whether you're paging forwards or backwards.

Failure Callback

This method is triggered on failure.




Back To Top

twitch_streams_get_followed_streams

Twitch Endpoint: Get Followed Streams

This function gets the list of broadcasters that the user follows and that are streaming live.

Note

Requires a user access token that includes the TWITCH_SCOPE: TWITCH_SCOPE_USER_READ_FOLLOWS.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_streams_get_followed_streams(user_id, optionals, callback_success, callback_failed)
Argument Type Description
user_id String The ID of the user whose list of followed streams you want to get. This ID must match the user ID in the access token.
optionals Struct The optional parameters to be passed into the function:

- first : Real : The maximum number of items to return per page in the response. The minimum page size is 1 item per page and the maximum is 100 items per page. The default is 100.
- after : String : The cursor used to get the next page of results. The Pagination struct in the response contains the cursor's value. Read more
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
data Array The list of live streams of broadcasters that the specified user follows. The list is in descending order by the number of viewers watching the stream. Because viewers come and go during a stream, it's possible to find duplicate or missing streams in the list as you page through the results. The list is empty if none of the followed broadcasters are streaming live.
 ├── id String An ID that identifies the stream. You can use this ID later to look up the video on demand (VOD).
 ├── user_id String The ID of the user that's broadcasting the stream.
 ├── user_login String The user's login name.
 ├── user_name String The user's display name.
 ├── game_id String The ID of the category or game being played.
 ├── game_name String The ID of the category or game being played.
 ├── type String The type of stream. Possible values are: "live". If an error occurs, this field is set to an empty string.
 ├── title String The stream's title. Is an empty string if not set.
 ├── viewer_count Real The number of users watching the stream.
 ├── started_at String The UTC date and time (in RFC3339 format) of when the broadcast began.
 ├── language String The language that the stream uses. This is an ISO 639-1 two-letter language code or "other" if the stream uses a language not in the list of supported stream languages.
 ├── thumbnail_url String A URL to an image of a frame from the last 5 minutes of the stream. Replace the width and height placeholders in the URL ({width}x{height}) with the size of the image you want, in pixels.
 ├── tag_ids Array of String IMPORTANT As of February 28, 2023, this field is deprecated and returns only an empty array. If you use this field, please update your code to use the tags field. The list of tags that apply to the stream. The list contains IDs only when the channel is streaming live. For a list of possible tags, see List of All Tags. The list doesn't include Category Tags.
 ├── tags Array of String The tags applied to the stream.
 └── is_mature Boolean A Boolean value that indicates whether the stream is meant for mature audiences.
pagination Struct The information used to page through the list of results. The struct is empty if there are no more pages left to page through. Read More
 └── cursor String The cursor used to get the next page of results. Set the request's after parameter to this value.

Failure Callback

This method is triggered on failure.




Back To Top

twitch_streams_create_stream_marker

Twitch Endpoint: Create Stream Marker

This function adds a marker to a live stream. A marker is an arbitrary point in a live stream that the broadcaster or editor wants to mark, so they can return to that spot later to create video highlights (see Video Producer, Highlights in the Twitch UX).

You may not add markers:

  • If the stream is not live
  • If the stream has not enabled video on demand (VOD)
  • If the stream is a premiere (a live, first-viewing event that combines uploaded videos with live chat)
  • If the stream is a rerun of a past broadcast, including past premieres.

Note

Requires a user access token that includes the TWITCH_SCOPE: TWITCH_SCOPE_CHANNEL_MANAGE_BROADCAST.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_streams_create_stream_marker(user_id, optionals, callback_success, callback_failed)
Argument Type Description
user_id String The ID of the broadcaster that's streaming content. This ID must match the user ID in the access token or the user in the access token must be one of the broadcaster's editors.
optionals Struct The optional parameters to be passed into the function:

- description : String : A short description of the marker to help the user remember why they marked the location. The maximum length of the description is 140 characters.
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
data Array A list that contains the single marker that you added.
 ├── id String An ID that identifies this marker.
 ├── created_at String The UTC date and time (in RFC3339 format) of when the user created the marker.
 ├── position_seconds Real The relative offset (in seconds) of the marker from the beginning of the stream.
 └── description String A description that the user gave the marker to help them remember why they marked the location.

Failure Callback

This method is triggered on failure.




Back To Top

twitch_streams_get_stream_markers

Twitch Endpoint: Get Stream Markers

This function gets a list of markers from the user's most recent stream or from the specified VOD/video. A marker is an arbitrary point in a live stream that the broadcaster or editor marked, so they can return to that spot later to create video highlights (see Video Producer, Highlights in the Twitch UX).

Note

Requires a user access token that includes the TWITCH_SCOPE_USER_READ_BROADCAST or TWITCH_SCOPE_CHANNEL_MANAGE_BROADCAST scope.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_streams_get_stream_markers(user_id, video_id, optionals, callback_success, callback_failed)
Argument Type Description
user_id String A user ID. The request returns the markers from this user's most recent video. This ID must match the user ID in the access token or the user in the access token must be one of the broadcaster's editors. This parameter and the video_id parameter are mutually exclusive.
video_id String A video on demand (VOD)/video ID. The request returns the markers from this VOD/video. The user in the access token must own the video or the user must be one of the broadcaster's editors. This parameter and the user_id parameter are mutually exclusive.
optionals Struct The optional parameters to be passed into the function:

- first : String : The maximum number of items to return per page in the response. The minimum page size is 1 item per page and the maximum is 100 items per page. The default is 20.
- before : String : The cursor used to get the previous page of results. The Pagination struct in the response contains the cursor's value. Read more
- after : String : The cursor used to get the next page of results. The Pagination struct in the response contains the cursor's value. Read more
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
data Array The list of markers grouped by the user that created the marks.
 ├── user_id String The ID of the user that created the marker.
 ├── user_name String The user's display name.
 ├── user_login String The user's login name.
 ├── videos Array A list of videos that contain markers. The list contains a single video.
 ├── video_id String An ID that identifies this video.
 └── markers Array The list of markers in this video. The list in ascending order by when the marker was created.
         ├── id String An ID that identifies this marker.
         ├── created_at String The UTC date and time (in RFC3339 format) of when the user created the marker.
         ├── description String The description that the user gave the marker to help them remember why they marked the location. Is an empty string if the user didn't provide one.
         ├── position_seconds Real The relative offset (in seconds) of the marker from the beginning of the stream.
         └── url String A URL that opens the video in Twitch Highlighter.
pagination Struct The information used to page through the list of results. The struct is empty if there are no more pages left to page through. Read More
 └── cursor String The cursor used to get the next page of results. Set the request's after or before parameter to this value depending on whether you're paging forwards or backwards.

Failure Callback

This method is triggered on failure.



⚠️ **GitHub.com Fallback** ⚠️