client¶
Short.io API Client implementation.
This module provides the main Client class that serves as the primary interface for interacting with the Short.io API in a Pythonic way. The Client class combines multiple specialized mixins to provide comprehensive access to all Short.io API endpoints while maintaining clean separation of concerns.
- pyshortio.client.normalize_endpoint(endpoint: str) str[source]¶
Normalize the endpoint URL by ensuring it ends with a slash.
This utility function ensures consistent handling of API endpoint URLs by standardizing the format. It removes trailing slashes to ensure that when paths are appended to the endpoint, double slashes are avoided.
Examples:
>>> normalize_endpoint("https://api.short.io/") "https://api.short.io" >>> normalize_endpoint("https://api.short.io") "https://api.short.io"
- class pyshortio.client.Client(token: str, endpoint: str = 'https://api.short.io')[source]¶
Main client class for interacting with the Short.io API.
This class combines multiple specialized mixins to provide a unified interface to all Short.io API endpoints. It handles authentication, request formatting, and response processing while delegating specific API endpoint implementations to the various mixins.
The Client implements core HTTP request methods (http_get, http_post) which are then used by the mixin classes to implement specific API endpoints. This ensures consistent request handling and error management across all API calls.
- Parameters:
token – The Short.io API token for authentication
endpoint – The base URL for the Short.io API (defaults to “https://api.short.io”)
- http_get(url: str, headers: Dict[str, Any] | None = None, params: Dict[str, Any] | None = None, debug: bool = False)[source]¶
Perform an HTTP GET request to the Short.io API.
This method handles the details of making GET requests to the API, including adding appropriate headers, formatting parameters, and logging request/response details for debugging.