KickEventsRequests

Inherits: KickRequestBase < RefCounted < Object

Handles Kick API requests related to event subscriptions (webhooks).

Description

KickEventsRequests provides methods for managing event subscriptions to receive webhooks from the Kick API.

Access this handler through KickAPI.get_events().

func _ready():
    KickAPI.configure("your_token")
    KickAPI.request_completed.connect(_on_request_completed)

    # Get current subscriptions
    KickAPI.get_events().get_subscriptions()

    # Create new subscriptions
    var events = [
        {"name": "stream.online", "version": 1},
        {"name": "channel.update", "version": 1},
        {"name": "chat.message", "version": 1}
    ]
    KickAPI.get_events().create_subscriptions(events, "webhook", 12345)

    # Delete a subscription
    KickAPI.get_events().delete_subscription("sub_abc123xyz")

func _on_request_completed(signal_name: String, response_code: int, data: Dictionary):
    if signal_name == "event_subscriptions_received":
        # Output:
        # {
        #   "data": [
        #     {
        #       "id": "sub_abc123",
        #       "app_id": "app_xyz789",
        #       "broadcaster_user_id": 12345,
        #       "event": "stream.online",
        #       "method": "webhook",
        #       "version": 1,
        #       "created_at": "2024-01-15T12:00:00Z",
        #       "updated_at": "2024-01-15T12:00:00Z"
        #     }
        #   ],
        #   "message": "success"
        # }
        print("Active subscriptions: ", data["data"].size())
        for sub in data["data"]:
            print("  ", sub["event"], " - ", sub["id"])

    elif signal_name == "event_subscriptions_created":
        # Output:
        # {
        #   "data": [
        #     {
        #       "name": "stream.online",
        #       "version": 1,
        #       "subscription_id": "sub_new123",
        #       "error": ""
        #     },
        #     ...
        #   ],
        #   "message": "success"
        # }
        for result in data["data"]:
            if result["error"].is_empty():
                print("Created: ", result["name"], " - ", result["subscription_id"])
            else:
                print("Failed: ", result["name"], " - ", result["error"])

    elif signal_name == "event_subscription_deleted":
        print("Subscription deleted successfully!") # Response code: 204

Tutorials

Methods

void

create_subscriptions(events: Array, method: String = "webhook", broadcaster_user_id: int = 0)

void

delete_subscription(subscription_id: String)

void

get_subscriptions()


Method Descriptions

void create_subscriptions(events: Array, method: String = "webhook", broadcaster_user_id: int = 0) 🔗

Creates one or more event subscriptions. The events array should contain dictionaries with name and version fields.

Currently only "webhook" method is supported.

Optionally provide broadcaster_user_id to subscribe to events for a specific broadcaster.

Results are returned via the KickAPI.request_completed signal with signal_name "event_subscriptions_created".


void delete_subscription(subscription_id: String) 🔗

Deletes a specific event subscription by its ID.

Results are returned via the KickAPI.request_completed signal with signal_name "event_subscription_deleted".


void get_subscriptions() 🔗

Retrieves all event subscriptions for your application.

Results are returned via the KickAPI.request_completed signal with signal_name "event_subscriptions_received".