REST Resource: liveChatMessages

Resource: LiveChatMessage

A liveChatMessage resource represents a chat message in a YouTube live chat. The resource can contain details about several types of messages, such as text messages, Super Chats, Super Stickers, membership events, live polls, and virtual gifts.

Live chat is enabled by default for live broadcasts and is available while the live broadcast is active. After the broadcast ends, live chat is no longer available for that event.

JSON representation
{
  "kind": string,
  "etag": string,
  "id": string,
  "snippet": {
    "type": enum,
    "liveChatId": string,
    "authorChannelId": string,
    "publishedAt": string,
    "hasDisplayContent": boolean,
    "displayMessage": string,
    "fanFundingEventDetails": {
      "amountMicros": string,
      "currency": string,
      "amountDisplayString": string,
      "userComment": string
    },
    "textMessageDetails": {
      "messageText": string
    },
    "userBannedDetails": {
      "bannedUserDetails": {
        "channelId": string,
        "channelUrl": string,
        "displayName": string,
        "profileImageUrl": string
      },
      "banType": enum,
      "banDurationSeconds": string
    },
    "superChatDetails": {
      "amountMicros": string,
      "currency": string,
      "amountDisplayString": string,
      "userComment": string,
      "tier": integer
    },
    "superStickerDetails": {
      "amountMicros": string,
      "currency": string,
      "amountDisplayString": string,
      "tier": integer,
      "superStickerMetadata": {
        "stickerId": string,
        "altText": string,
        "altTextLanguage": string
      }
    },
    "newSponsorDetails": {
      "memberLevelName": string,
      "isUpgrade": boolean
    },
    "memberMilestoneChatDetails": {
      "memberLevelName": string,
      "memberMonth": integer,
      "userComment": string
    },
    "membershipGiftingDetails": {
      "giftMembershipsCount": integer,
      "giftMembershipsLevelName": string
    },
    "giftMembershipReceivedDetails": {
      "memberLevelName": string,
      "gifterChannelId": string,
      "associatedMembershipGiftingMessageId": string
    },
    "pollDetails": {
      "metadata": {
        "questionText": string,
        "options": [
          {
            "optionText": string,
            "tally": string
          }
        ]
      },
      "status": enum
    },
    "giftDetails": {
      "giftName": string,
      "giftDuration": string,
      "jewelsAmount": integer,
      "giftUrl": string,
      "altText": string,
      "language": string,
      "hasVisualEffect": boolean,
      "comboCount": integer
    }
  },
  "authorDetails": {
    "channelId": string,
    "channelUrl": string,
    "displayName": string,
    "profileImageUrl": string,
    "isVerified": boolean,
    "isChatOwner": boolean,
    "isChatSponsor": boolean,
    "isChatModerator": boolean
  }
}
Fields
kind

string

Output only. Identifies what kind of resource this is. Value: the fixed string "youtube#liveChatMessage".

etag

string

Output only. Etag of this resource.

id

string

Output only. The ID that YouTube assigns to uniquely identify the message.

For giftEvent messages, the same ID can be reused across combo updates to increment snippet.giftDetails.comboCount.

snippet

object

The snippet object contains basic details about the message.

snippet.type

enum

The type of message. This property is always present and determines the contents of the message and which fields appear in the resource.

  • textMessageEvent: A user sent a text message.
  • tombstone: Signifies that a message used to exist with this ID and publish time, but has since been deleted. Only snippet.liveChatId, snippet.type, snippet.authorChannelId, and snippet.publishedAt are populated. Removed superChatEvent, superStickerEvent, newSponsorEvent, membershipGiftingEvent, giftMembershipReceivedEvent, and giftEvent messages are omitted instead of returning tombstones; removed memberMilestoneChatEvent messages return tombstones.
  • fanFundingEvent: Deprecated. As of February 28, 2017, liveChatMessage resources no longer return Fan Funding events.
  • chatEndedEvent: Legacy event type no longer emitted by the API. Once a live chat ends, requests return HTTP 403 liveChatEnded.
  • sponsorOnlyModeStartedEvent: The chat entered members-only mode, restricting new messages to channel members. Includes localized text in snippet.displayMessage.
  • sponsorOnlyModeEndedEvent: The chat exited members-only mode, allowing non-members to send messages. Includes localized text in snippet.displayMessage.
  • newSponsorEvent: A viewer joined or upgraded a channel membership. snippet.authorChannelId and authorDetails identify the member.
  • memberMilestoneChatEvent: A channel member sent a Member Milestone Chat.
  • membershipGiftingEvent: A user purchased gift memberships for other viewers.
  • giftMembershipReceivedEvent: A viewer received a gift membership.
  • userBannedEvent: A moderator banned or timed out a user. snippet.authorChannelId and authorDetails identify the moderator.
  • superChatEvent: A user purchased a Super Chat.
  • superStickerEvent: A user purchased a Super Sticker.
  • pollEvent: A live poll was created or closed.
  • giftEvent: A user redeemed Jewels for a virtual gift.

