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

# API 일관성

> X API v2의 모든 endpoint에서 사용되는 일관된 URL, 응답, ID 패턴을 이해하여 통합하는 모든 곳에 동일한 규칙이 적용되도록 합니다.

X API v2는 모든 endpoint에서 일관된 패턴으로 설계되었습니다. 한 endpoint의 동작 방식을 학습하면 동일한 패턴이 다른 모든 곳에 적용됩니다.

***

## 일관된 패턴

### URL 구조

모든 v2 endpoint는 예측 가능한 패턴을 따릅니다:

```
/version/resource/{id}?parameters
/version/resource/verb?parameters
```

예시:

```
/2/tweets/1234567890                    # Get a specific post
/2/tweets/search/recent                 # Search recent posts
/2/users/by/username/xdevelopers        # Get user by username
/2/users/1234/followers                 # Get user's followers
```

### 응답 구조

모든 응답은 동일한 최상위 구조를 사용합니다:

```json theme={null}
{
  "data": { ... },       // Primary object(s)
  "includes": { ... },   // Expanded objects
  "meta": { ... },       // Pagination, counts
  "errors": [ ... ]      // Partial errors (if any)
}
```

### ID 형식

언어 호환성을 보장하기 위해 모든 ID는 문자열로 반환됩니다:

```json theme={null}
{
  "id": "1234567890123456789",
  "author_id": "2244994945"
}
```

***

## Field 및 expansion

동일한 [fields](/x-api/fundamentals/fields) 및 [expansions](/x-api/fundamentals/expansions) 파라미터가 일관되게 동작합니다:

| 객체    | Fields 파라미터    | 적용 범위                         |
| :---- | :------------- | :---------------------------- |
| Post  | `tweet.fields` | Post를 반환하는 모든 endpoint        |
| User  | `user.fields`  | User를 반환하는 모든 endpoint        |
| Media | `media.fields` | 미디어 expansion이 있는 모든 endpoint |
| Poll  | `poll.fields`  | 투표 expansion이 있는 모든 endpoint  |
| Place | `place.fields` | 장소 expansion이 있는 모든 endpoint  |

***

## 객체 스키마

동일한 객체 유형은 어떤 endpoint가 반환하든 동일한 field를 갖습니다:

* 검색으로 얻은 Post는 조회로 얻은 Post와 동일한 field를 갖습니다
* 팔로워로 얻은 User는 검색으로 얻은 User와 동일한 field를 갖습니다
* 확장된(expanded) 객체는 독립형 객체와 일치합니다

***

## 인증

모든 endpoint는 동일한 인증 방법을 사용합니다:

| 방법           | Header 형식                            |
| :----------- | :----------------------------------- |
| Bearer Token | `Authorization: Bearer {token}`      |
| OAuth 1.0a   | `Authorization: OAuth {parameters}`  |
| OAuth 2.0    | `Authorization: Bearer {user_token}` |

***

## 오류 처리

오류는 일관된 형식을 따릅니다:

```json theme={null}
{
  "title": "Invalid Request",
  "detail": "The query parameter is missing",
  "type": "https://api.x.com/2/problems/invalid-request"
}
```

[모든 오류 유형 보기 →](/x-api/fundamentals/response-codes-and-errors)

***

## 페이지네이션

모든 페이지네이션 endpoint는 동일한 토큰 시스템을 사용합니다:

| 파라미터               | 설명                                        |
| :----------------- | :---------------------------------------- |
| `max_results`      | 페이지당 결과 수                                 |
| `pagination_token` | `next_token` 또는 `previous_token`에서 가져온 토큰 |

[페이지네이션에 대해 자세히 알아보기 →](/x-api/fundamentals/pagination)

***

## 명명 규칙

* 미국식 영어 철자(`favorites`가 아닌 `favourites` 아님)
* field 이름에 snake\_case 사용(`author_id`, `created_at`)
* 일관된 용어(field에서 `repost_count`가 아닌 `retweet_count`)

***

## 빈 값

값이 없는 field는 `null`로 반환되지 않고 생략됩니다:

```json theme={null}
// User without a bio
{
  "id": "1234",
  "name": "Example User",
  "username": "example"
  // "description" is omitted, not null
}
```

***

## Entity 일관성

`entities` 객체에는 텍스트에서 파싱된 엔티티만 포함됩니다:

* `urls`
* `hashtags`
* `mentions`
* `cashtags`

미디어 및 투표는 `entities`가 아닌 `attachments`에 있습니다.

***

## 이것이 의미하는 것

<CardGroup cols={2}>
  <Card title="한 번 배우면 어디서든 사용" icon="graduation-cap">
    한 endpoint에서 배운 패턴이 모든 endpoint에 적용됩니다.
  </Card>

  <Card title="예측 가능한 응답" icon="square-check">
    동일한 객체 유형은 API 전체에서 동일한 구조를 가집니다.
  </Card>

  <Card title="더 간단한 코드" icon="https://mintcdn.com/x-preview/ygI6sSJPehlc0qNT/icons/xds/icon-code.svg?fit=max&auto=format&n=ygI6sSJPehlc0qNT&q=85&s=488e23401b19225b89acc0136d242219" width="24" height="24" data-path="icons/xds/icon-code.svg">
    일반적인 패턴에 대한 재사용 가능한 함수를 구축합니다.
  </Card>

  <Card title="쉬운 디버깅" icon="bug">
    일관된 오류 형식이 문제 해결을 단순화합니다.
  </Card>
</CardGroup>

***

## 불일치 신고

불일치를 발견하셨나요? 알려주세요:

* [Developer Forum](https://devcommunity.x.com)
* [Developer Feedback](https://t.co/devfeedback)
