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

# 통합 가이드

> Blocks 엔드포인트 통합을 위한 핵심 개념과 모범 사례

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

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

***

<div id="authentication">
  ## 인증
</div>

차단(Block) 엔드포인트에는 사용자 인증이 필요합니다:

| Method                                                                                                                            | Description       |
| :-------------------------------------------------------------------------------------------------------------------------------- | :---------------- |
| [OAuth 2.0 Authorization Code with PKCE](/ko/resources/fundamentals/authentication#oauth-2-0-authorization-code-flow-with-pkce-2) | 새로운 애플리케이션에 권장됩니다 |
| [OAuth 1.0a User Context](/ko/resources/fundamentals/authentication)                                                              | 기존 방식(레거시) 지원용    |

<Warning>
  App-Only 인증은 지원되지 않습니다. 반드시 사용자 계정을 대신하여 인증해야 합니다.
</Warning>

<div id="required-scopes-oauth-20">
  ### 필수 스코프(OAuth 2.0)
</div>

| Scope         | 필요한 작업              |
| :------------ | :------------------ |
| `block.read`  | 차단된 계정 조회           |
| `block.write` | 계정 차단 및 차단 해제       |
| `users.read`  | block 관련 스코프와 함께 필요 |

***

<div id="endpoints-overview">
  ## 엔드포인트 개요
</div>

| Method | Endpoint                                            | Description  |
| :----- | :-------------------------------------------------- | :----------- |
| GET    | `/2/users/:id/blocking`                             | 차단된 계정 목록 조회 |
| POST   | `/2/users/:id/blocking`                             | 계정 차단        |
| DELETE | `/2/users/:source_user_id/blocking/:target_user_id` | 계정 차단 해제     |

***

<div id="fields-and-expansions">
  ## 필드 및 expansions
</div>

<div id="default-response">
  ### 기본 응답
</div>

```json theme={null}
{
  "data": [
    {
      "id": "1234567890",
      "name": "Example User",
      "username": "example"
    }
  ]
}
```

<div id="available-fields">
  ### 사용 가능한 필드
</div>

<Accordion title="user.fields">
  | 필드                  | 설명          |
  | :------------------ | :---------- |
  | `created_at`        | 계정 생성 일시    |
  | `description`       | 사용자 소개      |
  | `profile_image_url` | 프로필 이미지 URL |
  | `public_metrics`    | 팔로워/팔로잉 수   |
  | `verified`          | 인증 상태       |
</Accordion>

<Accordion title="expansions">
  | 확장                | 설명             |
  | :---------------- | :------------- |
  | `pinned_tweet_id` | 사용자가 고정해 둔 게시물 |
</Accordion>

***

<div id="what-happens-when-you-block">
  ## 차단하면 어떻게 되나요
</div>

<CardGroup cols={2}>
  <Card title="상대방이 할 수 없는 것" icon="xmark">
    * (로그아웃한 상태가 아니라면) 내 포스트 보기
    * 나를 팔로우하기
    * 나에게 DM 보내기
    * 나를 리스트에 추가하기
    * 사진에서 나를 태그하기
  </Card>

  <Card title="내가 할 수 없는 것" icon="xmark">
    * 상대방의 포스트 보기
    * 상대방을 팔로우하기
    * 상대방에게 DM 보내기
  </Card>
</CardGroup>

<Note>
  나를 팔로우하는 사용자를 차단하면, 그 사용자는 자동으로 팔로우가 해제됩니다.
</Note>

***

<div id="pagination">
  ## 페이지네이션
</div>

차단 목록이 많은 사용자의 경우 결과가 페이지네이션 방식으로 제공됩니다:

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

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

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

  # OAuth 2.0 사용자 액세스 토큰 사용
  client = Client(bearer_token="YOUR_USER_ACCESS_TOKEN")

  # SDK가 페이지네이션을 자동으로 처리합니다
  all_blocked = []

  for page in client.users.get_blocking(user_id="123", max_results=100):
      if page.data:
          all_blocked.extend(page.data)

  print(f"Blocked {len(all_blocked)} users")
  ```

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

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

  async function getAllBlockedUsers(userId) {
    const allBlocked = [];

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

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

    return allBlocked;
  }

  // 사용 예시
  const blocked = await getAllBlockedUsers("123");
  console.log(`Blocked ${blocked.length} users`);
  ```
</CodeGroup>

***

<div id="error-handling">
  ## 오류 처리
</div>

| Status | 오류        | 해결 방법             |
| :----- | :-------- | :---------------- |
| 400    | 잘못된 요청    | 사용자 ID 형식을 확인하세요  |
| 401    | 인증되지 않음   | 액세스 토큰을 확인하세요     |
| 403    | 권한 없음     | scope 및 권한을 확인하세요 |
| 404    | 찾을 수 없음   | 사용자가 존재하지 않습니다    |
| 429    | 요청이 너무 많음 | 잠시 기다렸다가 다시 시도하세요 |

***

<div id="next-steps">
  ## 다음 단계
</div>

<CardGroup cols={2}>
  <Card title="빠른 시작" icon="rocket" href="/ko/x-api/users/blocks/quickstart">
    첫 blocks 요청을 만들어 보세요
  </Card>

  <Card title="Mutes" icon="volume-xmark" href="/ko/x-api/users/mutes/introduction">
    차단 대신 사용자를 뮤트하세요
  </Card>

  <Card title="API 참조 문서" icon="code" href="/ko/x-api/users/get-blocking">
    전체 엔드포인트 문서
  </Card>

  <Card title="샘플 코드" icon="github" href="https://github.com/xdevplatform/Twitter-API-v2-sample-code">
    실행 가능한 코드 예제
  </Card>
</CardGroup>
