> ## Documentation Index
> Fetch the complete documentation index at: https://x-preview-mintlify-5e62557c.mintlify.site/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-mintlify-5e62557c/ddgNr7frFLmNFgtn/icons/xds/icon-heart.svg?fit=max&auto=format&n=ddgNr7frFLmNFgtn&q=85&s=c84e5955e47c158561b5e391a996d16a" 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-mintlify-5e62557c/dxXIRy5tzOESXfjK/icons/xds/icon-people.svg?fit=max&auto=format&n=dxXIRy5tzOESXfjK&q=85&s=3df3f471186c3b149f8bf206d86587e3" 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-mintlify-5e62557c/ddgNr7frFLmNFgtn/icons/xds/icon-heart.svg?fit=max&auto=format&n=ddgNr7frFLmNFgtn&q=85&s=c84e5955e47c158561b5e391a996d16a" 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-mintlify-5e62557c/NnGYBQFO1PDkJQK7/icons/xds/icon-code.svg?fit=max&auto=format&n=NnGYBQFO1PDkJQK7&q=85&s=e6a5208c5ad4cc59a4a97fed7db5ed00" 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>
