Skip to content

Post Stats

Endpoint

GET /api/v1/analytics/posts/:id

Returns the latest post_stats snapshot per channel for the given post — plus historical snapshots if the platform's fetched_at series has multiple entries.

Schema

The post_stats collection is the canonical engagement store. Per-snapshot fields:

typescript
{
  post_id: ObjectId,            // → Posts
  account_id: ObjectId,          // → Accounts (channel)
  social_network: string,        // "x", "instagram", ...
  post_social_id: string,        // platform-side post id
  status: number,
  impressions: number,
  likes: number,
  comments: number,
  shares: number,
  reach: number,
  engagement_rate: number,
  fetched_at: Date,
  message?: string,              // platform error if status indicates failure
  // category, type, module, labels, campaign — copied from the parent post
}

Indexes { post_id: 1, fetched_at: -1 } and { account_id: 1, fetched_at: -1 } keep both per-post and per-channel timelines fast.

Sync cadence

The publishing flow writes a snapshot the moment a post is sent. A scheduled stats-refresh job re-fetches each public post over the next 24 hours so engagement settles into a final value. Cadence varies per platform — quotas and rate limits dictate how often Sosyabot can poll.

Engagement rate

engagement_rate is computed at write time as a percentage of reach (or impressions if reach isn't returned by the platform). Use it as the primary normalised KPI when comparing channels with different audience sizes.