Analytics

Get Post Analytics

Returns a post's lifetime metrics. Metrics refresh about hourly for posts under 30 days old and about weekly after that. X metrics are read when you ask and charged to the wallet, at most once per post and UTC day. Later requests that day return the same reading at no charge.

GET
/v1/posts/{id}/analytics

Authorization

Bearer
headerAuthorizationBearer <op_>

Workspace API key, sent as Authorization: Bearer op_... Keys are created in the dashboard.

Path Parameters

id*string
Length1 <= length

Response Body

Post analytics

application/json
  1. response
postId*string
accountId*string
platform*|

The platform id. New platforms can be added, so handle a value you do not know.

status*|

ready has metrics. pending waits for the platform's first reading. failed means the last reading failed, and error says why. unavailable means the post can never be measured, because it is not published or the platform never reports metrics for it, such as a deleted post or a TikTok post that is not public. unsupported means the platform has no post metrics. unavailable and unsupported are final. New values can be added, so handle a value you do not know.

metrics*

Lifetime metrics. A metric the platform does not report is null.

fetchedAt*|

When the platform was last read. Null before the first reading, and for X, which is read when you ask.

Formatdate-time
error*|

Why the last reading failed. Null otherwise.

Example Request
import { Configuration, AnalyticsApi } from "@onepostly/sdk";const analyticsApi = new AnalyticsApi(  new Configuration({ accessToken: process.env.ONEPOSTLY_API_KEY }));const response = await analyticsApi.getPostAnalytics({  id: "pst_3c8a2d6e91b44f7a8e250d6b4c1f9a73",});console.log(response);
Example Response
{  "postId": "pst_3c8a2d6e91b44f7a8e250d6b4c1f9a73",  "accountId": "acc_1699f4157fb643f49d2ac447491f32a8",  "platform": "instagram",  "status": "ready",  "metrics": {    "impressions": 1456,    "reach": 987,    "likes": 123,    "comments": 12,    "shares": 4,    "saves": 2,    "views": 1456,    "engagement": 141  },  "fetchedAt": "2027-03-15T10:00:00.000Z",  "error": null}