Skip to main content
このモジュールは、X API と対話するための主要な Client クラスを提供します。 すべてのサブクライアントを取りまとめ、認証、セッション管理、OAuth 2.0 PKCE フローを扱います。 すべての機能は OpenAPI 仕様から生成されています。

Client

クラス 基底: object | None = None) Client for interacting with the X API.

コンストラクター

__init__

Initialize the X API client.

パラメーター

str
default:"'https://api.x.com'"
The base URL for the X API (defaults to https://api.x.com).
str or None
default:"None"
The bearer token for the X API (app-only authentication).
str or None
default:"None"
The OAuth2 access token for user context (can be used directly as bearer token).
str or None
default:"None"
The client ID for the X API (required for OAuth2 PKCE flow).
str or None
default:"None"
The client secret for the X API.
str or None
default:"None"
The redirect URI for OAuth2 authorization.
Dict[str, Any] or None
default:"None"
An existing OAuth2 token dictionary (if available). If provided, access_token will be extracted.
str or List[str] or None
default:"None"
Space-separated string or list of strings for OAuth2 authorization scopes.
str
default:"'https://x.com/i'"
The base URL for OAuth2 authorization (defaults to https://x.com/i).
OAuth1
OAuth1 instance for OAuth1.0a authentication.

パラメーター

str
default:"'https://api.x.com'"
str or None
default:"None"
str or None
default:"None"
str or None
default:"None"
str or None
default:"None"
str or None
default:"None"
Dict[str, Any] or None
default:"None"
str or List[str] or None
default:"None"
str
default:"'https://x.com/i'"
OAuth1

exchange_code

Exchange authorization code for tokens (matches TypeScript API).

パラメーター

Any
The authorization code from the callback.
Any
default:"None"
Optional code verifier (uses stored verifier if not provided).

fetch_token

Fetch token using authorization response URL (legacy method).

パラメーター

Any
The full callback URL received after authorization.

get_authorization_url

Get the authorization URL for the OAuth2 PKCE flow.

パラメーター

Any
default:"None"
Optional state parameter for security.

is_token_expired

Check if the OAuth2 token is expired.

refresh_token

Refresh the OAuth2 token.