# Godot Engine Reference

Reference for the classes in the Twitch Godot plugin, for GDScript and C#

Source: https://dev.twitch.tv/docs/game-engine-plugins/godot-reference/

This reference describes the classes of the Twitch Godot plugin (version 2.1). The plugin is a GDExtension for Godot 4.5 or newer. For an introduction, see the [Godot GDScript Guide](https://dev.twitch.tv/docs/game-engine-plugins/godot-guide-gdscript.md) or the [Godot C# Guide](https://dev.twitch.tv/docs/game-engine-plugins/godot-guide-csharp.md).

- [GDScript API](#gdscript-api): the `Twitch` singleton, `TwitchTask`, `TwitchEventStream`, `TwitchPoll`, `TwitchPrediction`, and the data classes. The same documentation is available in the editor: press F1 and search for *Twitch*.
- [C# API](#c-api): the typed wrappers in the `TwitchSDK` namespace.

## Project Settings

| Setting | Type | Default | Description |
| --- | --- | --- | --- |
| `twitch/auth/client_id` | String | `""` | Your application's Client ID. The plugin starts once it has one. |
| `twitch/debug/use_eventsub_proxy` | bool | `false` | Connect to a local EventSub test proxy instead of Twitch. It takes effect the next time the game starts. Never enable this in releases. |

The **Twitch** editor dock edits these settings. It also checks the Client ID against Twitch, and shows the plugin and core library versions.

## General behavior

- **Starting.** The plugin starts when the game starts, if the project has a Client ID. Otherwise it starts as soon as `Twitch.set_client_id()` (`Twitch.ClientId` in C#) is called. In the editor, it only starts when a tool script uses it. Until it has started, calls fail with an error that explains why.
- **Login.** The plugin logs users in with the device code flow, which only needs the Client ID. The login is saved in `user://twitch-twitchsdk-authorization.json`.
- **Tasks.** Calls return a `TwitchTask` that completes from the frame loop, on the main thread. Calls that need a logged-in user wait until the user has logged in.
- **Logging.** The plugin's log messages are printed to Godot's output, prefixed with `[TwitchSDK]` (debug messages only with `--verbose`), and emitted as the `Twitch.log_message` signal.
- **Shutting down.** The plugin shuts down when the game exits. Await `Twitch.prepare_shutdown()` first to remove the game's Channel Point rewards from the channel.
- **HTTP requests** identify the plugin with the User-Agent `GodotEngine/<engine version> (<OS>) Twitch-Route-66-Godot/2.1`.

## Event subscription scopes

| Event | Subscribe method | Event class | Required scope |
| --- | --- | --- | --- |
| Follows | `subscribe_to_channel_follow_events()` | `TwitchChannelFollowEvent` | `moderator:read:followers` |
| Subscriptions | `subscribe_to_channel_subscribe_events()` | `TwitchChannelSubscribeEvent` | `channel:read:subscriptions` |
| Cheers | `subscribe_to_channel_cheer_events()` | `TwitchChannelCheerEvent` | `bits:read` |
| Raids | `subscribe_to_channel_raid_events()` | `TwitchChannelRaidEvent` | none |
| Hype Trains | `subscribe_to_hype_train_events()` | `TwitchHypeTrainEvent` | `channel:read:hype_train` |
| Channel Point redemptions | `subscribe_to_custom_reward_events()` | `TwitchCustomRewardEvent` | `channel:manage:redemptions` |

`moderator:read:followers` and `channel:read:subscriptions` don't have an `OAuthScope` constant; pass them to `get_authentication_info()` as strings. If the user didn't grant the required scope, Twitch refuses the subscription: the plugin logs a warning, and no events of that type arrive.

Hype Train events arrive when a Hype Train begins, makes progress, and ends.

# GDScript API

## Twitch

*Inherits:* `Object`

Access the Twitch API through the `Twitch` singleton. The library starts automatically when the game starts, using the Client ID from the `twitch/auth/client_id` project setting, and keeps the user's login in `user://`.

Every API call returns a [`TwitchTask`](#twitchtask). Await it, or poll it from `Node._process()`:

```gdscript
var info: TwitchUserInfo = await Twitch.get_my_user_info().completed
```

The library only starts once it has a Client ID. If the project setting is empty, call `set_client_id()` first; until then, calls fail with an explanatory error.

Requests and results are typed `Resource` classes such as [`TwitchPollDefinition`](#twitchpolldefinition) and [`TwitchPollInfo`](#twitchpollinfo).

### Methods

#### build_oauth_scopes()

```gdscript
static func build_oauth_scopes(scopes: Array) -> String
```

Builds a space-separated scope string from an `Array` of `OAuthScope` values and/or custom scope `String`s.

#### check_user_subscription()

```gdscript
func check_user_subscription(broadcaster_id: String) -> TwitchTask
```

Checks if the logged-in user is subscribed to a channel. Resolves a [`TwitchUserSubscriptionCheckResult`](#twitchusersubscriptioncheckresult). Results are cached for 15 seconds per broadcaster.

Required scope: `user:read:subscriptions`.

#### close_event_stream()

```gdscript
func close_event_stream(event_stream_desc: TwitchEventStreamDesc) -> TwitchTask
```

Close a Twitch EventSub subscription.

After the subscription is closed, trying to receive events from it is an error.

The task resolves `null`.

#### create_clip()

```gdscript
func create_clip(has_delay: bool) -> TwitchTask
```

Creates a clip programmatically. This returns both an ID and an edit URL for the new clip.

Required scope: `clips:edit`

Creating a clip can take up to 15 seconds.

If `has_delay` is `false`, the clip is captured from the live stream when the API is called; otherwise, a delay is added before the clip is captured (to account for the brief delay between the broadcaster's stream and the viewer's experience of that stream).

The task resolves a [`TwitchClipInfo`](#twitchclipinfo): An object describing the new clip.

#### create_poll()

```gdscript
func create_poll(poll_definition: TwitchPollDefinition) -> TwitchTask
```

Create a poll on the user's Twitch channel.

Required scope: `channel:manage:polls`

Creating a poll automatically subscribes to updates for this poll. Avoid unnecessary traffic by invoking `Twitch.unsubscribe_from_poll()` at some point for every poll you create.

The task resolves a [`TwitchPollInfo`](#twitchpollinfo): An object describing the new poll.

#### create_prediction()

```gdscript
func create_prediction(prediction_definition: TwitchPredictionDefinition) -> TwitchTask
```

Create a Channel Points Prediction on the user's Twitch channel.

Required scope: `channel:manage:predictions`

Creating a prediction automatically subscribes to updates for this prediction. Avoid unnecessary traffic by invoking `Twitch.unsubscribe_from_prediction()` at some point for every prediction you create.

The task resolves a [`TwitchPredictionInfo`](#twitchpredictioninfo): An object describing the new prediction.

#### create_stream_marker()

```gdscript
func create_stream_marker(description: String) -> TwitchTask
```

Creates a marker in the stream of a user.

Required scope: `channel:manage:broadcast`

A marker is an arbitrary point in a stream that the broadcaster wants to mark; e.g., to easily return to later. The marker is created at the current timestamp in the live broadcast when the request is processed. Markers can be created by the stream owner or editors.

Markers cannot be created in some cases (an error will occur):

- If the specified user's stream is not live.
- If VOD (past broadcast) storage is not enabled for the stream.
- For premieres (live, first-viewing events that combine uploaded videos with live chat).
- For reruns (subsequent (not live) streaming of any past broadcast, including past premieres).

The task resolves a [`TwitchStreamMarkerInfo`](#twitchstreammarkerinfo): An object describing the new stream marker.

#### end_poll()

```gdscript
func end_poll(end_poll_request: TwitchEndPollRequest) -> TwitchTask
```

End a poll prematurely.

The task resolves a [`TwitchPollInfo`](#twitchpollinfo): The updated poll info.

#### end_prediction()

```gdscript
func end_prediction(end_prediction_request: TwitchEndPredictionRequest) -> TwitchTask
```

Lock, resolve, or cancel a Channel Points Prediction.

Required scope: `channel:manage:predictions`

The task resolves a [`TwitchPredictionInfo`](#twitchpredictioninfo): The updated prediction info.

#### fulfill_drop_entitlement_list()

```gdscript
func fulfill_drop_entitlement_list(entitlements: Array[TwitchDropEntitlement]) -> TwitchTask
```

Marks the given entitlements (from `get_drop_entitlements()`) fulfilled. Same as `fulfill_drop_entitlements()` with their IDs.

#### fulfill_drop_entitlements()

```gdscript
func fulfill_drop_entitlements(entitlement_ids: PackedStringArray) -> TwitchTask
```

Marks one or more of the logged-in user's Drop entitlements as fulfilled.

Call this after your game has successfully granted the reward(s) for the given entitlements in-game. Because the plugin uses the logged-in user's access token, you may only fulfill entitlements that belong to that user.

The task resolves `null`.

#### get_auth_state()

```gdscript
func get_auth_state() -> TwitchTask
```

Query the current authentication state.

This call always returns immediately.

The task resolves a [`TwitchAuthState`](#twitchauthstate).

#### get_authentication_info()

```gdscript
func get_authentication_info(scopes: Array) -> TwitchTask
```

Starts the device code login flow and resolves a [`TwitchAuthenticationInfo`](#twitchauthenticationinfo) with the URL and code to show the user. Resolves `null` if the user is already logged in.

`scopes` holds `OAuthScope` values and/or scope `String`s; requesting no scopes is an error. Repeated calls within 0.25 seconds return the same task.

Credentials are stored in `user://`, so the user stays logged in across restarts. Poll `get_auth_state()` to see when the login completes.

#### get_bits_leaderboard()

```gdscript
func get_bits_leaderboard(bits_leaderboard_request: TwitchBitsLeaderboardRequest) -> TwitchTask
```

Gets a ranked list of Bits leaderboard information for an authorized broadcaster.

Required scope: `bits:read`

The task resolves a [`TwitchBitsLeaderboard`](#twitchbitsleaderboard).

#### get_client_id()

```gdscript
func get_client_id() -> String
```

The Client ID in use. Comes from the `twitch/auth/client_id` project setting unless changed with `set_client_id()`.

#### get_drop_entitlements()

```gdscript
func get_drop_entitlements(game_id: String = "", fulfillment_status: Twitch.DropFulfillmentStatus = Twitch.DROP_FULFILLMENT_STATUS_CLAIMED) -> TwitchTask
```

Gets the logged-in user's Twitch Drop entitlements and resolves a [`TwitchDropEntitlementList`](#twitchdropentitlementlist). This supports the "offline inventory" Drops model: grant the rewards in-game, then mark them fulfilled with `fulfill_drop_entitlements()`.

`game_id` restricts the results to one game (category); leave it empty for all of your games. `fulfillment_status` defaults to Claimed (still to be granted); use Unknown for any status.

There is no push notification for Drops; call this periodically or from a "Check for Drops" button.

#### get_my_stream_info()

```gdscript
func get_my_stream_info() -> TwitchTask
```

Gets information about the currently logged-in user's stream.

If the user is not logged in, this also waits for a successful login. If the user is currently not live, the result is an empty [`TwitchStreamInfo`](#twitchstreaminfo) (its `TwitchStreamInfo.id` is empty).

The task resolves a [`TwitchStreamInfo`](#twitchstreaminfo).

#### get_my_user_info()

```gdscript
func get_my_user_info() -> TwitchTask
```

Gets information about the currently logged-in user's account.

If the user is not logged in, this also waits for a successful login.

The task resolves a [`TwitchUserInfo`](#twitchuserinfo).

#### get_plugin_version()

```gdscript
func get_plugin_version() -> String
```

The plugin version, for example `2.1`.

#### get_stream_info_by_id()

```gdscript
func get_stream_info_by_id(channel_id: String) -> TwitchTask
```

Resolves the [`TwitchStreamInfo`](#twitchstreaminfo) of a channel, or `null` if it's offline or doesn't exist.

#### get_use_eventsub_proxy()

```gdscript
func get_use_eventsub_proxy() -> bool
```

Whether the library connects to a local EventSubProxy instead of Twitch (`twitch/debug/use_eventsub_proxy`). Never enable this in releases.

#### get_user_info_by_id()

```gdscript
func get_user_info_by_id(id: String) -> TwitchTask
```

Gets information about a specific Twitch user account.

Returns an empty object if no such user could be found.

The task resolves a [`TwitchUserInfo`](#twitchuserinfo).

#### get_user_info_by_login_name()

```gdscript
func get_user_info_by_login_name(login: String) -> TwitchTask
```

Gets information about a specific Twitch user account.

Returns an empty object if no such user could be found.

The task resolves a [`TwitchUserInfo`](#twitchuserinfo).

#### get_version()

```gdscript
func get_version() -> String
```

The core library's version string, for example `2.1-<build>`.

#### initialize()

```gdscript
func initialize() -> bool
```

Starts the library now, if it isn't running yet. Returns `false` if no Client ID is set or the library has been shut down. The library never starts without a Client ID: with a saved login but no Client ID, Twitch would reject the token refresh and the saved login would be lost.

#### is_initialized()

```gdscript
func is_initialized() -> bool
```

Whether the library is running. It starts when the game starts if a Client ID is set in the project settings, otherwise as soon as `set_client_id()` is called. In the editor it starts on first API use.

#### log_out()

```gdscript
func log_out() -> TwitchTask
```

Log out.

This call always returns immediately.

The task resolves `null`.

#### modify_channel_information()

```gdscript
func modify_channel_information(modify_channel_info_request: TwitchModifyChannelInfoRequest) -> TwitchTask
```

Modifies channel information for the currently logged-in user.

Required scope: `channel:manage:broadcast`

The task resolves `null`.

#### new_poll()

```gdscript
func new_poll(definition: TwitchPollDefinition) -> TwitchTask
```

Creates a poll and resolves a [`TwitchPoll`](#twitchpoll) that tracks it, keeping `TwitchPoll.info` up to date.

Required scope: `channel:manage:polls`.

#### new_prediction()

```gdscript
func new_prediction(definition: TwitchPredictionDefinition) -> TwitchTask
```

Creates a Channel Points Prediction and resolves a [`TwitchPrediction`](#twitchprediction) that tracks it.

Required scope: `channel:manage:predictions`.

#### oauth_scope_to_string()

```gdscript
static func oauth_scope_to_string(scope: Twitch.OAuthScope) -> String
```

The Twitch scope string for an `OAuthScope`, for example `channel:manage:polls`.

#### prepare_shutdown()

```gdscript
func prepare_shutdown() -> TwitchTask
```

Prepare for shutdown.

You should invoke this function and wait for it to return before exiting from your game process. This function resets state associated with your session such as available Channel Points rewards.

The task resolves `null`.

#### query_streams()

```gdscript
func query_streams(stream_query: TwitchStreamQuery) -> TwitchTask
```

Gets information about active streams. Streams are returned sorted by number of current viewers, in descending order.

Submitting an empty `stream_query` is valid and fetches the top streams currently on Twitch. Across multiple pages of results, there may be duplicate or missing streams, as viewers join and leave streams.

The task resolves a [`TwitchStreamQueryResult`](#twitchstreamqueryresult): An object containing the matching streams and optionally a pagination token to fetch more results.

#### replace_custom_rewards()

```gdscript
func replace_custom_rewards(rewards: Array[TwitchCustomRewardDefinition]) -> TwitchTask
```

Updates the set of available custom Channel Points rewards on a channel.

Required scope: `channel:manage:redemptions`

If you enable any custom rewards, please clear them by invoking this function with an empty rewards list when the game terminates.

Note that removing rewards that still have pending redemptions will set those redemptions to `Twitch.CUSTOM_REWARD_REDEMPTION_STATE_FULFILLED`.

The task resolves `null`.

#### resolve_custom_reward()

```gdscript
func resolve_custom_reward(custom_reward_resolve_request: TwitchCustomRewardResolveRequest) -> TwitchTask
```

Updates the status of Custom Reward Redemption objects on a channel that are in the `Twitch.CUSTOM_REWARD_REDEMPTION_STATE_UNFULFILLED` status.

Required scope: `channel:manage:redemptions`

The task resolves `null`.

#### resolve_custom_reward_event()

```gdscript
func resolve_custom_reward_event(event: TwitchCustomRewardEvent, resolution: Twitch.CustomRewardRedemptionState) -> TwitchTask
```

Fulfills or cancels the redemption from a custom reward event. Canceling refunds the viewer's Channel Points.

Required scope: `channel:manage:redemptions`.

#### set_client_id()

```gdscript
func set_client_id(client_id: String) -> void
```

Sets the Client ID at runtime and starts the library if it isn't running yet. Meant for development and samples; it doesn't change the project setting. If the library is already running, the current login is kept (log out and in again to use the new Client ID).

#### shutdown()

```gdscript
func shutdown() -> void
```

Stops the library and drops all pending requests. Call `prepare_shutdown()` first (and wait for it) to clean up session state such as custom rewards. This happens automatically when the game exits.

#### subscribe_to_channel_cheer_events()

```gdscript
func subscribe_to_channel_cheer_events() -> TwitchTask
```

Resolves a [`TwitchEventStream`](#twitcheventstream) of [`TwitchChannelCheerEvent`](#twitchchannelcheerevent)s.

#### subscribe_to_channel_follow_events()

```gdscript
func subscribe_to_channel_follow_events() -> TwitchTask
```

Resolves a [`TwitchEventStream`](#twitcheventstream) of [`TwitchChannelFollowEvent`](#twitchchannelfollowevent)s.

#### subscribe_to_channel_raid_events()

```gdscript
func subscribe_to_channel_raid_events() -> TwitchTask
```

Resolves a [`TwitchEventStream`](#twitcheventstream) of [`TwitchChannelRaidEvent`](#twitchchannelraidevent)s.

#### subscribe_to_channel_subscribe_events()

```gdscript
func subscribe_to_channel_subscribe_events() -> TwitchTask
```

Resolves a [`TwitchEventStream`](#twitcheventstream) of [`TwitchChannelSubscribeEvent`](#twitchchannelsubscribeevent)s (new subscribers, not resubscribes).

#### subscribe_to_custom_reward_events()

```gdscript
func subscribe_to_custom_reward_events() -> TwitchTask
```

Resolves a [`TwitchEventStream`](#twitcheventstream) of [`TwitchCustomRewardEvent`](#twitchcustomrewardevent)s (custom Channel Points reward redemptions and their updates).

#### subscribe_to_event_stream()

```gdscript
func subscribe_to_event_stream(kind: Twitch.EventStreamKind) -> TwitchTask
```

Subscribe to a Twitch EventSub stream.

You must periodically receive events from your event stream. You must call `Twitch.close_event_stream()` once you are done.

To avoid leaking memory indefinitely in this case, there is an internal limit of 512 buffered events per event stream subscription, as well as an internal limit of 64 subscriptions per event type in total. When the internal buffer of a subscription is full, incoming events will be discarded silently. When the subscriptions limit is reached, an arbitrary subscription of the same type will be closed, and a warning message will be logged.

The task resolves a [`TwitchEventStreamDesc`](#twitcheventstreamdesc): An object describing the subscription.

#### subscribe_to_events()

```gdscript
func subscribe_to_events(kind: Twitch.EventStreamKind) -> TwitchTask
```

Subscribes to EventSub events of the given kind and resolves a [`TwitchEventStream`](#twitcheventstream). Read events regularly (they're buffered) and close the stream when you're done.

#### subscribe_to_hype_train_events()

```gdscript
func subscribe_to_hype_train_events() -> TwitchTask
```

Resolves a [`TwitchEventStream`](#twitcheventstream) of [`TwitchHypeTrainEvent`](#twitchhypetrainevent)s. Requires the `channel:read:hype_train` scope.

#### unsubscribe_from_poll()

```gdscript
func unsubscribe_from_poll(id: String) -> TwitchTask
```

Unsubscribe from updates for a specific poll.

You must not invoke this function multiple times for the same poll. Unsubscribing from polls is optional. Failing to do so results in unnecessary traffic, but will not cause any malfunction or memory leak.

The task resolves `null`.

#### unsubscribe_from_prediction()

```gdscript
func unsubscribe_from_prediction(id: String) -> TwitchTask
```

Unsubscribe from updates for a specific prediction.

You must not invoke this function multiple times for the same prediction. Unsubscribing from predictions is optional. Failing to do so results in unnecessary traffic, but will not cause any malfunction or memory leak.

The task resolves `null`.

#### wait_for_channel_cheer_event()

```gdscript
func wait_for_channel_cheer_event(event_stream_desc: TwitchEventStreamDesc) -> TwitchTask
```

A user cheers on the specified channel.

You may only call this with a subscription for the correct event type.

The task resolves a [`TwitchChannelCheerEvent`](#twitchchannelcheerevent): The event.

#### wait_for_channel_follow_event()

```gdscript
func wait_for_channel_follow_event(event_stream_desc: TwitchEventStreamDesc) -> TwitchTask
```

A specified channel receives a follow.

You may only call this with a subscription for the correct event type.

The task resolves a [`TwitchChannelFollowEvent`](#twitchchannelfollowevent): The event.

#### wait_for_channel_raid_event()

```gdscript
func wait_for_channel_raid_event(event_stream_desc: TwitchEventStreamDesc) -> TwitchTask
```

A broadcaster raids another broadcaster's channel.

You may only call this with a subscription for the correct event type.

The task resolves a [`TwitchChannelRaidEvent`](#twitchchannelraidevent): The event.

#### wait_for_channel_subscribe_event()

```gdscript
func wait_for_channel_subscribe_event(event_stream_desc: TwitchEventStreamDesc) -> TwitchTask
```

A notification when a specified channel receives a subscriber. This does not include resubscribes.

You may only call this with a subscription for the correct event type.

The task resolves a [`TwitchChannelSubscribeEvent`](#twitchchannelsubscribeevent): The event.

#### wait_for_custom_reward_event()

```gdscript
func wait_for_custom_reward_event(event_stream_desc: TwitchEventStreamDesc) -> TwitchTask
```

A viewer has redeemed a custom Channel Points reward on the specified channel or the redemption has been updated (i.e., fulfilled or canceled).

You may only call this with a subscription for the correct event type.

The task resolves a [`TwitchCustomRewardEvent`](#twitchcustomrewardevent): The event.

#### wait_for_hype_train_event()

```gdscript
func wait_for_hype_train_event(event_stream_desc: TwitchEventStreamDesc) -> TwitchTask
```

A Hype Train makes progress on the user's channel. Requires the `channel:read:hype_train` scope.

You may only call this with a subscription for the correct event type.

The task resolves a [`TwitchHypeTrainEvent`](#twitchhypetrainevent): The event.

#### wait_for_poll_update()

```gdscript
func wait_for_poll_update(poll: String) -> TwitchTask
```

Wait for updates to a specified poll. Updates occur when users submit votes, and finally, when the poll ends.

Avoid calling this function on polls after they have ended, as they will no longer receive updates at that point.

The task resolves a [`TwitchPollInfo`](#twitchpollinfo): The updated poll info.

#### wait_for_prediction_update()

```gdscript
func wait_for_prediction_update(prediction: String) -> TwitchTask
```

Wait for updates to a specified prediction. Updates occur when users submit votes, and finally, when the prediction ends.

Avoid calling this function on predictions after they have ended, as they will no longer receive updates at that point.

The task resolves a [`TwitchPredictionInfo`](#twitchpredictioninfo): The updated prediction info.

### Signals

#### log_message

```gdscript
signal log_message(level: Twitch.LogLevel, message: String)
```

Emitted for every message the core library logs, on the main thread. The messages are also printed to the output (debug messages only with `--verbose`); use this signal to show them in your own UI.

### Enums

#### enum OAuthScope

| Constant | Value | Description |
| --- | --- | --- |
| `OAUTH_SCOPE_CHANNEL_MANAGE_POLLS` | 0 | `channel:manage:polls`: create and end polls. |
| `OAUTH_SCOPE_CHANNEL_MANAGE_PREDICTIONS` | 1 | `channel:manage:predictions`: create and resolve predictions. |
| `OAUTH_SCOPE_CHANNEL_MANAGE_BROADCAST` | 2 | `channel:manage:broadcast`: channel information and stream markers. |
| `OAUTH_SCOPE_CHANNEL_MANAGE_REDEMPTIONS` | 3 | `channel:manage:redemptions`: custom Channel Points rewards. |
| `OAUTH_SCOPE_CHANNEL_READ_HYPE_TRAIN` | 4 | `channel:read:hype_train`: Hype Train events. |
| `OAUTH_SCOPE_CLIPS_EDIT` | 5 | `clips:edit`: create clips. |
| `OAUTH_SCOPE_USER_READ_SUBSCRIPTIONS` | 6 | `user:read:subscriptions`: check the user's subscriptions. |
| `OAUTH_SCOPE_BITS_READ` | 7 | `bits:read`: the Bits leaderboard. |

#### enum LogLevel

| Constant | Value | Description |
| --- | --- | --- |
| `LOG_LEVEL_DEBUG` | 0 |  |
| `LOG_LEVEL_INFO` | 1 |  |
| `LOG_LEVEL_WARNING` | 2 |  |
| `LOG_LEVEL_ERROR` | 3 |  |

#### enum AuthStatus

| Constant | Value | Description |
| --- | --- | --- |
| `AUTH_STATUS_LOGGED_OUT` | 0 | The core library is logged out. |
| `AUTH_STATUS_LOADING` | 1 | The status cannot be determined because an operation affecting it is currently in progress. |
| `AUTH_STATUS_WAITING_FOR_CODE` | 2 | The device code flow is in progress and we are currently waiting for the user to authorize. |
| `AUTH_STATUS_LOGGED_IN` | 3 | We have valid OAuth credentials. Note that these credentials may still be rejected if the user revokes your Client ID from their account. |

#### enum HypeTrainContributionType

| Constant | Value | Description |
| --- | --- | --- |
| `HYPE_TRAIN_CONTRIBUTION_TYPE_BITS` | 0 | Bits, from cheering, Power-ups, and Extensions. |
| `HYPE_TRAIN_CONTRIBUTION_TYPE_SUBSCRIPTION` | 1 | Subscriptions, including gifted subscriptions. |
| `HYPE_TRAIN_CONTRIBUTION_TYPE_OTHER` | 2 | Any other contribution method. |

#### enum CustomRewardRedemptionState

| Constant | Value | Description |
| --- | --- | --- |
| `CUSTOM_REWARD_REDEMPTION_STATE_UNKNOWN` | 0 | There was an error determining the state of the redemption. |
| `CUSTOM_REWARD_REDEMPTION_STATE_UNFULFILLED` | 1 | The Channel Points reward has been redeemed and is now waiting to be fulfilled. |
| `CUSTOM_REWARD_REDEMPTION_STATE_FULFILLED` | 2 | The Channel Points reward has been fulfilled. |
| `CUSTOM_REWARD_REDEMPTION_STATE_CANCELED` | 3 | The Channel Points reward has been canceled, and the Channel Points have been refunded. |

#### enum DropFulfillmentStatus

| Constant | Value | Description |
| --- | --- | --- |
| `DROP_FULFILLMENT_STATUS_UNKNOWN` | 0 | The entitlement's status could not be determined (e.g. it was absent or unrecognized in the API response). |
| `DROP_FULFILLMENT_STATUS_CLAIMED` | 1 | The viewer has earned the Drop and claimed it on Twitch, but your game has not yet granted the reward. |
| `DROP_FULFILLMENT_STATUS_FULFILLED` | 2 | Your game has granted the reward and marked the entitlement fulfilled via `Twitch.fulfill_drop_entitlements()`. |

#### enum EventStreamKind

| Constant | Value | Description |
| --- | --- | --- |
| `EVENT_STREAM_KIND_SUBSCRIPTION` | 0 | A notification when a specified channel receives a subscriber. This does not include resubscribes. |
| `EVENT_STREAM_KIND_FOLLOWER` | 1 | A specified channel receives a follow. |
| `EVENT_STREAM_KIND_CHEER` | 2 | A user cheers on the specified channel. |
| `EVENT_STREAM_KIND_CUSTOM_REWARD_REDEMPTION` | 3 | A viewer has redeemed a custom Channel Points reward on the specified channel or the redemption has been updated (i.e., fulfilled or canceled). |
| `EVENT_STREAM_KIND_HYPE_TRAIN` | 4 | A Hype Train makes progress on the user's channel. Requires the `channel:read:hype_train` scope. |
| `EVENT_STREAM_KIND_CHANNEL_RAID` | 5 | A broadcaster raids another broadcaster's channel. |

#### enum PredictionStatus

| Constant | Value | Description |
| --- | --- | --- |
| `PREDICTION_STATUS_ACTIVE` | 0 | The Prediction is active and viewers can make predictions. |
| `PREDICTION_STATUS_LOCKED` | 1 | The Prediction has been locked and viewers can no longer make predictions. |
| `PREDICTION_STATUS_RESOLVED` | 2 | A winning outcome has been chosen and the Channel Points have been distributed to the users who guessed the correct outcome. |
| `PREDICTION_STATUS_CANCELED` | 3 | The Prediction has been canceled and the Channel Points have been refunded to participants. |

#### enum PollStatus

| Constant | Value | Description |
| --- | --- | --- |
| `POLL_STATUS_ACTIVE` | 0 | Poll is currently in progress. |
| `POLL_STATUS_COMPLETED` | 1 | Poll has reached its `TwitchPollInfo.ended_at` time. |
| `POLL_STATUS_TERMINATED` | 2 | Poll has been manually terminated before its `TwitchPollInfo.ended_at` time. |
| `POLL_STATUS_ARCHIVED` | 3 | Poll is no longer visible on the channel. |
| `POLL_STATUS_MODERATED` | 4 | Poll is no longer visible to any user on Twitch. |
| `POLL_STATUS_INVALID` | 5 | Something went wrong determining the state. |

## TwitchTask

*Inherits:* `RefCounted`

Every [`Twitch`](#twitch) API call returns a [`TwitchTask`](#twitchtask). Await its `completed` signal, or poll it from `Node._process()`:

```gdscript
# Await it:
var task := Twitch.get_my_user_info()
var user: TwitchUserInfo = await task.completed
if task.has_error():
    push_error(task.error)

# Or poll it:
func _process(_delta):
    if task.is_completed():
        print(task.result)
```

`completed` is always emitted from the frame loop, never from inside the call that created the task, so awaiting a task right after creating it is always safe. To await a task that may have completed a while ago, use `await task.wait()`.

If a task fails and nobody awaited it or looked at its error, a warning is printed when it's freed.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `error` | String | The error message, or an empty string. |
| `operation` | String | The name of the call. |
| `result` | Variant | The result, or `null`. |

### Methods

#### get_error()

```gdscript
func get_error() -> String
```

The error message, or an empty string if the call succeeded (or is still running).

#### get_operation()

```gdscript
func get_operation() -> String
```

The name of the call, for example `create_poll`.

#### get_result()

```gdscript
func get_result() -> Variant
```

The result: a typed object such as [`TwitchUserInfo`](#twitchuserinfo), or `null` for calls without a result, failed calls and calls that are still running.

#### has_error()

```gdscript
func has_error() -> bool
```

Whether the call has finished with an error.

#### is_completed()

```gdscript
func is_completed() -> bool
```

Whether the call has finished, successfully or not.

#### is_successful()

```gdscript
func is_successful() -> bool
```

Whether the call has finished successfully.

#### wait()

```gdscript
func wait() -> Variant
```

Returns `completed` while the task is running, or the result once it has completed and the signal has been emitted. `await task.wait()` therefore works no matter when it's called.

### Signals

#### completed

```gdscript
signal completed(result: Variant)
```

Emitted once when the call finishes. `result` is `null` if it failed; check `has_error()`.

## TwitchEventStream

*Inherits:* `RefCounted`

Created by `Twitch.subscribe_to_channel_follow_events()` and the other `subscribe_to_*_events` methods.

You can have several subscriptions to the same event type; each event is delivered to all of them. Events that arrive while nobody is waiting are buffered (up to 512), so read them regularly and `close()` the stream when you're done. Dropping the last reference closes it too.

```gdscript
var follows: TwitchEventStream = await Twitch.subscribe_to_channel_follow_events().completed

func _process(_delta):
    var event: TwitchChannelFollowEvent = follows.try_get_next_event()
    if event:
        print(event.user_display_name, " followed!")
```

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `kind` | Twitch.EventStreamKind | The event type. |

### Methods

#### close()

```gdscript
func close() -> void
```

Ends the subscription. Pending `wait_for_event()` calls fail.

#### get_desc()

```gdscript
func get_desc() -> TwitchEventStreamDesc
```

The core library's description of the subscription.

#### get_kind()

```gdscript
func get_kind() -> Twitch.EventStreamKind
```

The event type.

#### is_closed()

```gdscript
func is_closed() -> bool
```

Whether `close()` has been called.

#### try_get_next_event()

```gdscript
func try_get_next_event() -> Variant
```

Returns the next event if one has arrived, otherwise `null`. Handy from `Node._process()`. Use either this or `wait_for_event()` on a stream, not both.

#### wait_for_event()

```gdscript
func wait_for_event() -> TwitchTask
```

Resolves the next event (for example a [`TwitchChannelFollowEvent`](#twitchchannelfollowevent)). Concurrent waits are served oldest first. Waits until an event arrives, potentially forever; `close()` the stream to cancel.

## TwitchPoll

*Inherits:* `RefCounted`

Created by `Twitch.new_poll()`. `info` always holds the latest [`TwitchPollInfo`](#twitchpollinfo); it's a new object after every update. Updates arrive as viewers vote and when the poll ends.

```gdscript
var definition := TwitchPollDefinition.new()
definition.title = "Best engine?"
definition.choices = PackedStringArray(["Godot", "Unity", "Unreal"])
definition.duration = 60
var poll: TwitchPoll = await Twitch.new_poll(definition).completed
poll.updated.connect(func(info): print(info.choices))
var final: TwitchPollInfo = await poll.ended
```

Tracking stops automatically when the poll ends. Call `close()` to stop earlier.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `info` | TwitchPollInfo | The latest poll status. |

### Methods

#### close()

```gdscript
func close() -> void
```

Stops receiving updates for this poll (unsubscribes). Pending tasks fail.

#### delete_poll()

```gdscript
func delete_poll() -> TwitchTask
```

Ends the poll now without showing results to viewers. Resolves the updated [`TwitchPollInfo`](#twitchpollinfo).

#### finish_poll()

```gdscript
func finish_poll() -> TwitchTask
```

Ends the poll now and shows the results to viewers, as if it had timed out. Resolves the updated [`TwitchPollInfo`](#twitchpollinfo).

#### get_info()

```gdscript
func get_info() -> TwitchPollInfo
```

The latest poll status.

#### get_poll_ended()

```gdscript
func get_poll_ended() -> TwitchTask
```

Resolves (with the final [`TwitchPollInfo`](#twitchpollinfo)) once the poll has ended.

#### is_active()

```gdscript
func is_active() -> bool
```

Whether the poll is still running.

#### is_closed()

```gdscript
func is_closed() -> bool
```

Whether tracking has stopped.

#### wait_for_update()

```gdscript
func wait_for_update() -> TwitchTask
```

Resolves (with the new [`TwitchPollInfo`](#twitchpollinfo)) on the next update.

### Signals

#### ended

```gdscript
signal ended(info: TwitchPollInfo)
```

Emitted once when the poll ends, with the final status.

#### updated

```gdscript
signal updated(info: TwitchPollInfo)
```

Emitted on every update.

## TwitchPrediction

*Inherits:* `RefCounted`

Created by `Twitch.new_prediction()`. `info` always holds the latest [`TwitchPredictionInfo`](#twitchpredictioninfo). Once the prediction is locked (no more votes), resolve it to one of its outcomes:

```gdscript
var prediction: TwitchPrediction = await Twitch.new_prediction(definition).completed
await prediction.locked
await prediction.resolve(prediction.info.outcomes[0]).completed
```

Tracking stops automatically when the prediction is resolved or canceled. Call `close()` to stop earlier.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `info` | TwitchPredictionInfo | The latest prediction status. |

### Methods

#### cancel()

```gdscript
func cancel() -> TwitchTask
```

Ends the prediction without an outcome; viewers get their Channel Points back. Resolves the updated [`TwitchPredictionInfo`](#twitchpredictioninfo).

#### close()

```gdscript
func close() -> void
```

Stops receiving updates for this prediction (unsubscribes). Pending tasks fail.

#### get_info()

```gdscript
func get_info() -> TwitchPredictionInfo
```

The latest prediction status.

#### get_prediction_ended()

```gdscript
func get_prediction_ended() -> TwitchTask
```

Resolves (with the final [`TwitchPredictionInfo`](#twitchpredictioninfo)) once the prediction is resolved or canceled.

#### get_prediction_locked()

```gdscript
func get_prediction_locked() -> TwitchTask
```

Resolves once the prediction is locked.

#### is_closed()

```gdscript
func is_closed() -> bool
```

Whether tracking has stopped.

#### lock()

```gdscript
func lock() -> TwitchTask
```

Stops accepting votes now, as if the timer had expired.

#### resolve()

```gdscript
func resolve(winning_outcome: TwitchPredictionOutcome) -> TwitchTask
```

Resolves the prediction to the winning outcome (one of `TwitchPredictionInfo.outcomes`). Allowed before it's locked, too.

#### resolve_by_id()

```gdscript
func resolve_by_id(winning_outcome_id: String) -> TwitchTask
```

Resolves the prediction by outcome ID.

#### wait_for_update()

```gdscript
func wait_for_update() -> TwitchTask
```

Resolves (with the new [`TwitchPredictionInfo`](#twitchpredictioninfo)) on the next update.

### Signals

#### ended

```gdscript
signal ended(info: TwitchPredictionInfo)
```

Emitted once when the prediction is resolved or canceled.

#### locked

```gdscript
signal locked(info: TwitchPredictionInfo)
```

Emitted once when the prediction is locked.

#### updated

```gdscript
signal updated(info: TwitchPredictionInfo)
```

Emitted on every update.

# Data Classes

Requests and results. They are `Resource`s, so you can create them with `.new()`, edit them in the inspector and save them as `.tres` files. Every data class also has a `to_dictionary()` method that returns its values as a `Dictionary`.

## TwitchAuthenticationInfo

*Inherits:* `Resource`

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `uri` | String |  |
| `user_code` | String |  |

## TwitchAuthState

*Inherits:* `Resource`

The library's user authentication state.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `status` | Twitch.AuthStatus | The current authentication status. |
| `scopes` | PackedStringArray | If `status` is `Twitch.AUTH_STATUS_LOGGED_IN`, this is the set of available OAuth scopes. This may be smaller than the set of scopes you passed to `get_authentication_info()` if the user logged in with a previous version of your application. |

## TwitchBitsLeaderboard

*Inherits:* `Resource`

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `data` | Array[TwitchBitsLeaderboardEntry] | Entries on the Bits leaderboard, in no particular order. |
| `started_at` | String | Start of the date range for the returned data. |
| `ended_at` | String | End of the date range for the returned data. |

## TwitchBitsLeaderboardEntry

*Inherits:* `Resource`

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `user_id` | String | ID of the user (viewer) in the leaderboard entry. |
| `user_name` | String | Display name corresponding to `TwitchBitsLeaderboardEntry.user_id`. |
| `rank` | int | Leaderboard rank of the user. |
| `score` | int | Leaderboard score (number of Bits) of the user. |

## TwitchBitsLeaderboardRequest

*Inherits:* `Resource`

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `count` | int | Number of results to be returned. Maximum: 100. Default: 10. |
| `period` | String | Time period over which data is aggregated (PST time zone). This parameter interacts with `TwitchBitsLeaderboardRequest.started_at`. Default: `all`. Valid values:<br>`day` – 00:00:00 on the day specified in `TwitchBitsLeaderboardRequest.started_at`, through 00:00:00 on the following day.<br>`week` – 00:00:00 on Monday of the week specified in `TwitchBitsLeaderboardRequest.started_at`, through 00:00:00 on the following Monday.<br>`month` – 00:00:00 on the first day of the month specified in `TwitchBitsLeaderboardRequest.started_at`, through 00:00:00 on the first day of the following month.<br>`year` – 00:00:00 on the first day of the year specified in `TwitchBitsLeaderboardRequest.started_at`, through 00:00:00 on the first day of the following year.<br>`all` – The lifetime of the broadcaster's channel. If this is specified (or used by default), `TwitchBitsLeaderboardRequest.started_at` is ignored. |
| `started_at` | String | Timestamp for the period over which the returned data is aggregated. Must be in RFC 3339 format. If this is not provided, data is aggregated over the current period; e.g., the current day/week/month/year. This value is ignored if `TwitchBitsLeaderboardRequest.period` is `all`. Currently, the HH:MM:SS part of this value is used only to identify a given day in PST and otherwise ignored. For example, if the `TwitchBitsLeaderboardRequest.started_at` value resolves to 5PM PST yesterday and `TwitchBitsLeaderboardRequest.period` is `day`, data is returned for all of yesterday. |
| `user_id` | String | ID of the user whose results are returned; i.e., the person who paid for the Bits. As long as `TwitchBitsLeaderboardRequest.count` is greater than 1, the returned data includes additional users, with Bits amounts above and below the user specified by `TwitchBitsLeaderboardRequest.user_id`. If `TwitchBitsLeaderboardRequest.user_id` is not provided, the endpoint returns the Bits leaderboard data across top users (subject to the value of `TwitchBitsLeaderboardRequest.count`). |

## TwitchChannelCheerEvent

*Inherits:* `Resource`

A user cheers on the specified channel.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `is_anonymous` | bool | Whether the user cheered anonymously or not. |
| `user_id` | String | The user ID for the user who cheered on the specified channel. This is empty if `TwitchChannelCheerEvent.is_anonymous` is true. |
| `user_display_name` | String | The user display name for the user who cheered on the specified channel. This is empty if `TwitchChannelCheerEvent.is_anonymous` is true. |
| `message` | String | The message sent with the cheer. |
| `bits` | int | The number of Bits cheered. |

## TwitchChannelFollowEvent

*Inherits:* `Resource`

A specified channel receives a follow.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `user_id` | String | The user ID for the user now following the specified channel. |
| `user_display_name` | String | The user display name for the user now following the specified channel. |
| `followed_at` | String | RFC3339 timestamp of when the follow occurred. |

## TwitchChannelRaidEvent

*Inherits:* `Resource`

A broadcaster raids another broadcaster's channel.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `from_broadcaster_id` | String | The broadcaster ID that created the raid. |
| `from_broadcaster_name` | String | The broadcaster display name that created the raid. |
| `to_broadcaster_id` | String | The broadcaster ID that received the raid. |
| `to_broadcaster_name` | String | The broadcaster display name that received the raid. |
| `viewers` | int | The number of viewers in the raid. |

## TwitchChannelSubscribeEvent

*Inherits:* `Resource`

A notification when a specified channel receives a subscriber. This does not include resubscribes.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `user_id` | String | The user ID for the user who subscribed to the specified channel. |
| `user_login` | String | The user login for the user who subscribed to the specified channel. |
| `user_display_name` | String | The user display name for the user who subscribed to the specified channel. |
| `tier` | String | The tier of the subscription. Valid values are `1000`, `2000`, and `3000`. |
| `is_gift` | bool | Whether the subscription is a gift. |
| `cumulative_months` | int | The total number of months the user has been subscribed to the channel. Always 0, because this event doesn't include resubscriptions. |
| `streak_months` | int | The number of consecutive months the user's current subscription has been active. Always 0, because this event doesn't include resubscriptions. |
| `duration_months` | int | The month duration of the subscription. Always 0, because this event doesn't include resubscriptions. |

## TwitchClipInfo

*Inherits:* `Resource`

Describes a Clip.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `id` | String | ID of the clip being queried. |
| `url` | String | URL where the clip can be viewed. |
| `embed_url` | String | URL to embed the clip. |
| `created_at` | String | Date when the clip was created. |
| `thumbnail_url` | String | URL of the clip thumbnail. |
| `duration` | int | Duration of the Clip in seconds. |

## TwitchCustomRewardDefinition

*Inherits:* `Resource`

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `title` | String | The title of the reward. |
| `cost` | int | The cost of the reward. |
| `prompt` | String | Optional. The prompt for the viewer when redeeming the reward. |
| `is_enabled` | bool | Optional. Whether the reward is currently enabled. If `false`, the reward won't show up to viewers. Default: `true`. |
| `background_color` | String | Optional. Custom background color for the reward. Format: Hex with # prefix. Example: `#00E5CB`. |
| `is_user_input_required` | bool | Optional. Whether the user needs to enter information when redeeming the reward. |
| `is_max_per_stream_enabled` | bool | Optional. Whether a maximum per stream is enabled. |
| `max_per_stream` | int | Optional. The maximum number per stream if enabled. |
| `is_max_per_user_per_stream_enabled` | bool | Optional. Whether a maximum per user per stream is enabled. |
| `max_per_user_per_stream` | int | Optional. The maximum number per user per stream if enabled. |
| `is_global_cooldown_enabled` | bool | Optional. Whether a cooldown is enabled. |
| `global_cooldown_seconds` | int | Optional. The cooldown in seconds if enabled. |
| `should_redemptions_skip_request_queue` | bool | Optional. Whether redemptions should be set to `Twitch.CUSTOM_REWARD_REDEMPTION_STATE_FULFILLED` status immediately when redeemed and skip the request queue instead of the normal `Twitch.CUSTOM_REWARD_REDEMPTION_STATE_UNFULFILLED` status. |

## TwitchCustomRewardEvent

*Inherits:* `Resource`

A viewer has redeemed a custom Channel Points reward on the specified channel or the redemption has been updated (i.e., fulfilled or canceled).

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `redemption_id` | String | The redemption identifier. |
| `broadcaster_id` | String | The requested broadcaster ID. |
| `redeemer_id` | String | User ID of the user that redeemed the reward. |
| `broadcaster_name` | String | The requested broadcaster display name. |
| `redeemer_name` | String | Display name of the user that redeemed the reward. |
| `user_input` | String | The user input provided. Empty string if not provided. |
| `status` | Twitch.CustomRewardRedemptionState | Status of the redemption. If you resolve or cancel all redemptions from your code, you should discard all events of this type with a status other than `Twitch.CUSTOM_REWARD_REDEMPTION_STATE_UNFULFILLED`. |
| `custom_reward_id` | String | The reward identifier. |
| `custom_reward_title` | String | The reward name. |
| `custom_reward_cost` | int | The reward cost. |
| `custom_reward_prompt` | String | The reward description. |
| `redeemed_at` | String | RFC3339 timestamp of when the reward was redeemed. |

## TwitchCustomRewardList

*Inherits:* `Resource`

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `rewards` | Array[TwitchCustomRewardDefinition] |  |

## TwitchCustomRewardResolveRequest

*Inherits:* `Resource`

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `redemption_id` | String | ID of the Custom Reward Redemption to update. |
| `custom_reward_id` | String | ID of the Custom Reward the redemptions to be updated are for. |
| `broadcaster_id` | String |  |
| `resolution` | Twitch.CustomRewardRedemptionState | The new status to set redemptions to. Can be either `Twitch.CUSTOM_REWARD_REDEMPTION_STATE_FULFILLED` or `Twitch.CUSTOM_REWARD_REDEMPTION_STATE_CANCELED`. Specifying `Twitch.CUSTOM_REWARD_REDEMPTION_STATE_CANCELED` will refund the user their Channel Points. |

## TwitchDropEntitlement

*Inherits:* `Resource`

Describes a single Twitch Drop entitlement granted to the currently logged-in user.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `id` | String | Unique ID of the entitlement. Pass this to `Twitch.fulfill_drop_entitlements()` once the reward has been granted in-game. |
| `benefit_id` | String | ID of the reward benefit the user is entitled to. Use this to decide which in-game item to grant. |
| `timestamp` | String | RFC3339 timestamp of when the entitlement was granted. |
| `user_id` | String | Twitch user ID the entitlement belongs to (the currently logged-in user). |
| `game_id` | String | ID of the game (category) the entitlement is associated with. |
| `fulfillment_status` | Twitch.DropFulfillmentStatus | Current fulfillment status of the entitlement. |
| `last_updated` | String | RFC3339 timestamp of when the entitlement was last updated. |

## TwitchDropEntitlementList

*Inherits:* `Resource`

The result of a `Twitch.get_drop_entitlements()` query.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `entitlements` | Array[TwitchDropEntitlement] | The matching Drop entitlements for the logged-in user. |

## TwitchDropEntitlementQuery

*Inherits:* `Resource`

Parameters for querying the logged-in user's Twitch Drop entitlements.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `game_id` | String | Optional. Restrict results to entitlements for a specific game (category) ID. Leave empty to return entitlements across all of your games. |
| `fulfillment_status` | Twitch.DropFulfillmentStatus | Optional. Restrict results to entitlements with a specific fulfillment status (typically `Twitch.DROP_FULFILLMENT_STATUS_CLAIMED` to find rewards that still need granting). Leave as `Twitch.DROP_FULFILLMENT_STATUS_UNKNOWN` to return entitlements of any status. |

## TwitchEndPollRequest

*Inherits:* `Resource`

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `broadcaster_id` | String | ID of the broadcaster. |
| `poll_id` | String | ID of the poll. |
| `show_results` | bool | If `true`, sets the poll status to `Twitch.POLL_STATUS_TERMINATED` so that results are shown. If `false`, sets the poll status to `Twitch.POLL_STATUS_ARCHIVED` so that the poll is canceled immediately and no results are shown. |

## TwitchEndPredictionRequest

*Inherits:* `Resource`

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `broadcaster_id` | String | The broadcaster running prediction events. |
| `prediction_id` | String | ID of the Prediction. |
| `status` | Twitch.PredictionStatus | The Prediction status to be set. Valid values: `Twitch.PREDICTION_STATUS_LOCKED`, `Twitch.PREDICTION_STATUS_RESOLVED`, `Twitch.PREDICTION_STATUS_CANCELED` |
| `winning_outcome_id` | String | ID of the winning outcome for the Prediction, if `TwitchEndPredictionRequest.status` is being set to `Twitch.PREDICTION_STATUS_RESOLVED`. |

## TwitchEventStreamDesc

*Inherits:* `Resource`

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `kind` | Twitch.EventStreamKind |  |
| `token` | int | Opaque token identifying the subscription. Do not touch. |

## TwitchEventStreamRequest

*Inherits:* `Resource`

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `kind` | Twitch.EventStreamKind |  |

## TwitchFulfillDropEntitlementsRequest

*Inherits:* `Resource`

Request to mark one or more Drop entitlements as fulfilled.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `entitlement_ids` | PackedStringArray | The IDs of the entitlements to mark as `Twitch.DROP_FULFILLMENT_STATUS_FULFILLED`. |

## TwitchHypeTrainContribution

*Inherits:* `Resource`

Describes a contribution to a Hype Train.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `user_id` | String | The ID of the user who contributed to the Hype Train. |
| `user_name` | String | The display name of the user who contributed to the Hype Train. |
| `type` | Twitch.HypeTrainContributionType | Type of contribution. |
| `total` | int | The total contributed. |

## TwitchHypeTrainEvent

*Inherits:* `Resource`

A Hype Train makes progress on the user's channel. Requires the `channel:read:hype_train` scope.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `hype_train_id` | String | The Hype Train ID. |
| `broadcaster_id` | String | The requested broadcaster ID. |
| `broadcaster_name` | String | The requested broadcaster display name. |
| `level` | int | The current level of the Hype Train. |
| `total_points` | int | Total points contributed to the Hype Train. |
| `progress` | int | The number of points contributed to the Hype Train at the current level. Set to `-1` when the Hype Train is over. |
| `goal` | int | The number of points required to reach the next level. Set to `-1` when the Hype Train is over. |
| `started_at` | String | The time when the Hype Train started. |
| `expires_at` | String | The time when the Hype Train expires. The expiration is extended when the Hype Train reaches a new level. This is empty when the Hype Train is over. |
| `ended_at` | String | The time when the Hype Train ended. Empty if the Hype Train has not ended yet. |
| `cooldown_ends_at` | String | The time when the Hype Train cooldown ends so that the next Hype Train can start. Empty if the Hype Train has not ended yet. |
| `top_contributions` | Array[TwitchHypeTrainContribution] | The contributors with the most points contributed. Contains a maximum of two objects: one for the top Bits contributor and one for the top subscriptions contributor (this includes gifted subscriptions). |
| `last_contribution` | TwitchHypeTrainContribution | The most recent contribution. This is empty when the Hype Train is over. Version 2 of Twitch's Hype Train events (the only version Twitch still accepts) no longer reports it, so it is empty unless Twitch sends it. |

## TwitchModifyChannelInfoRequest

*Inherits:* `Resource`

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `game_id` | String | The current game ID being played on the channel. Use '0' to unset the game. |
| `language` | String | The language of the channel. A language value must be either the ISO 639-1 two-letter code for a supported stream language or 'other'. |
| `title` | String | The title of the stream. |
| `delay` | int | Stream delay in seconds. Stream delay is a Twitch Partner feature; trying to set this value for other account types will return a 400 error. Default: `-1`, which leaves the delay unchanged. |
| `tags` | PackedStringArray | A list of channel-defined tags to apply to the channel. Tags help identify the content that the channel streams. A channel may specify a maximum of 10 tags. Each tag is limited to a maximum of 25 characters and may not be an empty string or contain spaces or special characters. Tags are case insensitive. For readability, consider using camelCasing or PascalCasing. |
| `force_update_tags` | bool | If `TwitchModifyChannelInfoRequest.tags` is missing or empty, channel tags will not be altered by default (if `TwitchModifyChannelInfoRequest.force_update_tags` is false). If `TwitchModifyChannelInfoRequest.force_update_tags` is `true`, passing an empty (or missing) array `TwitchModifyChannelInfoRequest.tags` causes all tags to be removed from the channel. |

## TwitchPollChoiceInfo

*Inherits:* `Resource`

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `id` | String | ID for the choice. |
| `title` | String | Text displayed for the choice. |
| `votes` | int | Total number of votes received for the choice across all methods of voting. |
| `channel_points_votes` | int | Number of votes received via Channel Points. |

## TwitchPollDefinition

*Inherits:* `Resource`

Contains the information necessary to create a new poll.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `title` | String | Question displayed for the poll. |
| `choices` | PackedStringArray | Array of the poll choices. |
| `duration` | int | Total duration for the poll (in seconds). |
| `bits_voting_enabled` | bool | Indicates if Bits can be used for voting. |
| `bits_per_vote` | int | Number of Bits required to vote once with Bits. |
| `channel_points_voting_enabled` | bool | Indicates if Channel Points can be used for voting. |
| `channel_points_per_vote` | int | Number of Channel Points required to vote once with Channel Points. |

## TwitchPollInfo

*Inherits:* `Resource`

Describes a Poll on a Twitch channel.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `id` | String | ID of the poll. |
| `broadcaster_id` | String | ID of the broadcaster. |
| `title` | String | Question displayed for the poll. |
| `choices` | Array[TwitchPollChoiceInfo] | Array of the poll choices. |
| `channel_points_voting_enabled` | bool | Indicates if Channel Points can be used for voting. |
| `channel_points_per_vote` | int | Number of Channel Points required to vote once with Channel Points. |
| `status` | Twitch.PollStatus | Poll status. |
| `started_at` | String | UTC timestamp for the poll's start time. |
| `ended_at` | String | UTC timestamp for the poll's end time. Empty if the poll is still `Twitch.POLL_STATUS_ACTIVE`. |

## TwitchPredictionDefinition

*Inherits:* `Resource`

Contains the information necessary to create a new prediction.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `title` | String | Title for the Prediction. |
| `outcomes` | PackedStringArray | Array of outcome titles for the Prediction. Array size must be 2. The first outcome object is the 'blue' outcome and the second outcome object is the 'pink' outcome when viewing the Prediction on Twitch. |
| `duration` | int | Total duration for the Prediction (in seconds). Minimum: 1. Maximum: 1800. |

## TwitchPredictionInfo

*Inherits:* `Resource`

Describes a Channel Points Prediction on a Twitch channel.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `id` | String | ID of the Prediction. |
| `broadcaster_id` | String | ID of the broadcaster. |
| `title` | String | Title for the Prediction. |
| `winning_outcome_id` | String | ID of the winning outcome. If `TwitchPredictionInfo.status` is `Twitch.PREDICTION_STATUS_ACTIVE`, this is set to `null`. |
| `outcomes` | Array[TwitchPredictionOutcome] | Array of possible outcomes for the Prediction. |
| `status` | Twitch.PredictionStatus | Status of the Prediction. |
| `created_at` | String | UTC timestamp for the Prediction's start time. |
| `ended_at` | String | UTC timestamp for when the Prediction ended. If `TwitchPredictionInfo.status` is `Twitch.PREDICTION_STATUS_ACTIVE`, this is set to `null`. |
| `locked_at` | String | UTC timestamp for when the Prediction was locked. If `TwitchPredictionInfo.status` is `Twitch.PREDICTION_STATUS_ACTIVE`, this is set to `null`. |

## TwitchPredictionOutcome

*Inherits:* `Resource`

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `id` | String | ID for the outcome. |
| `title` | String | Text displayed for the outcome. |
| `users` | int | Number of unique users that chose the outcome. |
| `channel_points` | int | Number of Channel Points used for the outcome. |
| `color` | String | Color for the outcome. Valid values: BLUE, PINK |

## TwitchStreamInfo

*Inherits:* `Resource`

Describes an active stream on Twitch.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `id` | String | Stream ID. |
| `user_id` | String | ID of the user who is streaming. |
| `user_login` | String | Login of the user who is streaming. |
| `user_name` | String | Display name of the user who is streaming. |
| `game_id` | String | ID of the game being played on the stream. |
| `game_name` | String | Name of the game being played. |
| `type` | String | Stream type: "live" or "" (in case of error). |
| `title` | String | Stream title. |
| `viewer_count` | int | Number of viewers watching the stream at the time of the query. |
| `started_at` | String | UTC timestamp. |
| `language` | String | Stream language. A language value is either the ISO 639-1 two-letter code for a supported stream language or 'other'. |
| `thumbnail_url` | String | Thumbnail URL of the stream. All image URLs have variable width and height. You can replace `{width}` and `{height}` with any values to get that size image |
| `tags` | PackedStringArray | Shows tag IDs that apply to the stream. |
| `is_mature` | bool | Indicates if the broadcaster has specified their channel contains mature content that may be inappropriate for younger audiences. |

## TwitchStreamMarkerInfo

*Inherits:* `Resource`

Describes a Stream Marker.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `id` | String | Unique ID of the marker. |
| `created_at` | String | RFC3339 timestamp of the marker. |
| `description` | String | Description of the marker. |
| `position_seconds` | int | Relative offset (in seconds) of the marker, from the beginning of the stream. |

## TwitchStreamQuery

*Inherits:* `Resource`

Describes a query for streams. All fields are optional.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `after` | String | Cursor for forward pagination: tells the server where to start fetching the next set of results, in a multi-page response. The cursor value specified here is from the `pagination_cursor` response field of a prior query. |
| `first` | int | Maximum number of objects to return. Maximum: 100. Default: 20. |
| `game_ids` | PackedStringArray | Returns streams broadcasting a specified game ID. You can specify up to 100 IDs. |
| `languages` | PackedStringArray | Stream language. You can specify up to 100 languages. A language value must be either the ISO 639-1 two-letter code for a supported stream language or 'other'. |
| `user_ids` | PackedStringArray | Returns streams broadcast by one or more specified user IDs. You can specify up to 100 IDs. |
| `user_logins` | PackedStringArray | Returns streams broadcast by one or more specified user login names. You can specify up to 100 names. |

## TwitchStreamQueryResult

*Inherits:* `Resource`

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `streams` | Array[TwitchStreamInfo] | List of streams matching the query. |
| `pagination_cursor` | String | Pagination cursor to fetch the next page of results. May be empty if there are no further results. |

## TwitchUserInfo

*Inherits:* `Resource`

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `channel_id` | String | User's ID. |
| `login_name` | String | User's login name. |
| `display_name` | String | User's display name. |
| `user_type` | String | User's type: "staff", "admin", "global_mod", or "". |
| `broadcaster_type` | String | User's broadcaster type: "partner", "affiliate", or "". |
| `description` | String | User's channel description. |
| `profile_image_url` | String | URL of the user's profile image. |
| `offline_image_url` | String | URL of the user's offline image. |
| `view_count` | int | Total number of views of the user's channel. Twitch has deprecated this value, so it is usually 0. |
| `created_at` | String | Date when the user was created. |
| `email` | String | User's verified email address. Only available if you have the `user:read:email` scope. |

## TwitchUserSubscriptionCheckResult

*Inherits:* `Resource`

Describes a user's subscription to a specified channel.

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `tier` | String | Subscription tier. 1000 is tier 1, 2000 is tier 2, and 3000 is tier 3. |
| `gifter_login` | String | Login of the gifter (if `TwitchUserSubscriptionCheckResult.is_gift` is `true`). |
| `gifter_name` | String | Display name of the gifter (if `TwitchUserSubscriptionCheckResult.is_gift` is `true`). |
| `is_gift` | bool | Indicates if the subscription is a gift. |
| `is_subscribed` | bool | Indicates if the user is subscribed at all. If this is `false`, all other fields are empty. |

# C# API

Godot doesn't generate C# bindings for GDExtension classes, so the addon ships typed wrappers in `addons/twitchsdk/csharp`, in the `TwitchSDK` namespace. They need the .NET edition of Godot, and Godot compiles them as part of your project.

The wrappers mirror the GDScript API with C# naming:

| GDScript | C# |
| --- | --- |
| `Twitch.get_my_user_info()` | `Twitch.GetMyUserInfo()` |
| `TwitchTask` | `TwitchTask` and `TwitchTask<T>`, which are awaitable |
| `task.has_error()` / `task.error` | `task.Exception` (a `TwitchException`), or a thrown `TwitchException` when awaiting |
| `TwitchEventStream` | `EventStream<T>` |
| `stream.close()` | `stream.Dispose()` |
| Signals such as `TwitchPoll.updated` | C# events such as `TwitchPoll.Updated` |
| `Twitch.log_message` | `Twitch.LogMessage` |
| `Twitch.OAUTH_SCOPE_CHANNEL_MANAGE_POLLS` | `OAuthScope.ChannelManagePolls` |
| `Twitch.AUTH_STATUS_LOGGED_IN` | `AuthStatus.LoggedIn` |
| `TwitchUserInfo.display_name` | `TwitchUserInfo.DisplayName` |
| `PackedStringArray`, `Array[TwitchPollChoiceInfo]` | `string[]`, `TwitchPollChoiceInfo[]` |

## Twitch (C#)

The Twitch API. Wraps the native `Twitch` singleton.

### Syntax

```cs
public static partial class Twitch
```

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `ClientId` | string | The Client ID in use (from the `twitch/auth/client_id` project setting). Setting it starts the plugin if needed, or switches the Client ID at runtime for development and samples. It doesn't change the project setting. |
| `IsInitialized` | bool | Whether the plugin is running. |
| `Native` | GodotObject | The native `Twitch` singleton. Throws `InvalidOperationException` if the GDExtension isn't loaded. |
| `PluginVersion` | string | The plugin version, for example `2.1`. |
| `UseEventSubProxy` | bool | Whether the plugin connects to a local EventSub test proxy. Never enable this in releases. |
| `Version` | string | The core library's version string, for example `2.1-<build>`. |

### Events

#### LogMessage

Raised for every message the core library logs, on the main thread. The messages are also printed to Godot's output.

```cs
public static event Action<LogLevel, string> LogMessage;
```

### Methods

Every method corresponds to the GDScript method of the same name in snake_case; see [Twitch](#twitch) above for details.

| Method | Returns |
| --- | --- |
| `BuildOAuthScopes(IEnumerable<OAuthScope> scopes, IEnumerable<string> customScopes = null)` | string |
| `CheckUserSubscription(string broadcasterId)` | TwitchTask\<TwitchUserSubscriptionCheckResult> |
| `CloseEventStream(TwitchEventStreamDesc eventStreamDesc)` | TwitchTask |
| `CreateClip(bool hasDelay)` | TwitchTask\<TwitchClipInfo> |
| `CreatePoll(TwitchPollDefinition pollDefinition)` | TwitchTask\<TwitchPollInfo> |
| `CreatePrediction(TwitchPredictionDefinition predictionDefinition)` | TwitchTask\<TwitchPredictionInfo> |
| `CreateStreamMarker(string description)` | TwitchTask\<TwitchStreamMarkerInfo> |
| `EndPoll(TwitchEndPollRequest endPollRequest)` | TwitchTask\<TwitchPollInfo> |
| `EndPrediction(TwitchEndPredictionRequest endPredictionRequest)` | TwitchTask\<TwitchPredictionInfo> |
| `FulfillDropEntitlements(string[] entitlementIds)` | TwitchTask |
| `FulfillDropEntitlements(params TwitchDropEntitlement[] entitlements)` | TwitchTask |
| `GetAuthenticationInfo(params OAuthScope[] scopes)` | TwitchTask\<TwitchAuthenticationInfo> |
| `GetAuthenticationInfo(IEnumerable<OAuthScope> scopes, IEnumerable<string> customScopes)` | TwitchTask\<TwitchAuthenticationInfo> |
| `GetAuthState()` | TwitchTask\<TwitchAuthState> |
| `GetBitsLeaderboard(TwitchBitsLeaderboardRequest bitsLeaderboardRequest)` | TwitchTask\<TwitchBitsLeaderboard> |
| `GetDropEntitlements(string gameId = null, DropFulfillmentStatus fulfillmentStatus = DropFulfillmentStatus.Claimed)` | TwitchTask\<TwitchDropEntitlementList> |
| `GetMyStreamInfo()` | TwitchTask\<TwitchStreamInfo> |
| `GetMyUserInfo()` | TwitchTask\<TwitchUserInfo> |
| `GetStreamInfoById(string channelId)` | TwitchTask\<TwitchStreamInfo> |
| `GetUserInfoById(string id)` | TwitchTask\<TwitchUserInfo> |
| `GetUserInfoByLoginName(string login)` | TwitchTask\<TwitchUserInfo> |
| `Initialize()` | bool |
| `LogOut()` | TwitchTask |
| `ModifyChannelInformation(TwitchModifyChannelInfoRequest modifyChannelInfoRequest)` | TwitchTask |
| `NewPoll(TwitchPollDefinition definition)` | TwitchTask\<TwitchPoll> |
| `NewPrediction(TwitchPredictionDefinition definition)` | TwitchTask\<TwitchPrediction> |
| `PrepareShutdown()` | TwitchTask |
| `QueryStreams(TwitchStreamQuery streamQuery)` | TwitchTask\<TwitchStreamQueryResult> |
| `ReplaceCustomRewards(TwitchCustomRewardDefinition[] rewards)` | TwitchTask |
| `ResolveCustomReward(TwitchCustomRewardEvent e, CustomRewardRedemptionState resolution)` | TwitchTask |
| `ResolveCustomReward(TwitchCustomRewardResolveRequest customRewardResolveRequest)` | TwitchTask |
| `ScopeString(this OAuthScope scope)` | string |
| `Shutdown()` | void |
| `SubscribeToChannelCheerEvents()` | TwitchTask\<EventStream\<TwitchChannelCheerEvent>> |
| `SubscribeToChannelFollowEvents()` | TwitchTask\<EventStream\<TwitchChannelFollowEvent>> |
| `SubscribeToChannelRaidEvents()` | TwitchTask\<EventStream\<TwitchChannelRaidEvent>> |
| `SubscribeToChannelSubscribeEvents()` | TwitchTask\<EventStream\<TwitchChannelSubscribeEvent>> |
| `SubscribeToCustomRewardEvents()` | TwitchTask\<EventStream\<TwitchCustomRewardEvent>> |
| `SubscribeToEventStream(EventStreamKind kind)` | TwitchTask\<TwitchEventStreamDesc> |
| `SubscribeToHypeTrainEvents()` | TwitchTask\<EventStream\<TwitchHypeTrainEvent>> |
| `UnsubscribeFromPoll(string id)` | TwitchTask |
| `UnsubscribeFromPrediction(string id)` | TwitchTask |
| `WaitForChannelCheerEvent(TwitchEventStreamDesc eventStreamDesc)` | TwitchTask\<TwitchChannelCheerEvent> |
| `WaitForChannelFollowEvent(TwitchEventStreamDesc eventStreamDesc)` | TwitchTask\<TwitchChannelFollowEvent> |
| `WaitForChannelRaidEvent(TwitchEventStreamDesc eventStreamDesc)` | TwitchTask\<TwitchChannelRaidEvent> |
| `WaitForChannelSubscribeEvent(TwitchEventStreamDesc eventStreamDesc)` | TwitchTask\<TwitchChannelSubscribeEvent> |
| `WaitForCustomRewardEvent(TwitchEventStreamDesc eventStreamDesc)` | TwitchTask\<TwitchCustomRewardEvent> |
| `WaitForHypeTrainEvent(TwitchEventStreamDesc eventStreamDesc)` | TwitchTask\<TwitchHypeTrainEvent> |
| `WaitForPollUpdate(string poll)` | TwitchTask\<TwitchPollInfo> |
| `WaitForPredictionUpdate(string prediction)` | TwitchTask\<TwitchPredictionInfo> |

`GetAuthenticationInfo` resolves `null` if the user is already logged in. Calls within 0.25 seconds of each other return the same task. `CheckUserSubscription` results are cached for 15 seconds per broadcaster. `GetStreamInfoById` resolves `null` if the channel is offline or doesn't exist.

## TwitchTask (C#)

The result of an asynchronous Twitch API call, the counterpart of the Unity plugin's `GameTask`. Await it, or check `IsCompleted` from `_Process`. Wraps the native `TwitchTask`.

### Syntax

```cs
public class TwitchTask
public class TwitchTask<T> : TwitchTask
```

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `Error` | string | The error message, or an empty string. |
| `Exception` | TwitchException | The error as an exception, or `null`. |
| `HasError` | bool | Whether the call has finished with an error. |
| `IsCompleted` | bool | Whether the call has finished (successfully or not). |
| `IsSuccessful` | bool | Whether the call has finished successfully. |
| `MaybeResult` | T | `TwitchTask<T>` only. The result if the call has finished successfully, otherwise the default value. Never throws. |
| `Native` | GodotObject | The native `TwitchTask` object. |
| `Operation` | string | The operation name, for example `create_poll`. |
| `Result` | T | `TwitchTask<T>` only. The result. Throws `InvalidOperationException` if the call is still pending, and the `TwitchException` if it failed. |

### Methods

| Method | Returns | Description |
| --- | --- | --- |
| `AsTask()` | Task, or Task\<T> for `TwitchTask<T>` | A .NET `Task` that completes with the result, or faults with a `TwitchException`. |
| `GetAwaiter()` | TaskAwaiter, or TaskAwaiter\<T> for `TwitchTask<T>` | Makes the task awaitable. |

## TwitchException

A Twitch API call failed.

### Syntax

```cs
public class TwitchException : Exception
```

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `Message` | string | The error message. |
| `Operation` | string | The operation that failed, for example `create_poll`. |

## EventStream\<T>

An active EventSub subscription. Read events regularly (they're buffered, up to 512), and `Dispose()` it when you're done. Wraps the native `TwitchEventStream`.

### Syntax

```cs
public sealed class EventStream<T> : IDisposable
```

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `IsClosed` | bool | Whether the subscription has been closed. |
| `Kind` | EventStreamKind | The event type. |
| `Native` | GodotObject | The native `TwitchEventStream` object. |

### Methods

| Method | Returns | Description |
| --- | --- | --- |
| `Dispose()` | void | Closes the subscription. A pending `WaitForEvent()` then fails. |
| `TryGetNextEvent(out T result)` | bool | Returns a waiting event, if there is one. Handy from `_Process`. Use either this or `WaitForEvent()` on a stream, not both. |
| `WaitForEvent()` | TwitchTask\<T> | Wait for the next event. Concurrent waits are served oldest first. |

## TwitchPoll (C#)

A poll that keeps itself up to date, the counterpart of the Unity plugin's `Poll`. Wraps the native [`TwitchPoll`](#twitchpoll).

### Syntax

```cs
public sealed class TwitchPoll : IDisposable
```

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `Info` | TwitchPollInfo | The latest poll status (a new object after every update). |
| `IsActive` | bool | Whether the poll is still running. |
| `PollEnded` | TwitchTask\<TwitchPollInfo> | Resolves once the poll has ended. |

### Events

| Event | Type | Description |
| --- | --- | --- |
| `Ended` | Action\<TwitchPollInfo> | Raised once the poll has ended. |
| `Updated` | Action\<TwitchPollInfo> | Raised on every update with the new info. |

### Methods

| Method | Returns | Description |
| --- | --- | --- |
| `DeletePoll()` | TwitchTask\<TwitchPollInfo> | End the poll now without showing results. |
| `Dispose()` | void | Stop tracking the poll. |
| `FinishPoll()` | TwitchTask\<TwitchPollInfo> | End the poll now and show the results. |
| `WaitForUpdate()` | TwitchTask\<TwitchPollInfo> | Wait for the poll state to update. |

## TwitchPrediction (C#)

A prediction that keeps itself up to date, the counterpart of the Unity plugin's `Prediction`. Wraps the native [`TwitchPrediction`](#twitchprediction).

### Syntax

```cs
public sealed class TwitchPrediction : IDisposable
```

### Properties

| Property | Type | Description |
| --- | --- | --- |
| `Info` | TwitchPredictionInfo | The latest prediction status (a new object after every update). |
| `PredictionEnded` | TwitchTask\<TwitchPredictionInfo> | Resolves once the prediction is resolved or canceled. |
| `PredictionLocked` | TwitchTask\<TwitchPredictionInfo> | Resolves once the prediction is locked. |

### Events

| Event | Type | Description |
| --- | --- | --- |
| `Ended` | Action\<TwitchPredictionInfo> | Raised once the prediction is resolved or canceled. |
| `Locked` | Action\<TwitchPredictionInfo> | Raised once the prediction is locked; resolve it then. |
| `Updated` | Action\<TwitchPredictionInfo> | Raised on every update with the new info. |

### Methods

| Method | Returns | Description |
| --- | --- | --- |
| `Cancel()` | TwitchTask\<TwitchPredictionInfo> | Cancel the prediction; viewers get their Channel Points back. |
| `Dispose()` | void | Stop tracking the prediction. |
| `Lock()` | TwitchTask\<TwitchPredictionInfo> | Stop accepting votes now. |
| `Resolve(TwitchPredictionOutcome outcome)` | TwitchTask\<TwitchPredictionInfo> | Resolve the prediction to the winning outcome. |
| `Resolve(string outcomeId)` | TwitchTask\<TwitchPredictionInfo> | Resolve the prediction by outcome ID. |
| `WaitForUpdate()` | TwitchTask\<TwitchPredictionInfo> | Wait for the prediction status to update. |

## OAuthScope

OAuth scopes used by the API, the counterpart of the Unity plugin's `TwitchOAuthScope`. Get the scope string with `scope.ScopeString()`.

### Syntax

```cs
public enum OAuthScope : long
```

| Value | Scope string |
| --- | --- |
| `ChannelManagePolls` | `channel:manage:polls` |
| `ChannelManagePredictions` | `channel:manage:predictions` |
| `ChannelManageBroadcast` | `channel:manage:broadcast` |
| `ChannelManageRedemptions` | `channel:manage:redemptions` |
| `ChannelReadHypeTrain` | `channel:read:hype_train` |
| `ClipsEdit` | `clips:edit` |
| `UserReadSubscriptions` | `user:read:subscriptions` |
| `BitsRead` | `bits:read` |

## Other enums (C#)

The other enums have the same values as their GDScript counterparts, with PascalCase names. Their underlying type is `long`.

| Enum | Values |
| --- | --- |
| `AuthStatus` | `LoggedOut`, `Loading`, `WaitingForCode`, `LoggedIn` |
| `CustomRewardRedemptionState` | `Unknown`, `Unfulfilled`, `Fulfilled`, `Canceled` |
| `DropFulfillmentStatus` | `Unknown`, `Claimed`, `Fulfilled` |
| `EventStreamKind` | `Subscription`, `Follower`, `Cheer`, `CustomRewardRedemption`, `HypeTrain`, `ChannelRaid` |
| `HypeTrainContributionType` | `Bits`, `Subscription`, `Other` |
| `LogLevel` | `Debug`, `Info`, `Warning`, `Error` |
| `PollStatus` | `Active`, `Completed`, `Terminated`, `Archived`, `Moderated`, `Invalid` |
| `PredictionStatus` | `Active`, `Locked`, `Resolved`, `Canceled` |

## Data classes (C#)

The C# data classes have the same names and properties as the [GDScript data classes](#data-classes), with PascalCase property names (for example `TwitchUserInfo.DisplayName`). Typed arrays and `PackedStringArray`s become C# arrays, and enum properties use the C# enums. Strings default to `""` and arrays to empty arrays; the other defaults match GDScript, for example `TwitchCustomRewardDefinition.IsEnabled` is `true` and `TwitchModifyChannelInfoRequest.Delay` is `-1`.

They are plain C# classes, not Godot `Resource`s. Results are snapshots, so changing them doesn't change anything in the plugin. Each class has these conversion helpers:

| Method | Description |
| --- | --- |
| `static T FromNative(Variant v)` | Converts a native object, as returned by the GDExtension, to this class. Returns `null` for `null`. |
| `static GodotObject ToNative(T value)` | Converts this class to the native `Resource`. |
