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

# リストメンバーの取得

> リストのメンバーを取得する

export const Button = ({href, children}) => {
  return <div className="not-prose group">
    <a href={href}>
      <button className="flex items-center space-x-2.5 py-1 px-4 bg-primary-dark dark:bg-white text-white dark:text-gray-950 rounded-full group-hover:opacity-[0.9] font-medium">
        <span>
          {children}
        </span>
        <svg width="3" height="24" viewBox="0 -9 3 24" class="h-6 rotate-0 overflow-visible"><path d="M0 0L3 3L0 6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg>
      </button>
    </a>
  </div>;
};

このガイドでは、リストのメンバーを取得する方法を説明します。

<Note>
  **前提条件**

  始める前に、以下が必要です。

  * 承認済みの App を持つ [開発者アカウント](https://developer.x.com/en/portal/petition/essential/basic-info)
  * App のベアラートークン
</Note>

***

<div id="get-list-members">
  ## リストメンバーを取得する
</div>

<Steps>
  <Step title="リストIDを確認する">
    リストを表示しているときに、URL からリストIDを確認できます：

    ```
    https://x.com/i/lists/84839422
                          └── ここがリストIDです
    ```
  </Step>

  <Step title="リストメンバーをリクエストする">
    <CodeGroup dropdown>
      ```bash cURL theme={null}
      curl "https://api.x.com/2/lists/84839422/members?\
      user.fields=created_at,username,verified&\
      max_results=100" \
        -H "Authorization: Bearer $BEARER_TOKEN"
      ```

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

      client = Client(bearer_token="YOUR_BEARER_TOKEN")

      # ページネーション付きでリストメンバーを取得
      for page in client.lists.get_members(
          "84839422",
          user_fields=["created_at", "username", "verified"],
          max_results=100
      ):
          for user in page.data:
              print(f"{user.username} - 参加日時: {user.created_at}")
      ```

      ```javascript JavaScript SDK theme={null}
      import { Client } from "@xdevplatform/xdk";

      const client = new Client({ bearerToken: "YOUR_BEARER_TOKEN" });

      // ページネーション付きでリストメンバーを取得
      const paginator = client.lists.getMembers("84839422", {
        userFields: ["created_at", "username", "verified"],
        maxResults: 100,
      });

      for await (const page of paginator) {
        page.data?.forEach((user) => {
          console.log(`${user.username} - 参加日時: ${user.created_at}`);
        });
      }
      ```
    </CodeGroup>
  </Step>

  <Step title="レスポンスを確認する">
    ```json theme={null}
    {
      "data": [
        {
          "id": "1319036828964454402",
          "name": "Birdwatch",
          "username": "birdwatch",
          "created_at": "2020-10-21T22:04:47.000Z",
          "verified": true
        },
        {
          "id": "1065249714214457345",
          "name": "Spaces",
          "username": "TwitterSpaces",
          "created_at": "2018-11-21T14:24:58.000Z",
          "verified": true
        }
      ],
      "meta": {
        "result_count": 2,
        "next_token": "5349804505549807616"
      }
    }
    ```
  </Step>
</Steps>

***

<div id="include-additional-data">
  ## 追加データを取得する
</div>

expansions を使用して、ピン留めされた投稿などの関連データを取得します。

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl "https://api.x.com/2/lists/84839422/members?\
  user.fields=created_at&\
  expansions=pinned_tweet_id&\
  tweet.fields=created_at" \
    -H "Authorization: Bearer $BEARER_TOKEN"
  ```

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

  client = Client(bearer_token="YOUR_BEARER_TOKEN")

  # expansions を指定して List メンバーを取得
  for page in client.lists.get_members(
      "84839422",
      user_fields=["created_at"],
      expansions=["pinned_tweet_id"],
      tweet_fields=["created_at"]
  ):
      for user in page.data:
          print(f"{user.username}")
      # ピン留めされた投稿は page.includes.tweets に含まれます
  ```

  ```javascript JavaScript SDK theme={null}
  import { Client } from "@xdevplatform/xdk";

  const client = new Client({ bearerToken: "YOUR_BEARER_TOKEN" });

  // expansions を指定して List メンバーを取得
  const paginator = client.lists.getMembers("84839422", {
    userFields: ["created_at"],
    expansions: ["pinned_tweet_id"],
    tweetFields: ["created_at"],
  });

  for await (const page of paginator) {
    page.data?.forEach((user) => {
      console.log(user.username);
    });
    // ピン留めされた投稿は page.includes?.tweets に含まれます
  }
  ```
</CodeGroup>

***

<div id="next-steps">
  ## 次のステップ
</div>

<CardGroup cols={2}>
  <Card title="リストメンバーを管理" icon="user-plus" href="/ja/x-api/lists/list-members/quickstart/manage-list-members">
    メンバーの追加と削除
  </Card>

  <Card title="リストの取得" icon="list" href="/ja/x-api/lists/list-lookup/quickstart">
    リストの詳細を取得する
  </Card>

  <Card title="APIリファレンス" icon="code" href="/ja/x-api/lists/get-list-members">
    エンドポイントの完全なドキュメント
  </Card>
</CardGroup>
