Client
Class Bases: object | None = None) Client for interacting with the X API.Constructors
__init__
Initialize the X API client.
Parameters
The base URL for the X API (defaults to https://api.x.com).
The bearer token for the X API (app-only authentication).
The OAuth2 access token for user context (can be used directly as bearer token).
The client ID for the X API (required for OAuth2 PKCE flow).
The client secret for the X API.
The redirect URI for OAuth2 authorization.
An existing OAuth2 token dictionary (if available). If provided, access_token will be extracted.
Space-separated string or list of strings for OAuth2 authorization scopes.
The base URL for OAuth2 authorization (defaults to https://x.com/i).
OAuth1 instance for OAuth1.0a authentication.
Parameters
exchange_code
Exchange authorization code for tokens (matches TypeScript API).
Parameters
The authorization code from the callback.
Optional code verifier (uses stored verifier if not provided).
fetch_token
Fetch token using authorization response URL (legacy method).
Parameters
The full callback URL received after authorization.
get_authorization_url
Get the authorization URL for the OAuth2 PKCE flow.
Parameters
Optional state parameter for security.