> ## 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.

# クイックスタート

> この例では、Bearer Token 認証で XDK を使って素早く投稿を検索する方法を紹介します。1. X Developer Console にログインします。2.

この例では、Bearer Token 認証で XDK を使って素早く投稿を検索する方法を紹介します。

## ステップ 1: SDK をインストールする

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

## ステップ 2: Bearer Token を取得する

1. [X Developer Console](https://developer.x.com/en/portal/dashboard) にログインします。
2. アプリを作成または選択します。
3. 「Keys and Tokens」で Bearer Token（アプリのみ認証）を生成します。

## ステップ 3: 最初のスクリプトを書いて実行する

`quickstart.py` というファイルを作成します:

```python title="Example" lines wrap icon="python" theme={null}
# Import the client
from xdk import Client
# Replace with your actual Bearer Token
client = Client(bearer_token="YOUR_BEARER_TOKEN_HERE")
# Fetch recent Posts mentioning "api"
# search_recent returns an Iterator, so iterate over it
for page in client.posts.search_recent(query="api", max_results=10):
    if page.data and len(page.data) > 0:
        # Access first Post - Pydantic models support both attribute and dict access
        first_post = page.data[0]
        post_text = first_post.text if hasattr(first_post, 'text') else first_post.get('text', '')
        print(f"Latest Post: {post_text}")
        break
    else:
        print("No Posts found.")
        break
```

実行します:

```bash theme={null}
python quickstart.py
```

**想定される出力**:

```
Latest Post: Exciting updates on XDK Python SDK!
```

**トラブルシューティング**: 401 エラーが返る場合は Bearer Token を再確認してください。レート制限（429）の場合は少し待って再試行してください。

## 次のステップ

* [認証](/xdks/python/authentication)で、Bearer Token（アプリのみ）認証、PKCE 付き OAuth 2.0（ユーザーコンテキスト）、OAuth 1.0a（レガシーのユーザーコンテキスト）の使い方を学びましょう。
* [ページネーション](/xdks/python/pagination)で、多数の結果を複数回の API 呼び出しを意識せずに取得するユースケースを学びましょう。
* [ストリーミング](/xdks/python/streaming)で、リアルタイムデータの扱い方を学びましょう。
  Python XDK を使った詳細なコードサンプルは、[コードサンプル GitHub リポジトリ](https://github.com/xdevplatform/samples/tree/main/python)を参照してください。
