Skip to main content

하위 패키지

하위 모듈

모듈 내용

XDK Python SDK. A Python SDK for the X API that provides convenient access to the X API endpoints with type safety and authentication support.

class xdk.Client

X API와 상호작용하기 위한 클라이언트입니다.

매개변수

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

__init__

X API 클라이언트를 초기화합니다.

매개변수

str
default:"'https://api.x.com'"
X API의 기본 URL입니다(기본값은 https://api.x.com).
str or None
default:"None"
X API의 Bearer Token입니다(앱 전용 인증).
str or None
default:"None"
사용자 컨텍스트를 위한 OAuth 2.0 액세스 토큰입니다(Bearer Token으로 직접 사용 가능).
str or None
default:"None"
X API의 client ID입니다(OAuth 2.0 PKCE 흐름에 필요).
str or None
default:"None"
X API의 client secret입니다.
str or None
default:"None"
OAuth 2.0 인증을 위한 redirect URI입니다.
Dict[str, Any] or None
default:"None"
기존 OAuth 2.0 토큰 딕셔너리입니다(가능한 경우). 제공되면 access_token이 추출됩니다.
str or List[str] or None
default:"None"
OAuth 2.0 인증 스코프를 위한 공백으로 구분된 문자열 또는 문자열 목록입니다.
str
default:"'https://x.com/i'"
OAuth 2.0 인증을 위한 기본 URL입니다(기본값은 https://x.com/i).
OAuth1
OAuth 1.0a 인증을 위한 OAuth1 인스턴스입니다.

exchange_code

인증 코드를 토큰으로 교환합니다(TypeScript API와 일치).

매개변수

Any
콜백에서 받은 인증 코드입니다.
Any
default:"None"
선택적 code verifier입니다(제공되지 않으면 저장된 verifier를 사용).

fetch_token

인증 응답 URL을 사용하여 토큰을 가져옵니다(레거시 메서드).

매개변수

Any
인증 후 수신된 전체 콜백 URL입니다.

get_authorization_url

OAuth 2.0 PKCE 흐름을 위한 인증 URL을 가져옵니다.

매개변수

Any
default:"None"
보안을 위한 선택적 state 매개변수입니다.

is_token_expired

OAuth 2.0 토큰이 만료되었는지 확인합니다.

refresh_token

OAuth 2.0 토큰을 갱신합니다.

class xdk.Cursor

[ResponseType]

매개변수

PaginatableMethod

__init__

Initialize the cursor.

매개변수

PaginatableMethod
The API method to call for each page (must support pagination)

items

Iterate over individual items from paginated responses.

매개변수

int or None
default:"None"
Maximum number of items to return (None for unlimited)

반환값

IteratorAny

pages

Iterate over pages of responses.

매개변수

int or None
default:"None"
Maximum number of pages to return (None for unlimited)

반환값

IteratorResponseType

class xdk.StreamConfig

Configuration for streaming connections with retry behavior.

매개변수

int
default:"10"
float
default:"1.0"
float
default:"64.0"
float
default:"2.0"
bool
default:"True"
float or None
default:"None"
int
default:"1024"
Callable[[], None] or None
default:"None"
Callable[[Exception or None], None] or None
default:"None"
Callable[[int, float], None] or None
default:"None"
Callable[[[StreamError

__init__

매개변수

int
default:"10"
float
default:"1.0"
float
default:"64.0"
float
default:"2.0"
bool
default:"True"
float or None
default:"None"
int
default:"1024"
Callable[[], None] or None
default:"None"
Callable[[Exception or None], None] or None
default:"None"
Callable[[int, float], None] or None
default:"None"
Callable[[[StreamError

on_error : Callable[[[StreamError]

exception xdk.StreamError

Exception raised for streaming errors with classification.

매개변수

str
StreamErrorType

__init__

매개변수

str
StreamErrorType

class xdk.StreamErrorType

Classification of streaming errors for retry decisions.

매개변수

Any

class xdk.StreamState

Internal state for a streaming connection.

매개변수

int
default:"0"
float
default:"1.0"
bool
default:"False"
int
default:"0"
StreamError

__init__

매개변수

int
default:"0"
float
default:"1.0"
bool
default:"False"
int
default:"0"
StreamError

last_error : [StreamError]

xdk.cursor

Create a cursor with proper type inference and validation. This factory function helps with type inference so you get proper type hints for the response type, and validates that the method supports pagination at both static analysis and runtime.

매개변수

PaginatableMethod
The API method to wrap (must support pagination)