Twitch.GiftSub

WebSocket event schema, payload, and examples

Properties

user
object required
messageId
string
systemMessage
string
isTest
boolean required
isInSharedChat
boolean required
isSharedChatHost
boolean required
isFromSharedChatGuest
boolean required
durationMonths
integer required
cumlativeTotal
integer required
recipient
object required
subTier
string
communityGiftId
string
fromCommunitySubGift
boolean required
randomCommunitySubGift
boolean required
communitySubGiftCount
integer required
communitySubGiftCumulativeTotal
integer required

Schema

The JSON Schema for the event payload, if available.
schema.json
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "TwitchChatNotification_SubGiftEvent",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "user": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/definitions/TwitchUser"
        }
      ]
    },
    "messageId": {
      "type": [
        "null",
        "string"
      ]
    },
    "systemMessage": {
      "type": [
        "null",
        "string"
      ]
    },
    "isTest": {
      "type": "boolean"
    },
    "isInSharedChat": {
      "type": "boolean"
    },
    "isSharedChatHost": {
      "type": "boolean"
    },
    "isFromSharedChatGuest": {
      "type": "boolean"
    },
    "durationMonths": {
      "type": "integer",
      "format": "int32"
    },
    "cumlativeTotal": {
      "type": "integer",
      "format": "int32"
    },
    "recipient": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "$ref": "#/definitions/TwitchBaseUser"
        }
      ]
    },
    "subTier": {
      "type": [
        "null",
        "string"
      ]
    },
    "communityGiftId": {
      "type": [
        "null",
        "string"
      ]
    },
    "fromCommunitySubGift": {
      "type": "boolean"
    },
    "randomCommunitySubGift": {
      "type": "boolean"
    },
    "communitySubGiftCount": {
      "type": "integer",
      "format": "int32"
    },
    "communitySubGiftCumulativeTotal": {
      "type": "integer",
      "format": "int32"
    }
  },
  "definitions": {
    "TwitchUser": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": [
            "null",
            "string"
          ]
        },
        "login": {
          "type": [
            "null",
            "string"
          ]
        },
        "name": {
          "type": [
            "null",
            "string"
          ]
        },
        "type": {
          "type": [
            "null",
            "string"
          ]
        },
        "role": {
          "$ref": "#/definitions/ViewerRole"
        },
        "badges": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/definitions/TwitchBadge"
          }
        },
        "color": {
          "type": [
            "null",
            "string"
          ]
        },
        "subscribed": {
          "type": "boolean"
        },
        "subscriptionTier": {
          "type": [
            "null",
            "string"
          ]
        },
        "monthsSubscribed": {
          "type": "integer",
          "format": "int32"
        }
      }
    },
    "ViewerRole": {
      "type": "integer",
      "description": "",
      "x-enum-names": [
        "Unknown",
        "Viewer",
        "Vip",
        "Moderator",
        "Broadcaster"
      ],
      "x-enum-varnames": [
        "Unknown",
        "Viewer",
        "Vip",
        "Moderator",
        "Broadcaster"
      ],
      "x-enumNames": [
        "Unknown",
        "Viewer",
        "Vip",
        "Moderator",
        "Broadcaster"
      ],
      "x-enum-descriptions": [
        null,
        null,
        null,
        null,
        null
      ],
      "x-enumDescriptions": [
        null,
        null,
        null,
        null,
        null
      ],
      "enum": [
        0,
        1,
        2,
        3,
        4
      ]
    },
    "TwitchBadge": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": [
            "null",
            "string"
          ]
        },
        "version": {
          "type": [
            "null",
            "string"
          ]
        },
        "imageUrl": {
          "type": [
            "null",
            "string"
          ]
        },
        "info": {
          "type": [
            "null",
            "string"
          ]
        }
      }
    },
    "TwitchBaseUser": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": [
            "null",
            "string"
          ]
        },
        "login": {
          "type": [
            "null",
            "string"
          ]
        },
        "name": {
          "type": [
            "null",
            "string"
          ]
        },
        "type": {
          "type": [
            "null",
            "string"
          ]
        }
      }
    }
  }
}

JSON Payload

An example JSON payload for the event, automatically generated using JSONSchemaFaker
example.json
{
  "communityGiftId": null,
  "communitySubGiftCount": -2709084,
  "communitySubGiftCumulativeTotal": 21706171,
  "cumlativeTotal": -25245053,
  "durationMonths": -48240268,
  "fromCommunitySubGift": true,
  "isFromSharedChatGuest": true,
  "isInSharedChat": true,
  "isSharedChatHost": false,
  "isTest": false,
  "messageId": null,
  "randomCommunitySubGift": true,
  "recipient": null,
  "subTier": null,
  "systemMessage": "dolore",
  "user": null
}

Client Example

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 "Twitch.GiftSub" events and register a callback
client.on('Twitch.GiftSub', ({ 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);
});