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

# 통합 가이드

> 이 가이드는 애플리케이션에 List lookup 엔드포인트를 통합할 때 필요한 핵심 개념을 다룹니다. List lookup을 다루는 X API v2 standard 티어 레퍼런스입니다.

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

이 가이드는 애플리케이션에 List lookup 엔드포인트를 통합할 때 필요한 핵심 개념을 다룹니다.

***

## 인증

List lookup 엔드포인트는 여러 인증 방식을 지원합니다:

| Method                                                                                                                         | Best for    | Access to private Lists? |
| :----------------------------------------------------------------------------------------------------------------------------- | :---------- | :----------------------- |
| [OAuth 2.0 App-Only](/resources/fundamentals/authentication#oauth-2-0)                                                         | 공개 List 데이터 | No                       |
| [OAuth 2.0 Authorization Code with PKCE](/resources/fundamentals/authentication#oauth-2-0-authorization-code-flow-with-pkce-2) | 사용자 대상 앱    | Yes (소유/팔로우)             |
| [OAuth 1.0a User Context](/resources/fundamentals/authentication)                                                              | 레거시 통합      | Yes (소유/팔로우)             |

### 요청 예시

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl "https://api.x.com/2/lists/84839422?\
  list.fields=description,member_count,follower_count,private" \
    -H "Authorization: Bearer $BEARER_TOKEN"
  ```

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

  client = Client(bearer_token="YOUR_BEARER_TOKEN")

  # ID로 List 가져오기
  response = client.lists.get(
      list_id="84839422",
      list_fields=["description", "member_count", "follower_count", "private"]
  )
  print(response.data)
  ```

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

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

  const response = await client.lists.get("84839422", {
    listFields: ["description", "member_count", "follower_count", "private"],
  });
  console.log(response.data);
  ```
</CodeGroup>

***

## 엔드포인트 개요

| Method | Endpoint                                                   | Description        |
| :----- | :--------------------------------------------------------- | :----------------- |
| GET    | [`/2/lists/:id`](/x-api/lists/get-list-by-id)              | ID로 List 가져오기      |
| GET    | [`/2/users/:id/owned_lists`](/x-api/users/get-owned-lists) | 사용자가 소유한 List 가져오기 |

***

## 필드 및 확장

### 기본 응답

```json theme={null}
{
  "data": {
    "id": "84839422",
    "name": "Tech News"
  }
}
```

### 사용 가능한 필드

<Accordion title="list.fields">
  | Field            | Description    |
  | :--------------- | :------------- |
  | `created_at`     | List 생성 타임스탬프  |
  | `description`    | List 설명        |
  | `follower_count` | 팔로워 수          |
  | `member_count`   | 멤버 수           |
  | `owner_id`       | 소유자의 사용자 ID    |
  | `private`        | List가 비공개인지 여부 |
</Accordion>

<Accordion title="user.fields (owner_id expansion 필요)">
  | Field               | Description  |
  | :------------------ | :----------- |
  | `username`          | 소유자의 @handle |
  | `name`              | 소유자의 표시 이름   |
  | `verified`          | 소유자의 인증 상태   |
  | `profile_image_url` | 소유자의 아바타 URL |
</Accordion>

### expansion을 사용한 예시

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl "https://api.x.com/2/lists/84839422?\
  list.fields=description,member_count,follower_count,owner_id&\
  expansions=owner_id&\
  user.fields=username,verified" \
    -H "Authorization: Bearer $BEARER_TOKEN"
  ```

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

  client = Client(bearer_token="YOUR_BEARER_TOKEN")

  # owner expansion과 함께 List 가져오기
  response = client.lists.get(
      list_id="84839422",
      list_fields=["description", "member_count", "follower_count", "owner_id"],
      expansions=["owner_id"],
      user_fields=["username", "verified"]
  )

  print(response.data)
  print(response.includes)  # owner user 객체 포함
  ```

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

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

  const response = await client.lists.get("84839422", {
    listFields: ["description", "member_count", "follower_count", "owner_id"],
    expansions: ["owner_id"],
    userFields: ["username", "verified"],
  });

  console.log(response.data);
  console.log(response.includes); // owner user 객체 포함
  ```
</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": {
    "id": "84839422",
    "name": "Tech News",
    "description": "Top tech journalists",
    "member_count": 50,
    "follower_count": 1250,
    "owner_id": "2244994945"
  },
  "includes": {
    "users": [
      {
        "id": "2244994945",
        "username": "XDevelopers",
        "verified": true
      }
    ]
  }
}
```

<Card title="Fields 및 expansions 가이드" icon="sliders" href="/x-api/fundamentals/fields">
  응답 커스터마이징에 대해 자세히 알아보기
</Card>

***

## 페이지네이션

소유한 List를 조회할 때 결과는 페이지네이션됩니다:

<CodeGroup dropdown>
  ```bash cURL theme={null}
  # 첫 번째 요청
  curl "https://api.x.com/2/users/123/owned_lists?max_results=100" \
    -H "Authorization: Bearer $BEARER_TOKEN"

  # 페이지네이션 토큰을 사용한 다음 요청
  curl "https://api.x.com/2/users/123/owned_lists?max_results=100&pagination_token=NEXT_TOKEN" \
    -H "Authorization: Bearer $BEARER_TOKEN"
  ```

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

  client = Client(bearer_token="YOUR_BEARER_TOKEN")

  # SDK가 페이지네이션을 자동으로 처리
  all_lists = []

  for page in client.lists.get_user_owned_lists(user_id="123", max_results=100):
      if page.data:
          all_lists.extend(page.data)

  print(f"Found {len(all_lists)} lists")
  ```

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

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

  async function getAllOwnedLists(userId) {
    const allLists = [];

    // SDK가 페이지네이션을 자동으로 처리
    const paginator = client.lists.getUserOwnedLists(userId, { maxResults: 100 });

    for await (const page of paginator) {
      if (page.data) {
        allLists.push(...page.data);
      }
    }

    return allLists;
  }

  // 사용 예시
  const lists = await getAllOwnedLists("123");
  console.log(`Found ${lists.length} lists`);
  ```
</CodeGroup>

<Card title="페이지네이션 가이드" icon="https://mintcdn.com/x-preview/Vn2KEkZaPF9LiPi3/icons/xds/icon-arrow-right.svg?fit=max&auto=format&n=Vn2KEkZaPF9LiPi3&q=85&s=88e933002782dbdeb204043cedef033e" href="/x-api/fundamentals/pagination" width="24" height="24" data-path="icons/xds/icon-arrow-right.svg">
  페이지네이션에 대해 자세히 알아보기
</Card>

***

## 비공개 List

* 비공개 List는 소유자에게만 표시됩니다
* 비공개 List의 세부 정보를 조회하려면 소유자로 인증해야 합니다
* `private` 필드는 List가 비공개인지 여부를 나타냅니다

***

## 오류 처리

| Status | Error             | Solution        |
| :----- | :---------------- | :-------------- |
| 400    | Invalid request   | List ID 형식 확인   |
| 401    | Unauthorized      | 인증 확인           |
| 403    | Forbidden         | List가 비공개일 수 있음 |
| 404    | Not Found         | List가 존재하지 않음   |
| 429    | Too Many Requests | 잠시 후 재시도        |

***

## 다음 단계

<CardGroup cols={2}>
  <Card title="퀵스타트" icon="https://mintcdn.com/x-preview/oR-aRNyj1BKPJtxM/icons/xds/icon-rocket.svg?fit=max&auto=format&n=oR-aRNyj1BKPJtxM&q=85&s=b978d7a9225de31709efbbed5b84e92d" href="/x-api/lists/list-lookup/quickstart" width="24" height="24" data-path="icons/xds/icon-rocket.svg">
    첫 List lookup 요청 만들기
  </Card>

  <Card title="List Posts" icon="https://mintcdn.com/x-preview/ygI6sSJPehlc0qNT/icons/xds/icon-bulleted-list.svg?fit=max&auto=format&n=ygI6sSJPehlc0qNT&q=85&s=b9bf8323233df59c682b0fec8e3f88d5" href="/x-api/lists/list-tweets/introduction" width="24" height="24" data-path="icons/xds/icon-bulleted-list.svg">
    List에서 Post 가져오기
  </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/lists/get-list-by-id" width="24" height="24" data-path="icons/xds/icon-code.svg">
    전체 엔드포인트 문서
  </Card>

  <Card title="예제 코드" icon="github" href="https://github.com/xdevplatform/Twitter-API-v2-sample-code">
    동작하는 코드 예제
  </Card>
</CardGroup>
