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

# 移行ガイド

> v2 hide replies エンドポイントは Labs hide replies エンドポイントを置き換えます。hide replies を扱う X API v2 スタンダードティアのリファレンス。

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 の hide replies エンドポイントを比較する

v2 の hide replies エンドポイントは、Labs の hide replies エンドポイントを置き換えます。このエンドポイントの Labs バージョンを使用したコード、アプリ、ツールをお持ちで、新しい X API v2 エンドポイントへの移行を検討中の場合、本ガイドが役立ちます。

新しい X API v2(hide replies エンドポイントを含む)を使用するには、[新しい Developer Console にオプトイン](https://developer.x.com/en/portal/opt-in)し、[Project](/resources/fundamentals/developer-apps) を作成し、その Project に App を追加する必要があります。その後、その App に紐づく認証情報を使用して hide replies エンドポイントへのリクエストを行えます。Labs v2 hide replies エンドポイントに登録した同じ App を追加すると、ユーザー認証が維持されます。

以下の表は、Labs と新しい X API v2 エンドポイントの相違点を比較しています:

| **Description**                                                                                                     | **Labs v2**                            | **X API v2**                           |
| :------------------------------------------------------------------------------------------------------------------ | :------------------------------------- | :------------------------------------- |
| Host domain                                                                                                         | [https://api.x.com](https://api.x.com) | [https://api.x.com](https://api.x.com) |
| Endpoint path                                                                                                       | /labs/2/tweets/:id/hidden              | /2/tweets/:id/hidden                   |
| 認証                                                                                                                  | OAuth 1.0a User context                | OAuth 1.0a User context                |
| サポートする HTTP メソッド                                                                                                    | PUT                                    | PUT                                    |
| デフォルトのリクエストレート制限                                                                                                    | 15 分あたり 10 リクエスト(認証済み全ユーザー間で共有)        | 認証ユーザーごとに 15 分あたり 50 リクエスト             |
| 返信を非表示にできる                                                                                                          | ✔︎                                     | ✔︎                                     |
| 以前非表示にした返信を再表示できる                                                                                                   | ✔︎                                     | ✔︎                                     |
| 複数回の非表示・再表示ができる                                                                                                     | ✔︎                                     | ✔︎                                     |
| [Project](/resources/fundamentals/developer-apps) に紐づく[開発者 App](/resources/fundamentals/developer-apps) の認証情報の使用が必要 |                                        | ✔                                      |

***

## コード例

### 返信を非表示にする (v2)

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl -X PUT "https://api.x.com/2/tweets/1234567890/hidden" \
    -H "Authorization: OAuth ..." \
    -H "Content-Type: application/json" \
    -d '{"hidden": true}'
  ```

  ```python title="Python" lines wrap icon="python" theme={null}
  # OAuth 1.0a User Context 認証が必要
  import requests
  from requests_oauthlib import OAuth1

  auth = OAuth1(
      "API_KEY", "API_SECRET",
      "ACCESS_TOKEN", "ACCESS_TOKEN_SECRET"
  )

  url = "https://api.x.com/2/tweets/1234567890/hidden"
  response = requests.put(url, auth=auth, json={"hidden": True})
  print(response.json())
  ```

  ```python title="Python SDK" lines wrap icon="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)

  # 返信を非表示にする
  response = client.posts.hide_reply("1234567890", hidden=True)
  print(f"Hidden: {response.data.hidden}")
  ```

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

  const oauth1 = new OAuth1({
    apiKey: "YOUR_API_KEY",
    apiSecret: "YOUR_API_SECRET",
    accessToken: "YOUR_ACCESS_TOKEN",
    accessTokenSecret: "YOUR_ACCESS_TOKEN_SECRET",
  });

  const client = new Client({ oauth1 });

  // 返信を非表示にする
  const response = await client.posts.hideReply("1234567890", { hidden: true });
  console.log(`Hidden: ${response.data?.hidden}`);
  ```
</CodeGroup>

**その他の移行リソース**

[X API 移行ハブ](/x-api/migrate/overview)
