TwitchHTTPClient
Inherits: RefCounted < Object
Low-level HTTP client for Twitch API with rate limiting and request queuing.
Description
TwitchHTTPClient handles HTTP communication with the Twitch API, including automatic rate limit tracking, request queuing, and retry logic. This class is used internally by TwitchAPI and typically does not need to be accessed directly.
Tutorials
Methods
get_queue_size() const |
|
get_rate_limit_remaining() const |
|
get_rate_limit_reset() const |
|
is_busy() const |
|
void |
poll() |
query_string_from_dict(params: Dictionary) static |
|
void |
queue_request(signal_name: String, method: Method, path: String, query_params: Dictionary = {}, body: String = "") |
void |
set_access_token(token: String) |
void |
set_base_url(url: String) |
void |
set_client_id(client_id: String) |
void |
set_credentials(client_id: String, access_token: String) |
void |
set_response_callback(callback: Callable) |
void |
set_tls_options(options: TLSOptions) |
Method Descriptions
Returns the number of requests currently waiting in the queue.
int get_rate_limit_remaining() const 🔗
Returns the number of API requests remaining before hitting the rate limit. Returns -1 if no requests have been made yet.
int get_rate_limit_reset() const 🔗
Returns the Unix timestamp when the rate limit resets. Returns 0 if no requests have been made yet.
Returns true if there are requests in the queue or a request is currently being processed.
void poll() 🔗
Processes the HTTP client state machine and request queue. Called automatically by TwitchAPI.
String query_string_from_dict(params: Dictionary) static 🔗
Static utility method that converts a Dictionary into a URL query string. Arrays are automatically expanded into multiple parameters.
void queue_request(signal_name: String, method: Method, path: String, query_params: Dictionary = {}, body: String = "") 🔗
Queues an HTTP request to the Twitch API. Requests are processed sequentially. Used internally by request category classes.
void set_access_token(token: String) 🔗
Sets the OAuth access token used in the Authorization header for all API requests.
void set_base_url(url: String) 🔗
Sets the base URL for API requests. Defaults to the Twitch Helix API URL. Rarely needs to be changed.
void set_client_id(client_id: String) 🔗
Sets the Twitch application Client ID used in the Client-Id header for all API requests.
void set_credentials(client_id: String, access_token: String) 🔗
Sets both the Client ID and OAuth access token in one call. Convenience method equivalent to calling set_client_id() and set_access_token().
void set_response_callback(callback: Callable) 🔗
Sets the callback function invoked when HTTP responses are received. Used internally by TwitchAPI.
void set_tls_options(options: TLSOptions) 🔗
There is currently no description for this method. Please help us by contributing one!