# YouTube follows in the PubNio analytics API

For a YouTube video, `follows` is `subscribersGained` from a report filtered to that video. For the channel, PubNio reads `subscribersGained` as `follower_gained` and `subscribersLost` as `follower_lost`, and `followers` is the channel's `subscriberCount`. Channel `follows` is not declared at all.

## What PubNio returns

| Metric | Scope | YouTube field | Unit | Combines by |
| --- | --- | --- | --- | --- |
| `follows` | post | `subscribersGained` | count | sum |
| `follows` | account | not declared | count | sum |
| `follower_gained` | account | `subscribersGained` | count | sum |
| `follower_lost` | account | `subscribersLost` | count | sum |
| `followers` | account | `subscriberCount` | count | latest |

`follows`: New follows attributed to the post or gained in the period.

`follower_gained`: Followers gained in the period.

`follower_lost`: Followers lost in the period.

`followers`: Current follower or subscriber count; a stock, never summed.

## How PubNio reads it

- The subscriber count is parsed from the Data API response, which may send it as a string; a value that is not a finite number is dropped rather than stored.
- An account metric missing from the capability list, such as channel `follows`, is not refused: the API returns it `pending` with reason `account_analytics_pending`. The account sync reads only supported metrics, so it stays pending.

## Example

The capabilities endpoint answers without calling YouTube. Under the YouTube provider, these are its entries for `follows`.

```http
GET /api/v1/workspaces/4e5f6a7b-8c9d-4e0f-9a1b-2c3d4e5f6a7b/analytics/capabilities
Authorization: Bearer pn_live_***
```

```json
[
  {
    "key": "follows",
    "scope": "post",
    "granularity": "day",
    "unit": "count",
    "aggregation": "sum",
    "availability": "available",
    "supported": true,
    "renamedFrom": "subscribersGained"
  }
]
```

## Limits

- PubNio stops re-reading a YouTube post 366 days after it is published, so a post's `follows` stops changing then.
- A metric YouTube does not report comes back with `value: null` and an availability state that says why. A post with no stored values whose last read failed on permissions, a rate limit, or a transient error answers with that error instead.

## Related

- [YouTube analytics API: the metrics PubNio reads](https://pubnio.com/platforms/youtube/analytics)
- [YouTube OAuth scopes](https://pubnio.com/docs/providers/youtube/scopes/)
- [API reference: analytics capabilities](https://pubnio.com/docs/reference/analytics-capabilities-get/)

