> ## Documentation Index
> Fetch the complete documentation index at: https://docs.x.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Python XDK

> 인증 설정, 페이지네이션 요청 및 스트리밍 예제를 포함하여 X API v2를 위한 공식 Python XDK 클라이언트 라이브러리를 설치하고 사용합니다.

[Python XDK](https://github.com/xdevplatform/xdk-py)는 X API v2의 공식 클라이언트 라이브러리입니다. 인증, 페이지네이션 및 스트리밍을 처리하므로 구축에 집중할 수 있습니다.

<Card title="GitHub 저장소" icon="github" href="https://github.com/xdevplatform/xdk-py">
  소스 코드, 이슈 및 릴리스.
</Card>

***

## 설치

```bash theme={null}
pip install xdk
```

Python 3.8+가 필요합니다.

***

## 빠른 시작

```python theme={null}
from xdk import Client

client = Client(bearer_token="YOUR_BEARER_TOKEN")

# Search for posts
for page in client.posts.search_recent(query="X API", max_results=10):
    if page.data and len(page.data) > 0:
        print(page.data[0].text)
        break
```

***

## 주요 기능

| 기능            | 설명                                              |
| :------------ | :---------------------------------------------- |
| **OAuth 지원**  | Bearer Token, PKCE가 포함된 OAuth 2.0, OAuth 1.0a   |
| **자동 페이지네이션** | 수동 `next_token` 처리 없이 결과 반복                     |
| **스트리밍**      | 지속적 연결을 통한 실시간 데이터(filtered stream 등)           |
| **전체 API 지원** | 모든 X API v2 엔드포인트 — 검색, 타임라인, filtered stream 등 |

***

## 인증

<Tabs>
  <Tab title="Bearer Token">
    ```python theme={null}
    from xdk import Client

    client = Client(bearer_token="YOUR_BEARER_TOKEN")
    ```
  </Tab>

  <Tab title="OAuth 2.0">
    ```python theme={null}
    from xdk import Client
    from xdk.oauth2_auth import OAuth2PKCEAuth

    auth = OAuth2PKCEAuth(
        client_id="YOUR_CLIENT_ID",
        redirect_uri="YOUR_CALLBACK_URL",
        scope="tweet.read users.read offline.access"
    )

    auth_url = auth.get_authorization_url()
    tokens = auth.fetch_token(authorization_response=callback_url)
    client = Client(bearer_token=tokens["access_token"])
    ```
  </Tab>

  <Tab title="OAuth 1.0a">
    ```python theme={null}
    from xdk import Client
    from xdk.oauth1_auth import OAuth1

    oauth1 = OAuth1(
        api_key="YOUR_API_KEY",
        api_secret="YOUR_API_SECRET",
        access_token="YOUR_ACCESS_TOKEN",
        access_token_secret="YOUR_ACCESS_TOKEN_SECRET"
    )

    client = Client(auth=oauth1)
    ```
  </Tab>
</Tabs>

***

## 일반적인 메서드

| 카테고리       | 메서드                            |
| :--------- | :----------------------------- |
| **Posts**  | `client.posts.search_recent()` |
| **Users**  | `client.users.get_me()`        |
| **Spaces** | `client.spaces.get()`          |
| **Lists**  | `client.lists.get()`           |
| **DMs**    | `client.direct_messages.get()` |

***

## 자세히 알아보기

<CardGroup cols={2}>
  <Card title="설치" icon="download" href="/xdks/python/install">
    개발 설치, 사전 요구 사항 및 검증.
  </Card>

  <Card title="빠른 시작" icon="rocket" href="/xdks/python/quickstart">
    첫 요청 단계별 워크스루.
  </Card>

  <Card title="인증" icon="key" href="/xdks/python/authentication">
    모든 인증 방법에 대한 자세한 가이드.
  </Card>

  <Card title="페이지네이션" icon="arrows-left-right" href="/xdks/python/pagination">
    자동 페이지네이션 및 반복자.
  </Card>

  <Card title="스트리밍" icon="satellite-dish" href="/xdks/python/streaming">
    filtered stream을 통한 실시간 데이터.
  </Card>

  <Card title="API 레퍼런스" icon="book" href="/xdks/python/reference/modules">
    전체 클라이언트 및 모델 레퍼런스.
  </Card>
</CardGroup>

코드 예제는 [samples 저장소](https://github.com/xdevplatform/samples/tree/main/python)를 참조하세요.
