Analytics

Get Account Analytics

Returns account-level insights, read live from the platform. Available for Instagram professional accounts and Facebook Pages.

GET
/v1/accounts/{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

Query Parameters

metrics?string

Comma-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.

Length1 <= length <= 500
period?string

Aggregation period. Defaults to day.

Value in"day""week""days_28""lifetime"
since?string

Start of the range.

Formatdate-time
until?string

End of the range.

Formatdate-time
breakdown?string

Instagram: breakdown for demographic metrics, such as age, city, country or gender.

Length1 <= length <= 64
timeframe?string

Instagram: timeframe for demographic metrics, such as this_month or this_week.

Length1 <= length <= 32
metricType?string

Instagram: total_value for one total over the period, time_series for daily values. When omitted, each metric is read the way Instagram reports it.

Value in"total_value""time_series"

Response Body

Account analytics

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

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.

Example Request
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);
Example 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": {}}