This module provides the primary Client class for interacting with the X API.
It coordinates all sub-clients and handles authentication, session management,
and OAuth2 PKCE flows. All functionality is generated from the OpenAPI specification.
Client
Class
Bases: object
Client for interacting with the X API.
Constructors
__init__
Initialize the X API client.
Parameters
path.base_url
str
default:"'https://api.twitter.com'"
The base URL for the X API.
path.bearer_token
str or None
default:"None"
The bearer token for the X API.
path.client_id
str or None
default:"None"
The client ID for the X API.
path.client_secret
str or None
default:"None"
The client secret for the X API.
path.redirect_uri
str or None
default:"None"
The redirect URI for OAuth2 authorization.
path.token
Dict[str, Any] or None
default:"None"
An existing OAuth2 token dictionary (if available).
path.scope
str or None
default:"None"
Space-separated list of scopes for OAuth2 authorization.
Parameters
path.base_url
str
default:"'https://api.twitter.com'"
path.bearer_token
str or None
default:"None"
path.client_id
str or None
default:"None"
path.client_secret
str or None
default:"None"
path.redirect_uri
str or None
default:"None"
path.token
Dict[str, Any] or None
default:"None"
path.scope
str or None
default:"None"
fetch_token
Fetch token using authorization response.
Parameters
path.authorization_response
get_authorization_url
Get the authorization URL for the OAuth2 PKCE flow.
is_token_expired
Check if the OAuth2 token is expired.
refresh_token
Refresh the OAuth2 token.