# Форматы событий YouTube

События канала `youtube`. В `data` у всех — [`PlatformEvent`](https://developers.donatty.com/structures/platform-event.md#platformevent), поля, зависящие от типа события, находятся в `details`. Сумма суперчата и суперстикера — [`ExactMoney`](https://developers.donatty.com/structures.md#exactmoney): точная, без округления.

## youtube.subscriber

Зритель подписался на привязанный канал YouTube. `actor` — подписчик. YouTube отдаёт только подписчиков с открытыми подписками, поэтому о подписчике, который их скрывает, событие не приходит. `data` — событие, как его возвращает `GET /v1/platform-events`.

**Канал:** `youtube` (право `youtube:read`)

| Поле | Тип | Описание |
|---|---|---|
| `id` | строка, `evt_…` | Идентификатор публикации: тот же, когда событие досылается из истории канала или публикуется повторно. Повторы отбрасывайте по `data.id`: он же и в REST. |
| `type` | строка, всегда `youtube.subscriber` |  |
| `subject` | строка | Идентификатор события платформы, `pevt_…`: `data.id`. |
| `dataschema` | строка (ссылка), всегда [адрес схемы PlatformEvent](https://api.donatty.com/v1/asyncapi.yaml#/components/schemas/PlatformEvent) |  |
| `data` | [`PlatformEvent`](https://developers.donatty.com/structures/platform-event.md#platformevent) |  |

### Пример

```json
{
  "specversion": "1.0",
  "id": "evt_51bc7fd9-c364-4ea0-b85b-9cd061ce437a",
  "type": "youtube.subscriber",
  "source": "https://api.donatty.com/v1/streamer",
  "subject": "pevt_1d7e3b95-8f20-4a6c-b417-5e9c2d8a0f36",
  "time": "2026-11-09T10:20:43.881201Z",
  "datacontenttype": "application/json",
  "dataschema": "https://api.donatty.com/v1/asyncapi.yaml#/components/schemas/PlatformEvent",
  "data": {
    "id": "pevt_1d7e3b95-8f20-4a6c-b417-5e9c2d8a0f36",
    "platform": "YOUTUBE",
    "type": "youtube.subscriber",
    "accountId": "104857306182736450192",
    "occurredAt": "2026-11-09T10:20:05Z",
    "recordedAt": "2026-11-09T10:20:43.881201Z",
    "actor": {
      "id": "UCq3Lr8VtNb2Kp6YdHs9WmXe",
      "login": null,
      "displayName": "Cool Subscriber",
      "avatarUrl": "https://yt3.ggpht.com/a/UCq3Lr8VtNb2Kp6YdHs9WmXe=s88-c-k"
    },
    "message": null,
    "isTest": false,
    "details": {}
  }
}
```

## youtube.member

Зритель стал спонсором привязанного канала YouTube или перешёл на другой уровень спонсорства. `actor` — спонсор. Одно событие на непрерывный доступ к уровню: спонсор, который ушёл и вернулся или перешёл на другой уровень, — новое событие. Нужны спонсорство на канале и доступ YouTube к списку спонсоров: без них источник указывает `youtube.member` в `unavailableTypes`. `data` — событие, как его возвращает `GET /v1/platform-events`.

**Канал:** `youtube` (право `youtube:read`)

| Поле | Тип | Описание |
|---|---|---|
| `id` | строка, `evt_…` | Идентификатор публикации: тот же, когда событие досылается из истории канала или публикуется повторно. Повторы отбрасывайте по `data.id`: он же и в REST. |
| `type` | строка, всегда `youtube.member` |  |
| `subject` | строка | Идентификатор события платформы, `pevt_…`: `data.id`. |
| `dataschema` | строка (ссылка), всегда [адрес схемы PlatformEvent](https://api.donatty.com/v1/asyncapi.yaml#/components/schemas/PlatformEvent) |  |
| `data` | [`PlatformEvent`](https://developers.donatty.com/structures/platform-event.md#platformevent) |  |

### Пример

```json
{
  "specversion": "1.0",
  "id": "evt_62cd80ea-d475-4fb1-a96c-ade172df548b",
  "type": "youtube.member",
  "source": "https://api.donatty.com/v1/streamer",
  "subject": "pevt_2e8f4ca6-9031-4b7d-8528-6fad3e9b1047",
  "time": "2026-11-09T10:22:16.305477Z",
  "datacontenttype": "application/json",
  "dataschema": "https://api.donatty.com/v1/asyncapi.yaml#/components/schemas/PlatformEvent",
  "data": {
    "id": "pevt_2e8f4ca6-9031-4b7d-8528-6fad3e9b1047",
    "platform": "YOUTUBE",
    "type": "youtube.member",
    "accountId": "104857306182736450192",
    "occurredAt": "2026-11-09T10:21:58Z",
    "recordedAt": "2026-11-09T10:22:16.305477Z",
    "actor": {
      "id": "UCm7Tn2QwRe5Yu8Io1PaSdFg",
      "login": null,
      "displayName": "Loyal Member",
      "avatarUrl": "https://yt3.ggpht.com/a/UCm7Tn2QwRe5Yu8Io1PaSdFg=s88-c-k"
    },
    "message": null,
    "isTest": false,
    "details": {
      "level": "Gold",
      "months": 3,
      "levelSince": "2026-11-09T10:21:58Z",
      "isUpgrade": null
    }
  }
}
```

## youtube.super_chat

Зритель купил суперчат на привязанном канале YouTube. `actor` — зритель, `message` — комментарий, `details.amount` — точная сумма в валюте, которой заплатил зритель, без пересчёта и округления. `data` — событие, как его возвращает `GET /v1/platform-events`.

**Канал:** `youtube` (право `youtube:read`)

| Поле | Тип | Описание |
|---|---|---|
| `id` | строка, `evt_…` | Идентификатор публикации: тот же, когда событие досылается из истории канала или публикуется повторно. Повторы отбрасывайте по `data.id`: он же и в REST. |
| `type` | строка, всегда `youtube.super_chat` |  |
| `subject` | строка | Идентификатор события платформы, `pevt_…`: `data.id`. |
| `dataschema` | строка (ссылка), всегда [адрес схемы PlatformEvent](https://api.donatty.com/v1/asyncapi.yaml#/components/schemas/PlatformEvent) |  |
| `data` | [`PlatformEvent`](https://developers.donatty.com/structures/platform-event.md#platformevent) |  |

### Пример

```json
{
  "specversion": "1.0",
  "id": "evt_73de91fb-e586-4ac2-ba7d-bef283e0659c",
  "type": "youtube.super_chat",
  "source": "https://api.donatty.com/v1/streamer",
  "subject": "pevt_3f9a5db7-a142-4c8e-9639-7abe4fac2158",
  "time": "2026-11-09T10:25:12.640833Z",
  "datacontenttype": "application/json",
  "dataschema": "https://api.donatty.com/v1/asyncapi.yaml#/components/schemas/PlatformEvent",
  "data": {
    "id": "pevt_3f9a5db7-a142-4c8e-9639-7abe4fac2158",
    "platform": "YOUTUBE",
    "type": "youtube.super_chat",
    "accountId": "104857306182736450192",
    "occurredAt": "2026-11-09T10:25:03.112Z",
    "recordedAt": "2026-11-09T10:25:12.640833Z",
    "actor": {
      "id": "UCz1Xc4VbN7mQ0Ws3Ed6Rf9T",
      "login": null,
      "displayName": "Generous Viewer",
      "avatarUrl": "https://yt3.ggpht.com/a/UCz1Xc4VbN7mQ0Ws3Ed6Rf9T=s88-c-k"
    },
    "message": "Great stream!",
    "isTest": false,
    "details": {
      "amount": {
        "value": "5.00",
        "currency": "USD"
      },
      "superChatId": "Cg0KC3N1cGVyY2hhdC0x",
      "tier": 2
    }
  }
}
```

## youtube.super_sticker

Зритель купил суперстикер на привязанном канале YouTube. `actor` — зритель, `details.amount` — точная сумма в валюте, которой заплатил зритель, без пересчёта и округления, `details.sticker` — стикер. `data` — событие, как его возвращает `GET /v1/platform-events`.

**Канал:** `youtube` (право `youtube:read`)

| Поле | Тип | Описание |
|---|---|---|
| `id` | строка, `evt_…` | Идентификатор публикации: тот же, когда событие досылается из истории канала или публикуется повторно. Повторы отбрасывайте по `data.id`: он же и в REST. |
| `type` | строка, всегда `youtube.super_sticker` |  |
| `subject` | строка | Идентификатор события платформы, `pevt_…`: `data.id`. |
| `dataschema` | строка (ссылка), всегда [адрес схемы PlatformEvent](https://api.donatty.com/v1/asyncapi.yaml#/components/schemas/PlatformEvent) |  |
| `data` | [`PlatformEvent`](https://developers.donatty.com/structures/platform-event.md#platformevent) |  |

### Пример

```json
{
  "specversion": "1.0",
  "id": "evt_84efa20c-f697-4bd3-8b8e-cf0394f176ad",
  "type": "youtube.super_sticker",
  "source": "https://api.donatty.com/v1/streamer",
  "subject": "pevt_40ab6ec8-b253-4d9f-a74a-8bcf50bd3269",
  "time": "2026-11-09T10:26:41.027519Z",
  "datacontenttype": "application/json",
  "dataschema": "https://api.donatty.com/v1/asyncapi.yaml#/components/schemas/PlatformEvent",
  "data": {
    "id": "pevt_40ab6ec8-b253-4d9f-a74a-8bcf50bd3269",
    "platform": "YOUTUBE",
    "type": "youtube.super_sticker",
    "accountId": "104857306182736450192",
    "occurredAt": "2026-11-09T10:26:33.490Z",
    "recordedAt": "2026-11-09T10:26:41.027519Z",
    "actor": {
      "id": "UCp5Lk8Jh2Gf6Ds9Az3Xc7Vb",
      "login": null,
      "displayName": "Sticker Fan",
      "avatarUrl": "https://yt3.ggpht.com/a/UCp5Lk8Jh2Gf6Ds9Az3Xc7Vb=s88-c-k"
    },
    "message": null,
    "isTest": false,
    "details": {
      "amount": {
        "value": "500",
        "currency": "JPY"
      },
      "superChatId": "Cg0KC3N1cGVyc3RpY2tlcg",
      "tier": 1,
      "sticker": {
        "id": "sticker_cat_wave",
        "altText": "A cat waving its paw"
      }
    }
  }
}
```
