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

# 連携ガイド

> このページでは、Lists エンドポイントを連携するためのツールと主要な概念について説明します。X API v2 スタンダード階層の manage lists に関するリファレンスドキュメントです。

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

このページでは、Lists エンドポイントを連携するためのツールと主要な概念について説明します。

## 便利なツール

このエンドポイントの連携に役立ついくつかの主要な概念に進む前に、まず以下について理解しておくことをおすすめします:

#### Postman

Postman はエンドポイントをテストするのに便利なツールです。それぞれの Postman リクエストには、利用可能なパスパラメータやボディパラメータがすべて含まれており、何が利用できるかを素早く把握できます。Postman コレクションの詳細については、[「Using Postman」](/tutorials/postman-getting-started) ページをご確認ください。

#### コードサンプル

このエンドポイントをお好きなプログラミング言語のコードで動かしてみたいですか?出発点として利用できるいくつかの異なるコードサンプルが [Github ページ](https://github.com/xdevplatform/Twitter-API-v2-sample-code) で公開されています。

#### サードパーティライブラリ

コミュニティ提供の[サードパーティライブラリ](/tools-and-libraries)を活用して、開発を始めましょう。適切なバージョンタグを検索することで、v2 エンドポイントに対応したライブラリを見つけられます。

### 主要な概念

#### 認証

すべての X API v2 エンドポイントでは、キーとトークンと呼ばれる認証情報でリクエストを認証する必要があります。

これらの特定のエンドポイントでは [OAuth 1.0a User Context](/resources/fundamentals/authentication) の利用が必要です。つまり、成功するリクエストを行うために API Key とユーザー Access Token のセットを使用する必要があります。Access Token はリクエストを代行するユーザーに紐づいている必要があります。他のユーザーのために Access Token を生成したい場合は、そのユーザーは [3-legged OAuth フロー](/resources/fundamentals/authentication#obtaining-access-tokens-using-3-legged-oauth-flow)を通じて App を承認または認証する必要があります。

OAuth 1.0a は扱いが難しい場合があります。この認証方式に不慣れな場合は、リクエストを適切に認証するために[ライブラリ](/tools-and-libraries)や Postman のようなツールの利用をおすすめします。

#### Developer Console、Project、developer App

X API v2 エンドポイントで動作する認証情報を取得するには、[developer account に登録](https://developer.x.com/en/portal/petition/essential/basic-info)し、そのアカウント内で [Project](/resources/fundamentals/developer-apps) を設定し、その Project 内で [developer App](/resources/fundamentals/developer-apps) を作成する必要があります。その後、developer App 内でキーとトークンを確認できます。

#### レート制限

日々、何千人もの開発者が X API へリクエストを送信しています。この膨大なリクエスト量を管理するために、各エンドポイントには[レート制限](/x-api/fundamentals/rate-limits)が設定されており、App の代理として、または認証済みユーザーの代理として実行できるリクエスト数が制限されます。

これらのエンドポイントはユーザーレベルでレート制限されており、リクエストを代行する認証済みユーザーは、任意の developer App を横断して、それぞれのエンドポイントを一定回数までしか呼び出せません。

以下の表は各エンドポイントのレート制限を示しています。

|              |                 |                   |
| :----------- | :-------------- | :---------------- |
| **Endpoint** | **HTTP method** | **Rate limit**    |
| /2/lists     | POST            | 15 分あたり 300 リクエスト |
| /2/lists/:id | DELETE / PUT    | 15 分あたり 300 リクエスト |

***

### コード例

#### List を作成

<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 list of interesting accounts"}'
  ```

  ```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)

  # 新しい List を作成
  response = client.lists.create(
      name="My List",
      description="A list of interesting accounts"
  )
  print(response.data)
  ```

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

  // 新しい List を作成
  const response = await client.lists.create({
    name: "My List",
  });
  console.log(response.data);
  ```
</CodeGroup>

#### List を更新

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl -X PUT "https://api.x.com/2/lists/123456789" \
    -H "Authorization: OAuth ..." \
    -H "Content-Type: application/json" \
    -d '{"name": "Updated List Name"}'
  ```

  ```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)

  # List を更新
  response = client.lists.update(
      list_id="123456789",
      name="Updated List Name"
  )
  print(response.data)
  ```

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

  // List を更新
  const response = await client.lists.update("123456789", {
    name: "Updated List Name",
  });
  console.log(response.data);
  ```
</CodeGroup>
