> ## Documentation Index
> Fetch the complete documentation index at: https://docs.postsyncer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Analytics - by post

> Aggregated analytics for one post across all accounts, plus per-account metrics

## By post

Returns **cumulative** engagement metrics for a single post (summed across every connected account / platform row) and a **per-account** breakdown. The only input is the **post ID** in the path (no query parameters).

Metrics match the `analytics` object on each item under `platforms` when you [get a post](/api-reference/posts/get): `comments`, `likes`, `shares`, `impressions`, `quotes`, `saves`, and `engagement_rate`.

For **published** platform rows, `analytics` uses the same values as the dashboard sync. For non-published rows, `analytics` is an empty object `{}`.

The **`total.engagement_rate`** value is a **weighted average** by impressions across published rows when any row has impressions; otherwise it falls back to a simple average of non-zero rates.

### Request

<ParamField path="post" type="integer" required>
  Post primary key (same id as in `/posts/{id}`).
</ParamField>

<RequestExample>
  ```bash theme={null}
  curl -X GET "https://postsyncer.com/api/v1/analytics/posts/743" \
    -H "Authorization: Bearer YOUR_API_TOKEN"
  ```
</RequestExample>

### Response

<ResponseField name="post_id" type="integer">
  The post id from the path
</ResponseField>

<ResponseField name="total" type="object">
  Cumulative metrics: `comments`, `likes`, `shares`, `impressions`, `quotes`, `saves`, `engagement_rate`
</ResponseField>

<ResponseField name="accounts" type="array">
  One entry per platform post row: `account_id`, `platform`, `status`, `post_url`, `analytics`, and `account` (same shape as list-accounts when present)
</ResponseField>

<ResponseExample>
  ```json theme={null}
  {
    "post_id": 743,
    "total": {
      "comments": 16,
      "likes": 84,
      "shares": 12,
      "impressions": 2500,
      "quotes": 4,
      "saves": 20,
      "engagement_rate": 4.25
    },
    "accounts": [
      {
        "account_id": 55,
        "platform": "twitter",
        "status": "PUBLISHED",
        "post_url": "https://twitter.com/user/status/123",
        "analytics": {
          "comments": 8,
          "likes": 42,
          "shares": 8,
          "impressions": 1250,
          "quotes": 2,
          "saves": 12,
          "engagement_rate": 4.4
        },
        "account": {
          "id": 55,
          "workspace_id": 12,
          "platform": "twitter",
          "username": "example",
          "name": "Example",
          "avatar": "https://…",
          "has_expired": false,
          "is_default": false,
          "support_threads": true,
          "is_verified": false
        }
      }
    ]
  }
  ```
</ResponseExample>

### Permissions

Requires the same **`posts`** ability as other post endpoints.

### Error codes

<ResponseField name="401" type="Unauthorized">
  Missing or invalid API token
</ResponseField>

<ResponseField name="403" type="Forbidden">
  Token does not have the `posts` permission
</ResponseField>

<ResponseField name="404" type="Not Found">
  Post does not exist or is not in any workspace the user can access
</ResponseField>

### Code examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://postsyncer.com/api/v1/analytics/posts/743" \
    -H "Authorization: Bearer YOUR_API_TOKEN"
  ```

  ```javascript Node.js theme={null}
  const axios = require('axios');

  const getPostAnalytics = async (postId) => {
    const { data } = await axios.get(
      `https://postsyncer.com/api/v1/analytics/posts/${postId}`,
      { headers: { Authorization: 'Bearer YOUR_API_TOKEN' } }
    );
    return data;
  };
  ```

  ```python Python theme={null}
  import requests

  r = requests.get(
      'https://postsyncer.com/api/v1/analytics/posts/743',
      headers={'Authorization': 'Bearer YOUR_API_TOKEN'},
  )
  r.raise_for_status()
  print(r.json()['total'])
  ```
</CodeGroup>

See also: [Analytics overview](/api-reference/analytics/overview).
