Read daily post analytics series with GET /api/v1/analytics/posts/{postId}/series. Requires an API key with the read scope or a signed-in workspace member.
Request
Daily points use UTC dates. Cumulative metrics set value to the day’s increase and total to the cumulative value; a missing date means no data. How far back from can reach depends on the workspace plan; an earlier date returns plan_required with the earliest allowed date.
| Parameter | In | Type | Required |
|---|---|---|---|
postId |
path | UUID | Yes |
workspaceId |
query | UUID | Yes |
targetId |
query | UUID | No |
from |
query | string | No |
to |
query | string | No |
timezone |
query | string | No |
granularity |
query | "day", "total" |
No |
metrics |
query | array of string | No |
Response
- HTTP 200:
PostAnalyticswithpostId,workspaceId,range,targets,freshness.
The OpenAPI document has each field’s type.
Examples
const series = await workspace.analytics.series(postId, {
metrics: ["views", "likes"],
});series = workspace.analytics.get_post_series(post_id)curl "https://pubnio.com/api/v1/analytics/posts/$POST_ID/series?workspaceId=$WORKSPACE_ID" \
-H "Authorization: Bearer $PUBNIO_API_KEY"pnio analytics posts series "$POST_ID" --metrics views,likesasync () => {
const postId = "<postId>";
const response = await codemode.request({
method: "GET",
path: `/api/v1/analytics/posts/${postId}/series`,
query: { workspaceId: codemode.workspaceId },
});
return response.data;
};Errors
plan-required: HTTP 402, Plan upgrade required
It also declares the problems every Analytics operation and most operations declare.
Idempotency
None needed: a read is safe to retry.
Limits
- Field lengths and ranges are in the OpenAPI document.