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

# Mutes Lookup

> このガイドでは、X API を利用してミュート中のユーザー一覧を取得する手順を説明します。X API v2 スタンダード階層の quickstart に関するリファレンスドキュメントです。

export const Button = ({href, children}) => {
  return <div className="not-prose">
    <a href={href}>
      <button className="x-btn">
        <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>;
};

このガイドでは、X API を利用してミュート中のユーザー一覧を取得する手順を説明します。

<Note>
  **前提条件**

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

  * 承認済みの App がある [developer account](https://developer.x.com/en/portal/petition/essential/basic-info)
  * ユーザー Access Token (OAuth 1.0a または OAuth 2.0 PKCE)
</Note>

***

## ミュート中のユーザーを取得

<Steps>
  <Step title="user ID を取得">
    認証済みユーザーの ID が必要です。[user lookup エンドポイント](/x-api/users/lookup/introduction) を使って取得するか、Access Token から確認できます (数値部分が user ID)。
  </Step>

  <Step title="ミュート中のユーザーをリクエスト">
    <CodeGroup dropdown>
      ```bash cURL theme={null}
      curl "https://api.x.com/2/users/123456789/muting?\
      user.fields=created_at,username,verified&\
      max_results=100" \
        -H "Authorization: Bearer $USER_ACCESS_TOKEN"
      ```

      ```python title="Python SDK" lines wrap icon="python" theme={null}
      from xdk import Client

      client = Client(bearer_token="YOUR_USER_ACCESS_TOKEN")

      # ページネーションでミュート中のユーザーを取得
      for page in client.users.get_muting(
          "123456789",
          user_fields=["created_at", "username", "verified"],
          max_results=100
      ):
          for user in page.data:
              print(f"{user.username} - Muted")
      ```

      ```javascript title="JavaScript SDK" lines wrap icon="square-js" theme={null}
      import { Client } from "@xdevplatform/xdk";

      const client = new Client({ accessToken: "YOUR_USER_ACCESS_TOKEN" });

      // ページネーションでミュート中のユーザーを取得
      const paginator = client.users.getMuting("123456789", {
        userFields: ["created_at", "username", "verified"],
        maxResults: 100,
      });

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

  <Step title="レスポンスを確認">
    ```json theme={null}
    {
      "data": [
        {
          "id": "2244994945",
          "name": "X Developers",
          "username": "XDevelopers",
          "created_at": "2013-12-14T04:35:55.000Z",
          "verified": true
        }
      ],
      "meta": {
        "result_count": 1,
        "next_token": "1710819323648428707"
      }
    }
    ```
  </Step>
</Steps>

***

## 追加データを含める

expansions を使うと、pinned Post などの関連データを取得できます:

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

  ```python title="Python SDK" lines wrap icon="python" theme={null}
  from xdk import Client

  client = Client(bearer_token="YOUR_USER_ACCESS_TOKEN")

  # expansions つきでミュート中のユーザーを取得
  for page in client.users.get_muting(
      "123456789",
      user_fields=["created_at"],
      expansions=["pinned_tweet_id"],
      tweet_fields=["created_at"]
  ):
      for user in page.data:
          print(f"{user.username}")
      # ピン留めされた Post は page.includes.tweets にあります
  ```

  ```javascript title="JavaScript SDK" lines wrap icon="square-js" theme={null}
  import { Client } from "@xdevplatform/xdk";

  const client = new Client({ accessToken: "YOUR_USER_ACCESS_TOKEN" });

  // expansions つきでミュート中のユーザーを取得
  const paginator = client.users.getMuting("123456789", {
    userFields: ["created_at"],
    expansions: ["pinned_tweet_id"],
    tweetFields: ["created_at"],
  });

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

### expansion 付きのレスポンス

```json title="レスポンス例" lines wrap icon="https://mintcdn.com/x-preview/Vn2KEkZaPF9LiPi3/icons/xds/icon-brackets.svg?fit=max&auto=format&n=Vn2KEkZaPF9LiPi3&q=85&s=ed2428e77bab43e57800e1a590e982fa" theme={null}
{
  "data": [
    {
      "username": "XDevelopers",
      "created_at": "2013-12-14T04:35:55.000Z",
      "id": "2244994945",
      "name": "X Developers",
      "pinned_tweet_id": "1430984356139470849"
    }
  ],
  "includes": {
    "tweets": [
      {
        "created_at": "2021-08-26T20:03:51.000Z",
        "id": "1430984356139470849",
        "text": "Help us build a better X Developer Platform!..."
      }
    ]
  },
  "meta": {
    "result_count": 1
  }
}
```

***

## 結果をページネーション

SDK は自動でページネーションを処理します。cURL の場合はレスポンスの `next_token` を使います:

```bash theme={null}
curl "https://api.x.com/2/users/123456789/muting?\
max_results=100&\
pagination_token=1710819323648428707" \
  -H "Authorization: Bearer $USER_ACCESS_TOKEN"
```

***

## 次のステップ

<CardGroup cols={2}>
  <Card title="Manage mutes" icon="volume-xmark" href="/x-api/users/mutes/quickstart/manage-mutes-quickstart">
    ユーザーのミュート・解除
  </Card>

  <Card title="API リファレンス" icon="https://mintcdn.com/x-preview/ygI6sSJPehlc0qNT/icons/xds/icon-code.svg?fit=max&auto=format&n=ygI6sSJPehlc0qNT&q=85&s=488e23401b19225b89acc0136d242219" href="/x-api/users/get-muting" width="24" height="24" data-path="icons/xds/icon-code.svg">
    エンドポイントの詳細ドキュメント
  </Card>
</CardGroup>
