KickAPI
Inherits: Object
Singleton for interacting with the Kick Developer Public API.
Description
KickAPI is a singleton that provides access to the Kick streaming platform API. It handles authentication, rate limiting, and provides organized access to different API endpoints through category-specific request handlers.
extends Node
func _ready():
# Configure the API with your access token
KickAPI.configure("your_access_token_here")
# Connect to the request completed signal
KickAPI.request_completed.connect(_on_request_completed)
KickAPI.request_failed.connect(_on_request_failed)
KickAPI.rate_limit_warning.connect(_on_rate_limit_warning)
# Get user information
KickAPI.get_users().get_users({"username": ["streamer_name"]})
func _on_request_completed(signal_name: String, response_code: int, data: Dictionary):
if signal_name == "users_received":
print("Response code: ", response_code) # 200
print("User data: ", data)
# Output:
# {
# "data": [
# {
# "user_id": 12345,
# "name": "streamer_name",
# "email": "[email protected]",
# "profile_picture": "https://..."
# }
# ],
# "message": "success"
# }
func _on_request_failed(signal_name: String, error_code: int, message: String):
printerr("Request failed: ", signal_name, " Error: ", error_code, " - ", message)
func _on_rate_limit_warning(remaining: int, reset_time: int):
print("Rate limit warning: ", remaining, " requests remaining until ", reset_time)
The API automatically polls for responses each frame. You can also manually call poll() if needed.
Tutorials
Methods
void |
|
get_chat() |
|
get_http_client() const |
|
get_rate_limit_remaining() const |
|
get_rate_limit_reset() const |
|
is_busy() const |
|
void |
poll() |
query_string_from_dict(params: Dictionary) const |
|
void |
set_access_token(token: String) |
Signals
rate_limit_warning(remaining: int, reset_time: int) 🔗
Emitted when the API is approaching its rate limit (less than 100 requests remaining).
request_completed(signal_name: String, response_code: int, data: Dictionary) 🔗
Emitted when an API request completes successfully (HTTP 2xx response).
request_failed(signal_name: String, error_code: int, message: String) 🔗
Emitted when an API request fails (HTTP 4xx or 5xx response).
Method Descriptions
void configure(access_token: String) 🔗
Configures the API with your access token. This must be called before making any API requests.
KickAPI.configure("your_access_token_here")
KickCategoriesRequests get_categories() 🔗
Returns the categories request handler for searching and retrieving category information.
KickChannelsRequests get_channels() 🔗
Returns the channels request handler for retrieving and updating channel information.
KickChatRequests get_chat() 🔗
Returns the chat request handler for sending chat messages.
KickEventsRequests get_events() 🔗
Returns the events request handler for managing event subscriptions (webhooks).
KickHTTPClient get_http_client() const 🔗
There is currently no description for this method. Please help us by contributing one!
KickLivestreamsRequests get_livestreams() 🔗
Returns the livestreams request handler for retrieving livestream information.
KickModerationRequests get_moderation() 🔗
Returns the moderation request handler for banning and unbanning users.
KickOAuthRequests get_oauth() 🔗
Returns the OAuth request handler for token introspection and public key retrieval.
int get_rate_limit_remaining() const 🔗
Returns the number of API requests remaining before hitting the rate limit. Returns -1 if unknown.
int get_rate_limit_reset() const 🔗
Returns the Unix timestamp when the rate limit will reset. Returns 0 if unknown.
KickUsersRequests get_users() 🔗
Returns the users request handler for retrieving user information.
Returns true if there are pending API requests in the queue.
void poll() 🔗
Manually polls the HTTP client for responses. This is normally not needed as the API automatically polls each physics frame.
String query_string_from_dict(params: Dictionary) const 🔗
Converts a Dictionary to a URL-encoded query string. Useful for building API requests.
void set_access_token(token: String) 🔗
Updates the access token used for API authentication.