YouTube.PollStarted

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
The JSON Schema for the event payload, if available.
schema.json
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "YouTubeGenericPollEvent",
  "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"
    }
  },
  "$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": "d",
  "totalVotes": -502,
  "totalOptions": 762,
  "options": [
    {
      "text": "",
      "votes": 266
    },
    {
      "text": null,
      "votes": 287
    },
    {
      "text": null,
      "votes": 17
    },
    {
      "text": "",
      "votes": -360
    },
    {
      "text": null,
      "votes": -643
    }
  ],
  "eventId": null,
  "publishedAt": "",
  "broadcast": {},
  "isTest": false
}
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.PollStarted" events and register a callback
client.on('YouTube.PollStarted', ({ 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);
});