> ## Documentation Index
> Fetch the complete documentation index at: https://x-preview-oauth-2-ios.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Metrics

## Overview

The metrics field allows developers to access public and private engagement metrics for Post and media objects. Public metrics are accessible by anyone with a developer account, while private metrics are accessible from owned/authorized accounts (definition below). Metrics include the total count of impressions, Retweets, Quote Tweets, likes, replies, video views, video view quartiles, URL and profile link clicks for each Post specified in the request. There is also the option to view a breakdown of metrics earned in an organic or promoted context, if the Post was promoted as an [Ad](https://ads.x.com/).

Public metrics can be requested with [App-only Token](/resources/fundamentals/authentication#oauth-2-0) authentication. Non-public metrics can be requested for owned/authorized Posts only, meaning developers need to authenticate using [OAuth 2.0](/resources/fundamentals/authentication#oauth-2-0-authorization-code-flow-with-pkce-3) or [OAuth 1.0a](/resources/fundamentals/authentication#oauth-1-0a-2) user context authorization.

**Non-public, organic, and promoted metrics are only available for Posts created within the last 30 days.**

### Terminology

* **Authorized account**: An X account that has authorized your [X developer app](/resources/fundamentals/developer-apps) by granting it access to that account (any [app permission level](/resources/fundamentals/developer-apps#app-permissions) will permit access to Post metrics).
* **Owned account**: An X account linked to your [X developer app](/resources/fundamentals/developer-apps).
* **Public metrics**: Totals that are available for anyone to access on [X](https://x.com/home), such as the number of likes and number of Retweets.
* **Non-public metrics**: Totals not available for public viewing on [X](https://x.com/home), such as the number of impressions and video view quartiles. Requires [OAuth 2.0](/resources/fundamentals/authentication#oauth-2-0-authorization-code-flow-with-pkce-3) or [OAuth 1.0a](/resources/fundamentals/authentication#oauth-1-0a-2) user context authentication.
* **Organic metrics**: A grouping of public and non-public metrics attributed to an organic context (posted and viewed in a regular manner). Requires [OAuth 2.0](/resources/fundamentals/authentication#oauth-2-0-authorization-code-flow-with-pkce-3) or [OAuth 1.0a](/resources/fundamentals/authentication#oauth-1-0a-2) user context authentication.
* **Promoted metrics**: A grouping of public and non-public metrics attributed to a promoted context (posted or viewed as part of an Ads campaign). Requires [OAuth 2.0](/resources/fundamentals/authentication#oauth-2-0-authorization-code-flow-with-pkce-3) or [OAuth 1.0a](/resources/fundamentals/authentication#oauth-1-0a-2) user context authentication and that the Post was promoted in an Ad.

## Available Metrics

| Metric                   | API Representations                                                                                                                                                                                                                                                               | Description                                                                                                                                                                                                                                    |
| :----------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Impressions**          | `data.non_public_metrics.impression_count`, `data.organic_metrics.impression_count`, `data.promoted_metrics.impression_count`                                                                                                                                                     | A count of how many times the Post has been viewed (not unique by user). A view is counted if any part of the Post is visible on the screen. Requires OAuth 1.0a User Context authentication.                                                  |
| **Retweets**             | `data.public_metrics.retweet_count`, `data.organic_metrics.retweet_count`, `data.promoted_metrics.retweet_count`                                                                                                                                                                  | A count of how many times the Post has been Retweeted. Does not include Quote Tweets (“Retweets with comment”). To get the "Retweets and comments" total as displayed on X clients, add `retweet_count` and `quote_count`.                     |
| **Quote Tweets**         | `data.public_metrics.quote_count`                                                                                                                                                                                                                                                 | A count of how many times the Post has been Retweeted with a new comment (message). There are no Quote Tweets from a paid context, so all Quote Tweets are organic.                                                                            |
| **Likes**                | `data.public_metrics.like_count`, `data.organic_metrics.like_count`, `data.promoted_metrics.like_count`                                                                                                                                                                           | A count of how many times the Post has been liked. The `public_metrics` field returns the total count of likes from both organic and paid contexts to maintain consistency with counts shown publicly on X.                                    |
| **Replies**              | `data.public_metrics.reply_count`, `data.organic_metrics.reply_count`, `data.promoted_metrics.reply_count`                                                                                                                                                                        | A count of how many times the Post has been replied to. The `public_metrics` field returns the total count of replies from both organic and paid contexts.                                                                                     |
| **URL Link Clicks**      | `data.non_public_metrics.url_link_clicks`, `data.organic_metrics.url_link_clicks`, `data.promoted_metrics.url_link_clicks`                                                                                                                                                        | A count of the number of times a user clicks on a URL link or URL preview card in a Post. Requires OAuth 1.0a User Context authentication.                                                                                                     |
| **User Profile Clicks**  | `data.non_public_metrics.user_profile_clicks`, `data.organic_metrics.user_profile_clicks`, `data.promoted_metrics.user_profile_clicks`                                                                                                                                            | A count of the number of times a user clicks on portions of a Post: display name, user name, profile picture. Requires OAuth 1.0a User Context authentication.                                                                                 |
| **Video views**          | `includes.media.public_metrics.view_count`, `includes.media.organic_metrics.view_count`, `includes.media.promoted_metrics.view_count`                                                                                                                                             | A count of how many times the video included in the Post has been viewed. This is the number of video views aggregated across all Posts in which the given video has been posted. Requires media expansion `expansions=attachment.media_keys`. |
| **Video view quartiles** | `includes.media.non_public_metrics.playback_0_count`, `includes.media.non_public_metrics.playback_25_count`, `includes.media.non_public_metrics.playback_50_count`, `includes.media.non_public_metrics.playback_75_count`, `includes.media.non_public_metrics.playback_100_count` | The number of users who played through each quartile in a video. Requires OAuth 1.0a User Context authentication and media expansion `expansions=attachment.media_keys`.                                                                       |

## Requesting Metrics

### Public Metrics

In the following request, we are requesting public metrics on the Post and on the attached video with the following fields and expansion. Be sure to replace `$BEARER_TOKEN` with your own generated bearer token.

* `tweet.fields=public_metrics`
* `expansions=attachments.media_keys&media.fields=public_metrics`

#### Sample Request

```bash theme={null}
curl 'https://api.x.com/2/tweets?ids=1204084171334832128&tweet.fields=public_metrics&expansions=attachments.media_keys&media.fields=public_metrics' --header 'Authorization: Bearer $BEARER_TOKEN'
```

### Private Metrics (Non-public, Organic Metrics)

The following request asks for non-public metrics with additional details on organic metrics for the Post and attached video. Since these fields are private and not available for public view on X, the request requires [OAuth 2.0](/resources/fundamentals/authentication#oauth-2-0-authorization-code-flow-with-pkce-3) or [OAuth 1.0a](/resources/fundamentals/authentication#oauth-1-0a-2) user context authentication. Refer to our [guide](/resources/fundamentals/authentication#creating-a-signature) for generating the OAuth 1.0a signature needed below.

* `tweet.fields=non_public_metrics,organic_metrics`
* `expansions=attachments.media_keys&media.fields=non_public_metrics,organic_metrics`

#### Sample Request

```bash theme={null}
curl 'https://api.x.com/2/tweets/1204084171334832128?tweet.fields=non_public_metrics,organic_metrics&media.fields=non_public_metrics,organic_metrics&expansions=attachments.media_keys' --header 'authorization: OAuth oauth_consumer_key="CONSUMER_API_KEY", oauth_nonce="OAUTH_NONCE", oauth_signature="OAUTH_SIGNATURE", oauth_signature_method="HMAC-SHA1", oauth_timestamp="OAUTH_TIMESTAMP", oauth_token="ACCESS_TOKEN", oauth_version="1.0"'
```

#### Sample Response

```
{
  "data": {
    "attachments": {
      "media_keys": ["13_1204080851740315648"]
    },
    "id": "1263145271946551300",
    "non_public_metrics": {
      "impression_count": 956,
      "url_link_clicks": 9,
      "user_profile_clicks": 34
    },
    "organic_metrics": {
      "impression_count": 956,
      "like_count": 49,
      "reply_count": 2,
      "retweet_count": 9,
      "url_link_clicks": 9,
      "user_profile_clicks": 34
    },
    "text": "test"
  },
  "includes": {
    "media": [
      {
        "media_key": "13_1204080851740315648",
        "non_public_metrics": {
          "playback_0_count": 0,
          "playback_100_count": 1,
          "playback_25_count": 2,
          "playback_50_count": 1,
          "playback_75_count": 1
        },
        "organic_metrics": {
          "playback_0_count": 0,
          "playback_100_count": 1,
          "playback_25_count": 2,
          "playback_50_count": 1,
          "playback_75_count": 1,
          "view_count": 1
        },
        "type": "video"
      }
    ]
  }
}
```
