Skip to main content

Endpoint

POST https://api.ugc.inc/stats/posts

Overview

Get post statistics including views, likes, comments, shares, and saves. Behavior:
  • If startDate and endDate are NOT provided: Returns the latest stat per post (one record per post) - optimal for dashboards showing current state
  • If startDate or endDate is provided: Returns all stats within the date range - use for historical analysis and trend tracking
Use this endpoint to track post performance over time.

Request Body

postIds
string[]
Array of post IDs to get stats for. Omit to get all posts.
startDate
string
Start date in ISO 8601 format (e.g., 2024-01-01T00:00:00Z). Optional. If omitted (along with endDate), returns latest stat per post.
endDate
string
End date in ISO 8601 format (e.g., 2024-12-31T23:59:59Z). Optional. If omitted (along with startDate), returns latest stat per post.

Response

data
PostStat[]
Array of post statistics objects
curl -X POST https://api.ugc.inc/stats/posts \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "postIds": ["post_123456", "post_789012"],
    "startDate": "2024-01-01T00:00:00Z",
    "endDate": "2024-12-31T23:59:59Z"
  }'
{
  "ok": true,
  "code": 200,
  "message": "Success",
  "data": [
    {
      "id": "pstat_abc123",
      "post_id": "post_123456",
      "views": 125000,
      "likes": 8950,
      "comments": 342,
      "shares": 567,
      "saves": 1234,
      "created_at": "2024-12-25T10:00:00Z"
    },
    {
      "id": "pstat_def456",
      "post_id": "post_123456",
      "views": 128500,
      "likes": 9120,
      "comments": 356,
      "shares": 589,
      "saves": 1289,
      "created_at": "2024-12-26T10:00:00Z"
    }
  ]
}