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

# 좋아요 조회

> 게시물을 좋아요한 사용자와 사용자가 좋아요한 포스트 조회

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

이 가이드는 X API를 사용하여 좋아요 데이터를 조회하는 방법을 단계별로 설명합니다.

<Note>
  **사전 준비 사항**

  시작하기 전에 다음이 필요합니다.

  * 승인된 App이 있는 [개발자 계정](https://developer.x.com/en/portal/petition/essential/basic-info)
  * App의 Bearer 토큰(공개 데이터용) 또는 사용자 액세스 토큰(비공개 지표용)
</Note>

***

<div id="get-users-who-liked-a-post">
  ## 게시물을 좋아요한 사용자 가져오기
</div>

특정 게시물에 좋아요를 누른 사용자 목록을 가져옵니다:

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl "https://api.x.com/2/tweets/1354143047324299264/liking_users?\
  user.fields=created_at,username,verified" \
    -H "Authorization: Bearer $BEARER_TOKEN"
  ```

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

  client = Client(bearer_token="YOUR_BEARER_TOKEN")

  # 페이지네이션을 사용해 게시물에 좋아요를 누른 사용자 가져오기
  for page in client.posts.get_liking_users(
      "1354143047324299264",
      user_fields=["created_at", "username", "verified"]
  ):
      for user in page.data:
          print(f"{user.username} - Joined: {user.created_at}")
  ```

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

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

  // 페이지네이션을 사용해 게시물에 좋아요를 누른 사용자 가져오기
  const paginator = client.posts.getLikingUsers("1354143047324299264", {
    userFields: ["created_at", "username", "verified"],
  });

  for await (const page of paginator) {
    page.data?.forEach((user) => {
      console.log(`${user.username} - Joined: ${user.created_at}`);
    });
  }
  ```
</CodeGroup>

<div id="response">
  ### 응답
</div>

```json theme={null}
{
  "data": [
    {
      "created_at": "2008-12-04T18:51:57.000Z",
      "id": "17874544",
      "username": "TwitterSupport",
      "name": "Twitter Support",
      "verified": true
    },
    {
      "created_at": "2007-02-20T14:35:54.000Z",
      "id": "783214",
      "username": "Twitter",
      "name": "Twitter",
      "verified": true
    }
  ],
  "meta": {
    "result_count": 2,
    "next_token": "7140dibdnow9c7btw3z2vwioavpvutgzrzm9icis4ndix"
  }
}
```

***

<div id="get-a-users-liked-posts">
  ## 사용자가 좋아한 포스트 가져오기
</div>

특정 사용자가 좋아요를 누른 포스트를 조회합니다:

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl "https://api.x.com/2/users/2244994945/liked_tweets?\
  tweet.fields=created_at,public_metrics&\
  max_results=10" \
    -H "Authorization: Bearer $BEARER_TOKEN"
  ```

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

  client = Client(bearer_token="YOUR_BEARER_TOKEN")

  # 페이지네이션을 사용해 사용자가 좋아한 포스트를 가져옵니다.
  for page in client.users.get_liked_tweets(
      "2244994945",
      tweet_fields=["created_at", "public_metrics"],
      max_results=10
  ):
      for post in page.data:
          print(f"{post.text[:50]}... - Likes: {post.public_metrics.like_count}")
  ```

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

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

  // 페이지네이션을 사용해 사용자가 좋아한 포스트를 가져옵니다.
  const paginator = client.users.getLikedTweets("2244994945", {
    tweetFields: ["created_at", "public_metrics"],
    maxResults: 10,
  });

  for await (const page of paginator) {
    page.data?.forEach((post) => {
      console.log(`${post.text?.slice(0, 50)}... - Likes: ${post.public_metrics?.like_count}`);
    });
  }
  ```
</CodeGroup>

<div id="response">
  ### 응답
</div>

```json theme={null}
{
  "data": [
    {
      "id": "1362449997430542337",
      "text": "Honored to be the first developer to be featured...",
      "created_at": "2021-02-18T17:45:00.000Z",
      "public_metrics": {
        "retweet_count": 5,
        "reply_count": 2,
        "like_count": 42,
        "quote_count": 1
      }
    }
  ],
  "meta": {
    "result_count": 1,
    "next_token": "7140dibdnow9c7btw4539n0vybdnx19ylpayqf16fjt4l"
  }
}
```

***

<div id="include-additional-data">
  ## 추가 데이터 포함
</div>

expansions 매개변수를 사용해 고정 포스트와 같은 관련 데이터를 가져오세요:

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl "https://api.x.com/2/tweets/1354143047324299264/liking_users?\
  user.fields=created_at&\
  expansions=pinned_tweet_id&\
  tweet.fields=created_at" \
    -H "Authorization: Bearer $BEARER_TOKEN"
  ```

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

  client = Client(bearer_token="YOUR_BEARER_TOKEN")

  # 고정 포스트 expansion을 포함해 좋아요한 사용자 가져오기
  for page in client.posts.get_liking_users(
      "1354143047324299264",
      user_fields=["created_at"],
      expansions=["pinned_tweet_id"],
      tweet_fields=["created_at"]
  ):
      for user in page.data:
          print(f"{user.username}")
      # 고정 포스트는 page.includes.tweets에 있습니다
  ```

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

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

  // 고정 포스트 expansion을 포함해 좋아요한 사용자 가져오기
  const paginator = client.posts.getLikingUsers("1354143047324299264", {
    userFields: ["created_at"],
    expansions: ["pinned_tweet_id"],
    tweetFields: ["created_at"],
  });

  for await (const page of paginator) {
    page.data?.forEach((user) => {
      console.log(user.username);
    });
    # 고정 포스트는 page.includes?.tweets에 있습니다
  }
  ```
</CodeGroup>

***

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

<CardGroup cols={2}>
  <Card title="좋아요 관리" icon="heart" href="/ko/x-api/posts/likes/quickstart/manage-likes">
    포스트에 좋아요를 누르거나 취소하기
  </Card>

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