Analytics
Get Account Analytics
Returns account-level insights, read live from the platform. Available for Instagram professional accounts and Facebook Pages.
BearerAuthorizationBearer <op_>Workspace API key, sent as Authorization: Bearer op_... Keys are created in the dashboard.
id*string1 <= lengthmetrics?stringComma-separated metric names. Instagram defaults to views, reach, accounts_engaged and total_interactions. Facebook defaults to page_media_view, page_total_media_view_unique, page_post_engagements, page_follows and page_daily_follows_unique.
1 <= length <= 500period?stringAggregation period. Defaults to day.
"day""week""days_28""lifetime"since?stringStart of the range.
date-timeuntil?stringEnd of the range.
date-timebreakdown?stringInstagram: breakdown for demographic metrics, such as age, city, country or gender.
1 <= length <= 64timeframe?stringInstagram: timeframe for demographic metrics, such as this_month or this_week.
1 <= length <= 32metricType?stringInstagram: total_value for one total over the period, time_series for daily values. When omitted, each metric is read the way Instagram reports it.
"total_value""time_series"Account analytics
application/json- response
accountId*stringplatform*|The platform id. New platforms can be added, so handle a value you do not know.
metrics*array<>One entry per metric, with its values over the period.
demographics*Breakdowns by dimension, keyed by metric name.
import { Configuration, AnalyticsApi } from "@onepostly/sdk";const analyticsApi = new AnalyticsApi( new Configuration({ accessToken: process.env.ONEPOSTLY_API_KEY }));const response = await analyticsApi.getAccountAnalytics({ id: "acc_YOUR_INSTAGRAM_ACCOUNT_ID", metrics: "reach,views", period: "day",});console.log(response);{ "accountId": "acc_YOUR_INSTAGRAM_ACCOUNT_ID", "platform": "instagram", "metrics": [ { "name": "reach", "period": "day", "values": [ { "value": 3120, "endTime": null } ] }, { "name": "views", "period": "day", "values": [ { "value": 8450, "endTime": null } ] } ], "demographics": {}}