ads - YoYoGames/GMEXT-Twitch GitHub Wiki

Ads

Functions

These are the functions of this module:



Back To Top

twitch_ads_start_commercial

Twitch Endpoint: Start Commercial

This function starts a commercial on the specified channel.

Note

Only partners and affiliates may run commercials and they must be streaming live at the time.

Note

Only the broadcaster may start a commercial; the broadcaster's editors and moderators may not start commercials on behalf of the broadcaster.

Requires a user access token that includes the TWITCH_SCOPE_CHANNEL_EDIT_COMMERCIAL 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_ads_start_commercial(broadcaster_id, length, callback_success, callback_failed)
Argument Type Description
broadcaster_id String The ID of the partner or affiliate broadcaster that wants to run the commercial. This ID must match the user ID found in the OAuth token.
length String The length of the commercial you requested. If you request a commercial that's longer than 180 seconds, the API uses 180 seconds.
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 of Struct An array that contains a single struct with the status of your start commercial request.
 ├── length Real The length of the commercial you requested. If you request a commercial that's longer than 180 seconds, the API uses 180 seconds.
 ├── message String A message that indicates whether Twitch was able to serve an ad.
 └── retry_after Real The number of seconds you must wait before running another commercial.

Failure Callback

This method is triggered on failure.




Back To Top

twitch_ads_get_ad_schedule

Twitch Endpoint: Get Ad Schedule

This function returns ad schedule related information, including snooze, when the last ad was run, when the next ad is scheduled, and if the channel is currently in pre-roll free time. Note that a new ad cannot be run until 8 minutes after running a previous ad.

Note

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

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_ads_get_ad_schedule(broadcaster_id, callback_success, callback_failed)
Argument Type Description
broadcaster_id String Provided broadcaster_id must match the user_id in the auth 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 of Struct A list that contains information related to the channel's ad schedule.
 ├── snooze_count Real The number of snoozes available for the broadcaster.
 ├── snooze_refresh_at String The UTC timestamp when the broadcaster will gain an additional snooze, in RFC3339 format.
 ├── next_ad_at String The UTC timestamp of the broadcaster's next scheduled ad, in RFC3339 format. Empty if the channel has no ad scheduled or is not live.
 ├── duration Real The length in seconds of the scheduled upcoming ad break.
 ├── last_ad_at String The UTC timestamp of the broadcaster's last ad-break, in RFC3339 format. Empty if the channel has not run an ad or is not live.
 └── preroll_free_time Real The amount of pre-roll free time remaining for the channel in seconds. Returns 0 if they are currently not pre-roll free.

Failure Callback

This method is triggered on failure.




Back To Top

twitch_ads_snooze_next_ad

Twitch Endpoint: Snooze Next Ad

If available, pushes back the timestamp of the upcoming automatic mid-roll ad by 5 minutes. This endpoint duplicates the snooze functionality in the creator dashboard's Ads Manager.

Note

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

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_ads_snooze_next_ad(broadcaster_id, callback_success, callback_failed)
Argument Type Description
broadcaster_id String Provided broadcaster_id must match the user_id in the auth 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 of Struct A list that contains information about the channel's snoozes and next upcoming ad after successfully snoozing.
 ├── snooze_count Real The number of snoozes available for the broadcaster.
 ├── snooze_refresh_at String The UTC timestamp when the broadcaster will gain an additional snooze, in RFC3339 format.
 └── next_ad_at String The UTC timestamp of the broadcaster's next scheduled ad, in RFC3339 format.

Failure Callback

This method is triggered on failure.



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