YouTube.PollClosed

WebSocket event schema, payload, and examples
The properties defined in the event schema, with descriptions.
broadcast
object required
eventId
string
isTest
boolean required
options
YouTubePollOptionData[]
publishedAt
string required
question
string
totalOptions
integer required
totalVotes
integer required
winningOption
object required
The JSON Schema for the event payload, if available.
schema.json
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "YouTubePollClosedEvent",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "question": {
      "type": [
        "null",
        "string"
      ]
    },
    "totalVotes": {
      "type": "integer"
    },
    "totalOptions": {
      "type": "integer"
    },
    "options": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/YouTubePollOptionData"
      }
    },
    "eventId": {
      "type": [
        "null",
        "string"
      ]
    },
    "publishedAt": {
      "type": "string"
    },
    "broadcast": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/$defs/YouTubeBroadcastWebsocketData"
        }
      ]
    },
    "isTest": {
      "type": "boolean"
    },
    "winningOption": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/$defs/YouTubePollOptionData"
        }
      ]
    }
  },
  "$defs": {
    "YouTubePollOptionData": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "text": {
          "type": [
            "null",
            "string"
          ]
        },
        "votes": {
          "type": "integer"
        }
      }
    },
    "YouTubeBroadcastWebsocketData": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": [
            "null",
            "string"
          ]
        },
        "channelId": {
          "type": [
            "null",
            "string"
          ]
        },
        "liveChatId": {
          "type": [
            "null",
            "string"
          ]
        },
        "title": {
          "type": [
            "null",
            "string"
          ]
        },
        "description": {
          "type": [
            "null",
            "string"
          ]
        },
        "categoryId": {
          "type": [
            "null",
            "string"
          ]
        },
        "privacy": {
          "type": [
            "null",
            "string"
          ]
        },
        "publishedAt": {
          "type": "string"
        },
        "scheduledStartTime": {
          "type": "string"
        },
        "scheduledEndTime": {
          "type": "string"
        },
        "actualStartTime": {
          "type": "string"
        },
        "actualEndTime": {
          "type": "string"
        },
        "tags": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "string"
          }
        },
        "defaultLanguage": {
          "type": [
            "null",
            "string"
          ]
        },
        "defaultAudioLanguage": {
          "type": [
            "null",
            "string"
          ]
        },
        "status": {
          "type": [
            "null",
            "string"
          ]
        }
      }
    }
  }
}
An example JSON payload for the event, automatically generated using JSONSchemaFaker
example.json
{
  "question": "ezpUwMb",
  "totalVotes": 976,
  "totalOptions": -255,
  "options": [
    {
      "text": null,
      "votes": 424
    },
    {
      "text": "U5",
      "votes": 178
    },
    {
      "text": "ILwcvtZ",
      "votes": 664
    },
    {
      "text": "BUUdbr",
      "votes": -345
    },
    {
      "text": "",
      "votes": -427
    }
  ],
  "eventId": "D",
  "publishedAt": "NXgWtqr2m",
  "broadcast": {},
  "isTest": true,
  "winningOption": {}
}
Example code showing how to subscribe to this event using the Streamer.bot WebSocket Client
index.js
// Initialize the Streamer.bot WebSocket Client
const client = new StreamerbotClient();

// Subscribe to "YouTube.PollClosed" events and register a callback
client.on('YouTube.PollClosed', ({ event, data }) => {
  // Code here will run every time the event is received!
  console.log('Received event:', event.source, event.type);
  console.log('Event data:', data);
});