X (Twitter) analytics API: the metrics PubNio reads

PubNio's X (Twitter) adapter declares 10 post metrics and 12 account metrics as supported. It re-reads each post on a schedule for 366 days after publishing. A metric X (Twitter) does not report comes back as null with a reason.

X (Twitter): LiveView as Markdown

What PubNio returns

MetricPost fieldAccount field
impressionsimpression_countsum of posts' impression_count
viewsimpression_countsum of posts' impression_count
likeslike_countsum of posts' like_count
commentsreply_countsum of posts' reply_count
sharesrepost_count + quote_countsum of posts' reposts + quotes
savesbookmark_countsum of posts' bookmark_count
clicksnot returned: not_exposedlink + profile clicks (non-public)
link_clicksurl_link_clicks (non-public; posts up to 30 days old only)sum of posts' url_link_clicks (non-public)
profile_visitsuser_profile_clicks (non-public; posts up to 30 days old only)sum of posts' user_profile_clicks (non-public)
followers—followers_count
engagementderivedderived
engagement_ratederivedderived

X returns no value for the other keys, reach, page_views, follows, follower_gained, follower_lost, watch_time_ms, avg_watch_time_ms, and completion_rate: the adapter marks each not_exposed or leaves it out.

“Not declared” means the adapter's capabilities leave the metric out. A post reading then comes back unsupported with reason not_exposed; an account reading comes back pending with reason account_analytics_pending and stays there, because the account sync reads only declared metrics.

How PubNio reads it

  • X account metrics other than followers are sums over the account's own posts created in the range, read from its posts timeline 100 at a time for at most 10 pages. Past 1,000 posts PubNio stops paging and records the sync run as partial, so the totals undercount; the account response carries no partial flag. Each daily point is the posts created that day.
  • followers is the user's followers_count from the user lookup, read on every account sync.

PubNio reads an X post no sooner than 30 minutes after it is published; a post the sync pass finds later is read when it is found. After the first read it reads every 30 minutes until it is a day old, every 6 hours until day 7, daily until day 30, and weekly after that. It stops reading the post 366 days after publishing. A refresh request does not wait for that: it reads the post as soon as 15 minutes after publishing.

X returns lifetime totals for a post, so PubNio stores each read's increase on the UTC day of the read. The first read puts the whole total on that day, only summed metrics get daily points, and a total that drops is stored as zero, not a negative day.

Account metrics are read once a day, each time for the UTC dates from 30 days before the read through the day of the read, and readings count as stale two days after the last read.

Capabilities also declare latencySeconds: 3600, how long the adapter expects X's numbers to take to settle. PubNio publishes the figure; reads are scheduled only by the rules above.

PubNio's X analytics capabilities require these OAuth scopes on the connected account: tweet.read, users.read. When one is missing, the sync marks the metrics permission_missing and lists what is absent in missingScopes.

clicks: PubNio returns X clicks only for accounts, as link clicks plus profile clicks summed over the account's posts in the range. A single post's clicks is unsupported with reason not_exposed; ask for link_clicks and profile_visits instead.

  • A post adds to account clicks only when it carried at least one of url_link_clicks or user_profile_clicks; both are non-public counts.

Example

impressions is declared, and no daily account read has stored it yet, so it is pending with reason not_published until the first read lands. reach and follower_gained are metrics X does not supply: each comes back unsupported with its reason. The request answers 200 with one entry per key.

request.http
GET /api/v1/workspaces/4e5f6a7b-8c9d-4e0f-9a1b-2c3d4e5f6a7b/analytics/accounts/7f3c2a10-5b4e-4d6f-8a9b-0c1d2e3f4a5b?metrics=impressions&metrics=reach&metrics=follower_gained
Authorization: Bearer pn_live_***
response-metrics.json
[
  {
    "key": "impressions",
    "value": null,
    "availability": "pending",
    "reason": "not_published"
  },
  {
    "key": "reach",
    "value": null,
    "availability": "unsupported",
    "reason": "not_exposed"
  },
  {
    "key": "follower_gained",
    "value": null,
    "availability": "unsupported",
    "reason": "not_exposed"
  }
]

Limits

  • No reach, follows, watch time, or completion rate for X, and no followers gained or lost for accounts.
  • A request covers at most 366 days and 30 metrics, in UTC dates, and defaults to the last 30 days. How far back a daily series reaches depends on the workspace plan, and stored daily points are deleted after 400 days.