# X engagement rate in the PubNio analytics API

PubNio computes X post `engagement_rate` as engagement ÷ impressions, where engagement is likes + replies + reposts and quotes + bookmarks. All four parts must be present. A post with zero impressions returns `not_applicable` with reason `zero_impressions` instead of dividing by zero.

## What PubNio returns

| Metric | Scope | X field | Unit | Combines by |
| --- | --- | --- | --- | --- |
| `engagement_rate` | post | derived | ratio | ratio |
| `engagement_rate` | account | derived | ratio | ratio |
| `engagement` | post | derived | count | sum |
| `engagement` | account | derived | count | sum |

`engagement_rate`: Engagement divided by impressions, 0 to 1.

`engagement`: Derived: likes + comments + shares + saves.

## How PubNio reads it

- The account rate works differently. Each post in the range adds the parts it reports, with a missing part counted as zero, and the summed engagement is divided by summed impressions. Each day's rate uses the posts created that day.
- The post derivation is the shared step: it adds engagement only when likes, comments, shares, and saves are all present, and a rate only when impressions are above zero.

## Example

The capabilities endpoint answers without calling X. Under the X provider, these are its entries for `engagement_rate`.

```http
GET /api/v1/workspaces/4e5f6a7b-8c9d-4e0f-9a1b-2c3d4e5f6a7b/analytics/capabilities
Authorization: Bearer pn_live_***
```

```json
[
  {
    "key": "engagement_rate",
    "scope": "post",
    "granularity": "day",
    "unit": "ratio",
    "aggregation": "ratio",
    "availability": "available",
    "supported": true
  },
  {
    "key": "engagement_rate",
    "scope": "account",
    "granularity": "day",
    "unit": "ratio",
    "aggregation": "ratio",
    "availability": "available",
    "supported": true
  }
]
```

## Limits

- PubNio stops re-reading an X post 366 days after it is published, so a post's `engagement_rate` stops changing then.
- An account `engagement_rate` total is the last daily read's value for its window, 30 days before the read through the day of the read, whatever `from` and `to` the request names. Per-day values come from the daily series, which the workspace plan bounds.
- A metric X does not report comes back with `value: null` and an availability state that says why. A post with no stored values whose last read failed on permissions, a rate limit, or a transient error answers with that error instead.

## Related

- [X (Twitter) analytics API: the metrics PubNio reads](https://pubnio.com/platforms/x/analytics)
- [X OAuth scopes](https://pubnio.com/docs/providers/x/scopes/)
- [API reference: analytics capabilities](https://pubnio.com/docs/reference/analytics-capabilities-get/)

