Base EventSub Client#
Note
This is the base class used for all EventSub Transport implementations.
See EventSub for a list of all available Transports.
Class Documentation#
- class twitchAPI.eventsub.base.EventSubBase#
Bases:
ABC
EventSub integration for the Twitch Helix API.
- __init__(twitch)#
- Parameters:
twitch¶ (
Default:) – a app authenticated instance ofTwitch
-
logger: Default:#
The logger used for EventSub related log messages
- abstract start()#
Starts the EventSub client
- Return type:
None
- Raises:
RuntimeError – if EventSub is already running
- abstract async stop()#
Stops the EventSub client
This also unsubscribes from all known subscriptions if unsubscribe_on_stop is True
- Return type:
None
- async unsubscribe_all()#
Unsubscribe from all subscriptions
- async unsubscribe_all_known()#
Unsubscribe from all subscriptions known to this client.
- async unsubscribe_topic(topic_id)#
- Return type:
- Default:
Unsubscribe from a specific topic.
- async listen_channel_update(broadcaster_user_id, callback)#
A broadcaster updates their channel properties e.g., category, title, mature flag, broadcast, or language.
No Authentication required.
For more information see here: https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types#channelupdate
- Parameters:
broadcaster_user_id¶ (
Default:) – the id of the user you want to listen tocallback¶ (
Default:) – function for callback- Raises:
EventSubSubscriptionConflict – if a conflict was found with this subscription (e.g. already subscribed to this exact topic)
EventSubSubscriptionTimeout – if
wait_for_subscription_confirm
is true and the subscription was not fully confirmed in timeEventSubSubscriptionError – if the subscription failed (see error message for details)
TwitchBackendException – if the subscription failed due to a twitch backend error
- Return type:
Default:- async listen_channel_update_v2(broadcaster_user_id, callback)#
A broadcaster updates their channel properties e.g., category, title, content classification labels or language.
No Authentication required.
For more information see here: https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types#channelupdate
- Parameters:
broadcaster_user_id¶ (
Default:) – the id of the user you want to listen tocallback¶ (
Default:) – function for callback- Raises:
EventSubSubscriptionConflict – if a conflict was found with this subscription (e.g. already subscribed to this exact topic)
EventSubSubscriptionTimeout – if
wait_for_subscription_confirm
is true and the subscription was not fully confirmed in timeEventSubSubscriptionError – if the subscription failed (see error message for details)
TwitchBackendException – if the subscription failed due to a twitch backend error
- Return type:
Default:- async listen_channel_follow_v2(broadcaster_user_id, moderator_user_id, callback)#
A specified channel receives a follow.
User Authentication with
MODERATOR_READ_FOLLOWERS
is required.For more information see here: https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types#channelfollow
- Parameters:
broadcaster_user_id¶ (
Default:) – the id of the user you want to listen tomoderator_user_id¶ (
Default:) – The ID of the moderator of the channel you want to get follow notifications for.callback¶ (
Default:) – function for callback- Raises:
EventSubSubscriptionConflict – if a conflict was found with this subscription (e.g. already subscribed to this exact topic)
EventSubSubscriptionTimeout – if
wait_for_subscription_confirm
is true and the subscription was not fully confirmed in timeEventSubSubscriptionError – if the subscription failed (see error message for details)
TwitchBackendException – if the subscription failed due to a twitch backend error
- Return type:
Default:- async listen_channel_subscribe(broadcaster_user_id, callback)#
A notification when a specified channel receives a subscriber. This does not include resubscribes.
User Authentication with
CHANNEL_READ_SUBSCRIPTIONS
is required.For more information see here: https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types#channelsubscribe
- Parameters:
broadcaster_user_id¶ (
Default:) – the id of the user you want to listen tocallback¶ (
Default:) – function for callback- Raises:
EventSubSubscriptionConflict – if a conflict was found with this subscription (e.g. already subscribed to this exact topic)
EventSubSubscriptionTimeout – if
wait_for_subscription_confirm
is true and the subscription was not fully confirmed in timeEventSubSubscriptionError – if the subscription failed (see error message for details)
TwitchBackendException – if the subscription failed due to a twitch backend error
- Return type:
Default:- async listen_channel_subscription_end(broadcaster_user_id, callback)#
A notification when a subscription to the specified channel ends.
User Authentication with
CHANNEL_READ_SUBSCRIPTIONS
is required.For more information see here: https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types#channelsubscriptionend
- Parameters:
broadcaster_user_id¶ (
Default:) – the id of the user you want to listen tocallback¶ (
Default:) – function for callback- Raises:
EventSubSubscriptionConflict – if a conflict was found with this subscription (e.g. already subscribed to this exact topic)
EventSubSubscriptionTimeout – if
wait_for_subscription_confirm
is true and the subscription was not fully confirmed in timeEventSubSubscriptionError – if the subscription failed (see error message for details)
TwitchBackendException – if the subscription failed due to a twitch backend error
- Return type:
Default:- async listen_channel_subscription_gift(broadcaster_user_id, callback)#
A notification when a viewer gives a gift subscription to one or more users in the specified channel.
User Authentication with
CHANNEL_READ_SUBSCRIPTIONS
is required.For more information see here: https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types#channelsubscriptiongift
- Parameters:
broadcaster_user_id¶ (
Default:) – the id of the user you want to listen tocallback¶ (
Default:) – function for callback- Raises:
EventSubSubscriptionConflict – if a conflict was found with this subscription (e.g. already subscribed to this exact topic)
EventSubSubscriptionTimeout – if
wait_for_subscription_confirm
is true and the subscription was not fully confirmed in timeEventSubSubscriptionError – if the subscription failed (see error message for details)
TwitchBackendException – if the subscription failed due to a twitch backend error
- Return type:
Default:- async listen_channel_subscription_message(broadcaster_user_id, callback)#
A notification when a user sends a resubscription chat message in a specific channel.
User Authentication with
CHANNEL_READ_SUBSCRIPTIONS
is required.For more information see here: https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types#channelsubscriptionmessage
- Parameters:
broadcaster_user_id¶ (
Default:) – the id of the user you want to listen tocallback¶ (
Default:) – function for callback- Raises:
EventSubSubscriptionConflict – if a conflict was found with this subscription (e.g. already subscribed to this exact topic)
EventSubSubscriptionTimeout – if
wait_for_subscription_confirm
is true and the subscription was not fully confirmed in timeEventSubSubscriptionError – if the subscription failed (see error message for details)
TwitchBackendException – if the subscription failed due to a twitch backend error
- Return type:
Default:- async listen_channel_cheer(broadcaster_user_id, callback)#
A user cheers on the specified channel.
User Authentication with
BITS_READ
is required.For more information see here: https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types#channelcheer
- Parameters:
broadcaster_user_id¶ (
Default:) – the id of the user you want to listen tocallback¶ (
Default:) – function for callback- Raises:
EventSubSubscriptionConflict – if a conflict was found with this subscription (e.g. already subscribed to this exact topic)
EventSubSubscriptionTimeout – if
wait_for_subscription_confirm
is true and the subscription was not fully confirmed in timeEventSubSubscriptionError – if the subscription failed (see error message for details)
TwitchBackendException – if the subscription failed due to a twitch backend error
- Return type:
Default:- async listen_channel_raid(callback, to_broadcaster_user_id=None, from_broadcaster_user_id=None)#
A broadcaster raids another broadcaster’s channel.
No authorization required.
For more information see here: https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types#channelraid
- Parameters:
from_broadcaster_user_id¶ (
Default:) – The broadcaster user ID that created the channel raid you want to get notifications for.to_broadcaster_user_id¶ (
Default:) – The broadcaster user ID that received the channel raid you want to get notifications for.callback¶ (
Default:) – function for callback- Raises:
EventSubSubscriptionConflict – if a conflict was found with this subscription (e.g. already subscribed to this exact topic)
EventSubSubscriptionTimeout – if
wait_for_subscription_confirm
is true and the subscription was not fully confirmed in timeEventSubSubscriptionError – if the subscription failed (see error message for details)
TwitchBackendException – if the subscription failed due to a twitch backend error
- Return type:
Default:- async listen_channel_ban(broadcaster_user_id, callback)#
A viewer is banned from the specified channel.
User Authentication with
CHANNEL_MODERATE
is required.For more information see here: https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types#channelban
- Parameters:
broadcaster_user_id¶ (
Default:) – the id of the user you want to listen tocallback¶ (
Default:) – function for callback- Raises:
EventSubSubscriptionConflict – if a conflict was found with this subscription (e.g. already subscribed to this exact topic)
EventSubSubscriptionTimeout – if
wait_for_subscription_confirm
is true and the subscription was not fully confirmed in timeEventSubSubscriptionError – if the subscription failed (see error message for details)
TwitchBackendException – if the subscription failed due to a twitch backend error
- Return type:
Default:- async listen_channel_unban(broadcaster_user_id, callback)#
A viewer is unbanned from the specified channel.
User Authentication with
CHANNEL_MODERATE
is required.For more information see here: https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types#channelunban
- Parameters:
broadcaster_user_id¶ (
Default:) – the id of the user you want to listen tocallback¶ (
Default:) – function for callback- Raises:
EventSubSubscriptionConflict – if a conflict was found with this subscription (e.g. already subscribed to this exact topic)
EventSubSubscriptionTimeout – if
wait_for_subscription_confirm
is true and the subscription was not fully confirmed in timeEventSubSubscriptionError – if the subscription failed (see error message for details)
TwitchBackendException – if the subscription failed due to a twitch backend error
- Return type:
Default:- async listen_channel_moderator_add(broadcaster_user_id, callback)#
Moderator privileges were added to a user on a specified channel.
User Authentication with
MODERATION_READ
is required.For more information see here: https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types#channelmoderatoradd
- Parameters:
broadcaster_user_id¶ (
Default:) – the id of the user you want to listen tocallback¶ (
Default:) – function for callback- Raises:
EventSubSubscriptionConflict – if a conflict was found with this subscription (e.g. already subscribed to this exact topic)
EventSubSubscriptionTimeout – if
wait_for_subscription_confirm
is true and the subscription was not fully confirmed in timeEventSubSubscriptionError – if the subscription failed (see error message for details)
TwitchBackendException – if the subscription failed due to a twitch backend error
- Return type:
Default:- async listen_channel_moderator_remove(broadcaster_user_id, callback)#
Moderator privileges were removed from a user on a specified channel.
User Authentication with
MODERATION_READ
is required.For more information see here: https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types#channelmoderatorremove
-
logger: