Guides
Analytics

Analytics

Pharlo exposes two live analytics endpoints — one for a whole channel, one for a specific post. Each request makes a real-time call to the underlying platform API (YouTube Data API, Meta Graph API) and returns whatever the platform reports at that moment.

If you need long-term historical trends, weekly aggregates, or comparison reports, build them yourself on top of these primitives (or subscribe to the platform APIs directly).

EndpointUse case
GET /api/v1/connections/{id}/channel-statsCurrent subscriber count, total views, total posts
GET /api/v1/connections/{id}/posts/{postId}/statsLive performance of one published post

Both endpoints are billed as PLATFORM tier — each call consumes one Pharlo credit and one quota unit on the underlying platform. Cache responses in your own app if you display them in a UI that updates frequently.


Channel-level stats

Use when you need the current "headline numbers" for a channel — for example, to render a subscriber count next to a connection in your dashboard.

curl https://pharlo.io/api/v1/connections/7f3e1a2b-4c5d-6e7f-8a9b-0c1d2e3f4a5b/channel-stats \
  -H "Authorization: Bearer $DELIVERY_API_KEY"

Post-level stats

Use to fetch the latest performance of an individual post you've published. postId is the id of an assignment whose status is published.

curl https://pharlo.io/api/v1/connections/7f3e1a2b-4c5d-6e7f-8a9b-0c1d2e3f4a5b/posts/a1b2c3d4-e5f6-7890-abcd-ef1234567890/stats \
  -H "Authorization: Bearer $DELIVERY_API_KEY"

Patterns

Caching

Stats responses include a fetchedAt timestamp. Cache the response on your side for at least a few minutes — most use cases don't need second-level freshness, and caching reduces both your bill and the chance of hitting the platform's own rate limits.

Bulk dashboards

Pharlo does not provide a bulk "all channels stats" endpoint. To render a dashboard across many connections, loop over GET /api/v1/connections and call /channel-stats for each one — in parallel where possible, but keep an eye on platform rate limits (a few requests per second per connection is safe).

Handling token expiry

If the connection's OAuth token is expired or missing, the analytics endpoints respond with 409 Conflict. Catch this and call POST /api/v1/connections/{id}/refresh-token, then retry. If refresh-token itself returns expired, the user must re-run the OAuth flow.


See also