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

# Likes

> Likes エンドポイントを使用すると、投稿にいいねを付けたり外したり、投稿にいいねを付けたユーザーを表示したり、ユーザーがいいねを付けた投稿を取得したりできます。likes を扱う X API v2 スタンダードティアのリファレンス。

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

Likes エンドポイントを使用すると、投稿にいいねを付けたり外したり、投稿にいいねを付けたユーザーを表示したり、ユーザーがいいねを付けた投稿を取得したりできます。

## 概要

<CardGroup cols={2}>
  <Card title="投稿にいいねを付ける" icon="https://mintcdn.com/x-preview/szd6PKNMlRQoyyAo/icons/xds/icon-heart.svg?fit=max&auto=format&n=szd6PKNMlRQoyyAo&q=85&s=3a435e6393c019d681c6f1a0737e21a8" width="24" height="24" data-path="icons/xds/icon-heart.svg">
    ユーザーの代理で投稿にいいねを付ける
  </Card>

  <Card title="投稿のいいねを外す" icon="heart-crack">
    投稿からいいねを取り消す
  </Card>

  <Card title="いいねしたユーザー" icon="https://mintcdn.com/x-preview/SxzTbJaLjs3MidH1/icons/xds/icon-people.svg?fit=max&auto=format&n=SxzTbJaLjs3MidH1&q=85&s=9d5f3f82edcd2a4070364193436e7980" width="24" height="24" data-path="icons/xds/icon-people.svg">
    投稿にいいねを付けたユーザーを表示
  </Card>

  <Card title="いいねした投稿" icon="list-heart">
    ユーザーがいいねを付けた投稿を取得
  </Card>
</CardGroup>

***

## エンドポイント

### いいねルックアップ

| Method | Endpoint                                                      | Description       |
| :----- | :------------------------------------------------------------ | :---------------- |
| GET    | [`/2/tweets/:id/liking_users`](/x-api/posts/get-liking-users) | 投稿にいいねを付けたユーザーを取得 |
| GET    | [`/2/users/:id/liked_tweets`](/x-api/users/get-liked-posts)   | ユーザーがいいねを付けた投稿を取得 |

### いいねの管理

| Method | Endpoint                                                   | Description |
| :----- | :--------------------------------------------------------- | :---------- |
| POST   | [`/2/users/:id/likes`](/x-api/users/like-post)             | 投稿にいいねを付ける  |
| DELETE | [`/2/users/:id/likes/:tweet_id`](/x-api/users/unlike-post) | 投稿のいいねを外す   |

***

## 重要事項

<Note>
  liking users エンドポイントは、実際のいいね数に関係なく、投稿ごとに全期間で最大 **100 ユーザー** を返します。
</Note>

***

## 例: いいねしたユーザーを取得する

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

## 例: 投稿にいいねを付ける

```bash theme={null}
curl -X POST "https://api.x.com/2/users/123456789/likes" \
  -H "Authorization: Bearer $USER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"tweet_id": "1234567890"}'
```

***

## はじめる

<Note>
  **前提条件**

  * 承認済みの[開発者アカウント](https://developer.x.com/en/portal/petition/essential/basic-info)
  * 開発者コンソール内の [Project と App](/resources/fundamentals/developer-apps)
  * App の[キーとトークン](/resources/fundamentals/authentication)
</Note>

<CardGroup cols={2}>
  <Card title="ルックアップクイックスタート" icon="https://mintcdn.com/x-preview/szd6PKNMlRQoyyAo/icons/xds/icon-heart.svg?fit=max&auto=format&n=szd6PKNMlRQoyyAo&q=85&s=3a435e6393c019d681c6f1a0737e21a8" href="/x-api/posts/likes/quickstart/likes-lookup" width="24" height="24" data-path="icons/xds/icon-heart.svg">
    投稿のいいねを取得
  </Card>

  <Card title="管理クイックスタート" icon="plus" href="/x-api/posts/likes/quickstart/manage-likes">
    投稿にいいねを付ける・外す
  </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/posts/get-liking-users" 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>