Valid values of this enum field are:

  • textMessageEvent
  • tombstone
  • fanFundingEvent
  • chatEndedEvent
  • sponsorOnlyModeStartedEvent
  • sponsorOnlyModeEndedEvent
  • newSponsorEvent
  • memberMilestoneChatEvent
  • membershipGiftingEvent
  • giftMembershipReceivedEvent
  • userBannedEvent
  • superChatEvent
  • superStickerEvent
  • pollEvent
  • giftEvent
snippet.liveChatId

string

The ID that uniquely identifies the live chat associated with this message. The live chat ID for a broadcast appears in the liveBroadcast resource's snippet.liveChatId property or the video resource's liveStreamingDetails.activeLiveChatId property.

snippet.authorChannelId

string

Output only. The ID of the user associated with authoring this message. This field is populated based on snippet.type:

  • textMessageEvent: The user who wrote the message.
  • tombstone: The original author of the deleted message.
  • sponsorOnlyModeStartedEvent and sponsorOnlyModeEndedEvent: The channel owner.
  • superChatEvent: The user who purchased the Super Chat.
  • superStickerEvent: The user who purchased the Super Sticker.
  • newSponsorEvent: The user who joined or upgraded a membership.
  • memberMilestoneChatEvent: The member who sent the milestone message.
  • membershipGiftingEvent: The user who purchased the gift memberships.
  • giftMembershipReceivedEvent: The user who received the gift membership.
  • userBannedEvent: The moderator who took the ban or timeout action.
  • pollEvent: The user who created the poll.
  • giftEvent: The user who sent the gift.
  • fanFundingEvent (deprecated): The user who funded the broadcast.
snippet.publishedAt

string

Output only. The date and time when the message was originally published. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format.

snippet.hasDisplayContent

boolean

Output only. Whether the message has display content that should be displayed to users.

snippet.displayMessage

string

Output only. Contains a string that can be displayed to users. Omitted for silent events that have no display message, such as tombstone, userBannedEvent, and pollEvent.

snippet.fanFundingEventDetails
(deprecated)

object

Output only. Deprecated: As of February 28, 2017, liveChatMessage resources no longer return details for Fan Funding events. Only set if snippet.type is fanFundingEvent.

snippet.fanFundingEventDetails
(deprecated).amountMicros

string

The amount of the fan funding contribution, in micros of the contribution currency.

snippet.fanFundingEventDetails
(deprecated).currency

string

The currency in which the fan funding contribution was made.

snippet.fanFundingEventDetails
(deprecated).amountDisplayString

string

A rendered string that displays the contribution amount and currency to the user.

snippet.fanFundingEventDetails
(deprecated).userComment

string

The comment added by the user to this fan funding event.

snippet.textMessageDetails

object

Details about the text message. Only set if snippet.type is textMessageEvent.

snippet.textMessageDetails.messageText

string

The user's message.

snippet.userBannedDetails

object

Output only. Details about a user banned or timed out from the live chat and details about the ban. Only set if snippet.type is userBannedEvent.

snippet.userBannedDetails.bannedUserDetails

object

The details of the user that was banned.

snippet.userBannedDetails.bannedUserDetails.channelId

string

The YouTube channel ID.

snippet.userBannedDetails.bannedUserDetails.channelUrl

string

The channel's URL.

snippet.userBannedDetails.bannedUserDetails.displayName

string

