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

# v1 から v2 への移行

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>;
};

<div id="manage-lists-standard-v11-compared-to-x-api-v2">
  ### リストの管理: standard v1.1 と X API v2 の比較
</div>

standard v1.1 の [POST lists/create](https://developer.x.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-create)、[POST lists/destroy](https://developer.x.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-destroy)、および [POST lists/update](https://developer.x.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-update) エンドポイントを使用している場合、本ガイドは、standard v1.1 と X API v2 のリスト管理エンドポイント間の共通点と相違点を理解できるようにすることを目的としています。

* **共通点**
  * 認証
* **相違点**
  * エンドポイント URL
  * App と Project の要件
  * HTTP メソッド
  * レート制限
  * リクエストパラメータ

<div id="similarities">
  #### 類似点
</div>

**認証**

エンドポイントの両バージョンとも [OAuth 1.0a User Context](https://developer.x.com/content/developer-twitter/resources/fundamentals/authentication) をサポートしています。そのため、これまで標準 v1.1 のリスト管理用エンドポイントのいずれかを使用していた場合、X API v2 のエンドポイントに移行しても、同じ認証方法を引き続き使用できます。

<div id="differences">
  #### 相違点
</div>

**エンドポイント URL**

* 標準 v1.1 エンドポイント:
  * POST [https://api.x.com/1.1/lists/create.json](https://api.x.com/1.1/lists/create.json)
    (リストを作成)
  * POST [https://api.x.com/1.1/lists/destroy.json](https://api.x.com/1.1/lists/destroy.json)
    (リストを削除)
  * POST [https://api.x.com/1.1/lists/update.json](https://api.x.com/1.1/lists/update.json)
    (リストを更新)
* X API v2 エンドポイント:
  * POST [https://api.x.com/2/lists](https://api.x.com/2/lists)
    (リストを作成)

  * DELETE [https://api.x.com/2/lists/:id](https://api.x.com/2/lists/:id)
    (リストを削除)

  * PUT [https://api.x.com/2/lists/:id](https://api.x.com/2/lists/:id)
    (リストを更新)

**レート制限**

| **Standard v1.1**                     | **X API v2**                                                    |
| :------------------------------------ | :-------------------------------------------------------------- |
| /1.1/lists/create.json<br /><br />なし  | /2/lists<br /><br />OAuth 1.0a ユーザーコンテキストで 15 分間に 300 リクエスト     |
| /1.1/lists/destroy.json<br /><br />なし | /2/lists/:id<br /><br />OAuth 1.0a ユーザーコンテキストで 15 分間に 300 リクエスト |
| /1.1/lists/update.json<br /><br />なし  | /2/lists/:id<br /><br />OAuth 1.0a ユーザーコンテキストで 15 分間に 300 リクエスト |

**App と Project の要件**

X API v2 エンドポイントを使用する場合、リクエストの認証には、[Project](/ja/resources/fundamentals/developer-apps) に関連付けられた [developer App](/ja/resources/fundamentals/developer-apps) の認証情報を使用する必要があります。X API v1.1 のすべてのエンドポイントでは、Project に関連付けられているかどうかにかかわらず App の認証情報を使用できます。

**リクエストパラメータ**

次の標準 v1.1 のリクエストパラメータには、X API v2 で対応するパラメータがあります:

**リストを作成**

| **Standard** | **X API v2** |
| :----------- | :----------- |
| name         | name         |
| mode         | private      |
| description  | description  |

**リストを削除/更新**

| **Standard**        | **X API v2** |
| :------------------ | :----------- |
| owner\_screen\_name | 対応するパラメータなし  |
| owner\_id           | 対応するパラメータなし  |
| list\_id            | id           |
| slug                | 対応するパラメータなし  |

<Note>
  **注意:** 標準 v1.1 のパラメータはクエリパラメータとして渡されますが、X API v2 のパラメータは、POST エンドポイントではボディパラメータとして、DELETE および PUT エンドポイントではパスパラメータとして渡されます。
</Note>

***

<div id="code-examples">
  ## コード例
</div>

<div id="create-a-list-v2">
  ### リストを作成する (v2)
</div>

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl -X POST "https://api.x.com/2/lists" \
    -H "Authorization: OAuth ..." \
    -H "Content-Type: application/json" \
    -d '{"name": "My List", "description": "A great list"}'
  ```

  ```python 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/lists"
  data = {"name": "My List", "description": "A great list"}

  response = requests.post(url, auth=auth, json=data)
  print(response.json())
  ```

  ```python Python SDK 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.lists.create(name="My List", description="A great list")
  print(f"Created List: {response.data.id}")
  ```

  ```javascript JavaScript SDK 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.lists.create({
    name: "My List",
    description: "A great list",
  });
  console.log(`Created List: ${response.data?.id}`);
  ```
</CodeGroup>

<div id="delete-a-list-v2">
  ### リストを削除する (v2)
</div>

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl -X DELETE "https://api.x.com/2/lists/123456789" \
    -H "Authorization: OAuth ..."
  ```

  ```python Python theme={null}
  # OAuth 1.0a のユーザーコンテキスト認証が必要です
  import requests
  from requests_oauthlib import OAuth1

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

  url = "https://api.x.com/2/lists/123456789"
  response = requests.delete(url, auth=auth)
  print(response.json())
  ```

  ```python Python SDK 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.lists.delete("123456789")
  print(f"Deleted: {response.data.deleted}")
  ```

  ```javascript JavaScript SDK 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.lists.delete("123456789");
  console.log(`Deleted: ${response.data?.deleted}`);
  ```
</CodeGroup>