The channel's display name.

snippet.userBannedDetails.bannedUserDetails.profileImageUrl

string

The channel's avatar URL.

snippet.userBannedDetails.banType

enum

The type of ban. Valid values are permanent and temporary.

Valid values of this enum field are:

  • permanent
  • temporary
snippet.userBannedDetails.banDurationSeconds

string

The duration of the ban, in seconds. This property is only present if banType is temporary.

snippet.superChatDetails

object

Output only. Details about the Super Chat event. Only set if snippet.type is superChatEvent.

snippet.superChatDetails.amountMicros

string

The amount purchased by the user, in micros of the purchase currency (1,750,000 micros = 1.75).

snippet.superChatDetails.currency

string

The currency in which the purchase was made, specified as an ISO 4217 currency code.

snippet.superChatDetails.amountDisplayString

string

A rendered string that displays the purchase amount and currency (for example, $1.00) to the user.

snippet.superChatDetails.userComment

string

The comment added by the user to this Super Chat event.

snippet.superChatDetails.tier

integer (uint32 format)

The tier for the paid message, matching the snippet.messageType property in a superChatEvent resource.

The tier is based on the purchase amount and determines the highlight color in the live chat UI, maximum message length, and ticker pin duration. Super Chat tiers are documented in the YouTube Help Center; the lowest purchase amount is tier 1.

snippet.superStickerDetails

object

Output only. Details about the Super Sticker event. Only set if snippet.type is superStickerEvent.

snippet.superStickerDetails.amountMicros

string

The amount purchased by the user, in micros of the purchase currency (1,750,000 micros = 1.75).

snippet.superStickerDetails.currency

string

The currency in which the purchase was made, specified as an ISO 4217 currency code.

snippet.superStickerDetails.amountDisplayString

string

A rendered string that displays the purchase amount and currency (for example, $1.00) to the user.

snippet.superStickerDetails.tier

integer (uint32 format)

The tier for the paid message, matching the snippet.messageType property in a superChatEvent resource.

The tier is based on the purchase amount and determines the highlight color in the live chat UI, maximum message length, and ticker pin duration. Super Chat tiers, which also cover Super Stickers, are documented in the YouTube Help Center; the lowest purchase amount is tier 1.

snippet.superStickerDetails.superStickerMetadata

object

Information about the Super Sticker.

snippet.superStickerDetails.superStickerMetadata.stickerId

string

Unique identifier of the Super Sticker. This is a shorter form of altText that includes the pack name and a recognizable characteristic of the sticker.

The sticker image is displayed in YouTube live chat, and the image URL isn't available through the API. For reference, see the Super Sticker ID to URL mapping CSV.

snippet.superStickerDetails.superStickerMetadata.altText

string

Internationalized alt text that describes the sticker image and any animation associated with it. The altTextLanguage field identifies the language of this text. Set the hl request parameter to retrieve the text in a specific language.

snippet.superStickerDetails.superStickerMetadata.altTextLanguage

string

Specifies the localization language in which altText is returned. The value is derived from the hl request parameter.

snippet.newSponsorDetails

object

Output only. Details about the New Member Announcement event. Only set if snippet.type is newSponsorEvent. The term "member" replaces "sponsor".

snippet.newSponsorDetails.memberLevelName

string

The name of the level that the viewer joined. Level names are defined by the YouTube channel offering the membership.

In some situations this field isn't filled.

snippet.newSponsorDetails.isUpgrade

boolean

Whether the viewer upgraded from a lower membership level. Set to true on upgrades; omitted or false when the viewer wasn't a member at the time of purchase.

snippet.memberMilestoneChatDetails

object

Output only. Details about the Member Milestone Chat event. Only set if snippet.type is memberMilestoneChatEvent.

snippet.memberMilestoneChatDetails.memberLevelName

string

The name of the level at which the viewer is a member. Level names are defined by the YouTube channel offering the membership.

In some situations this field isn't filled.

snippet.memberMilestoneChatDetails.memberMonth

integer (uint32 format)

The total number of months (rounded up) the viewer has been a member that granted them this Member Milestone Chat. This is the same number of months displayed to YouTube users.

snippet.memberMilestoneChatDetails.userComment

string

The comment added by the member to this Member Milestone Chat.

Empty for messages without a comment from the member.

snippet.membershipGiftingDetails

object

Output only. Details about the Membership Gifting event. Only set if snippet.type is membershipGiftingEvent.

snippet.membershipGiftingDetails.giftMembershipsCount

integer

The number of gift memberships purchased by the user.

snippet.membershipGiftingDetails.giftMembershipsLevelName

string

The name of the level of the gift memberships purchased by the user. Level names are defined by the YouTube channel offering the membership.

In some situations this field isn't filled.

snippet.giftMembershipReceivedDetails

object

Output only. Details about the Gift Membership Received event. Only set if snippet.type is giftMembershipReceivedEvent.

snippet.giftMembershipReceivedDetails.memberLevelName

string

The name of the level at which the viewer is a member. This matches the snippet.membershipGiftingDetails.giftMembershipsLevelName of the associated membership gifting message. Level names are defined by the YouTube channel offering the membership.

In some situations this field isn't filled.

snippet.giftMembershipReceivedDetails.gifterChannelId

string

The ID of the user that made the membership gifting purchase. This matches the snippet.authorChannelId of the associated membership gifting message.

snippet.giftMembershipReceivedDetails.associatedMembershipGiftingMessageId

string

The ID of the membership gifting message that is related to this gift membership. This ID refers to a message whose snippet.type is membershipGiftingEvent.

snippet.pollDetails

object

Details about the poll event. Only set if snippet.type is pollEvent.

snippet.pollDetails.metadata

object

Metadata for the live poll, including the question and options.

snippet.pollDetails.metadata.questionText

string

The question text for the live poll. Maximum length is 100 characters.

snippet.pollDetails.metadata.options[]

object

The list of poll choices, returned in display order. When creating a poll, provide between 2 and 4 options.

snippet.pollDetails.metadata.options[].optionText

string

The text displayed for this poll choice. Maximum length is 35 characters.

snippet.pollDetails.metadata.options[].tally

string (int64 format)

Output only. The vote count for this poll option. For an active poll, present only when the request is authorized by the channel owner or a user who has voted; for a closed poll, present with the final vote count. Do not set this field when creating a poll.

snippet.pollDetails.status

enum

Output only. The poll's lifecycle status: active while open for voting, or closed once ended. Do not set this field when creating a poll.

Valid values of this enum field are:

  • active
  • closed
snippet.giftDetails

object

Output only. Details about the gift event. Only set if snippet.type is giftEvent.

snippet.giftDetails.giftName

string

The name of the gift.

snippet.giftDetails.giftDuration

string (Duration format)

The duration to display the gift.

A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".

snippet.giftDetails.jewelsAmount

integer

The number of Jewels redeemed for the gift.

snippet.giftDetails.giftUrl

string

The URL of the gift asset.

snippet.giftDetails.altText

string

The alternative text to use for accessibility.

snippet.giftDetails.language

string

The BCP-47 language code of altText and giftName.

snippet.giftDetails.hasVisualEffect

boolean

Whether the gift involves a visual effect.

snippet.giftDetails.comboCount

integer

The number of times the gift has been sent in a row. Omitted when the gift is not part of a combo.

authorDetails

object

Output only. The authorDetails object contains basic details about the user that posted this message.

authorDetails.channelId

string

The author's YouTube channel ID.

authorDetails.channelUrl

string

The URL of the author's YouTube channel.

authorDetails.displayName

string

The display name of the author's YouTube channel.

authorDetails.profileImageUrl

string

The avatar URL of the author's YouTube channel.

authorDetails.isVerified

boolean

Whether the author's identity has been verified by YouTube.

authorDetails.isChatOwner

boolean

Whether the author is the owner of the live chat.

authorDetails.isChatSponsor

boolean

Whether the author is a sponsor of the live chat.

authorDetails.isChatModerator

boolean

Whether the author is a moderator of the live chat.

Methods

delete

Deletes a chat message.

insert

Adds a text message or a poll to a live chat.

list

Lists live chat messages for a specific chat.

streamList

Establishes a server-streaming connection to receive live chat messages for a specific chat with low latency.

transition

Transitions the status of a live chat poll message to close an active poll.