AI-generated Key Takeaways
-
The
liveChatMessageresource represents a message in a YouTube live chat, encompassing text, fan funding, and other event types, and it is only available during the live event. -
This resource's
snippetproperty contains the core message details, including the message type, author information, and content, which can be a simple text message, a super chat, poll data or even details of a deleted message. -
The
authorDetailsproperty withinliveChatMessageprovides comprehensive information about the message sender, such as their channel ID, display name, profile image, and their role in the chat (e.g., owner, sponsor, moderator). -
Different message types, like
superChatDetails,superStickerDetails,pollDetails,membershipGiftingDetails, orgiftMembershipReceivedDetails, provide specific data structures that capture the unique attributes and data associated with each individual type of message in the live chat. -
The
liveChatMessageresource supports several methods includinglistto retrieve messages,insertto add messages or polls,transitionto modify message states, anddeleteto remove messages, with thedeletemethod requiring authorization.
A liveChatMessage resource represents a chat message in a YouTube live chat. The resource can contain details about several types of messages, including a newly posted text message or fan funding event.
The live chat feature is enabled by default for live broadcasts and is available while the live event is active. (After the event ends, live chat is no longer available for that event.)
Methods
The API supports the following methods for liveChatMessages resources:
- list
- Lists live chat messages for a specific chat. Try it now.
- streamList
- Enables a server-streaming connection for receiving live chat messages for a specific chat in low latency. Try it now.
- insert
- Adds a message or a poll to a live chat. Try it now.
- transition
- Transitions the state of a live message. Try it now.
- delete
- Deletes a chat message. The API request must be authorized by the channel owner or a moderator of the live chat. Try it now.
Resource representation
The following JSON structure shows the format of a liveChatMessages resource:
{
"kind": "youtube#liveChatMessage",
"etag": etag,
"id": string,
"snippet": {
"type": string,
"liveChatId": string,
"authorChannelId": string,
"publishedAt": datetime,
"hasDisplayContent": boolean,
"displayMessage": string,
"fanFundingEventDetails": {
"amountMicros": unsigned long,
"currency": string,
"amountDisplayString": string,
"userComment": string
},
"textMessageDetails": {
"messageText": string
},
"messageDeletedDetails": {
"deletedMessageId": string
},
"userBannedDetails": {
"bannedUserDetails": {
"channelId": string,
"channelUrl": string,
"displayName": string,
"profileImageUrl": string
},
"banType": string,
"banDurationSeconds": unsigned long
},
"memberMilestoneChatDetails": {
"userComment": string,
"memberMonth": unsigned integer,
"memberLevelName": string
},
"newSponsorDetails": {
"memberLevelName": string,
"isUpgrade": bool
},
"superChatDetails": {
"amountMicros": unsigned long,
"currency": string,
"amountDisplayString": string,
"userComment": string,
"tier": unsigned integer
},
"superStickerDetails": {
"superStickerMetadata": {
"stickerId": string,
"altText": string,
"language": string
},
"amountMicros": unsigned long,
"currency": string,
"amountDisplayString": string,
"tier": unsigned integer
},
"pollDetails": {
"metadata": {
"options": {
"optionText": string,
"tally": string,
},
"questionText": string,
"status": enum
},
},
"membershipGiftingDetails": {
"giftMembershipsCount": integer,
"giftMembershipsLevelName": string
},
"giftMembershipReceivedDetails": {
"memberLevelName": string,
"gifterChannelId": string,
"associatedMembershipGiftingMessageId": string
},
},
"authorDetails": {
"channelId": string,
"channelUrl": string,
"displayName": string,
"profileImageUrl": string,
"isVerified": boolean,
"isChatOwner": boolean,
"isChatSponsor": boolean,
"isChatModerator": boolean
},
}Properties
The following table defines the properties that appear in this resource:
| Properties | |
|---|---|
kind |
stringIdentifies the API resource's type. The value will be youtube#liveChatMessage. |
etag |
etagThe Etag of this resource. |
id |
stringThe ID that YouTube assigns to uniquely identify the message. |
snippet |
objectThe snippet object contains core details about the chat message. |
snippet.type |
stringThe message's type. This property is always present, and its value determines which fields are present in the resource. Valid values for this property are:
|
snippet.liveChatId |
stringThe ID that uniquely identifies the live chat with which the message is associated. The live chat ID associated with a broadcast is returned in the liveBroadcast resource's snippet.liveChatId property. |
snippet.authorChannelId |
stringThe ID of the user that authored the message. This field is only filled for the following message types:
|
snippet.publishedAt |
datetimeThe 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 |
booleanIndicates whether the message has display content that should be displayed to users. |
snippet.displayMessage |
stringContains a string that is displayed to users. This field is not present if the message type is chatEndedEvent or tombstone. |
snippet.fanFundingEventDetails |
objectNote: This object and its child properties have been deprecated. As of February 28, 2017, liveChatMessage resources will no longer return details for Fan Funding events.This object contains details about the funding event. It is only present if the message type is fanFundingEvent. |
snippet.fanFundingEventDetails.amountMicros |
unsigned longNote: This property has been deprecated. The amount of the fund. |
snippet.fanFundingEventDetails.currency |
stringNote: This property has been deprecated. The currency in which the fund was made. |
snippet.fanFundingEventDetails.amountDisplayString |
stringNote: This property has been deprecated. A rendered string that displays the fund amount and currency to the user. |
snippet.fanFundingEventDetails.userComment |
stringNote: This property has been deprecated. The comment added by the user to this fan funding event. |
snippet.textMessageDetails |
objectThis object contains details about the text message. It is only present if the message type is textMessageEvent. |
snippet.textMessageDetails.messageText |
stringThe user's message. |
snippet.messageDeletedDetails |
objectThis object contains details about a message deleted by a chat moderator or by the owner of the live broadcast's channel. It is only present if the message type is messageDeletedEvent. |
snippet.messageDeletedDetails.deletedMessageId |
stringThe ID that uniquely identifies the deleted message. The value is the same as the id property value of the original text message. For example, if a textMessageEvent has an id property value of 123, and that message is subsequently deleted, the snippet.messageDeletedDetails.deletedMessageId value will be 123 for that message.If you cache chat messages after retrieving them, use the value of this property to identify the message that should no longer be displayed. |
snippet.userBannedDetails |
objectThis object contains details about a user who has been banned from the chat. It also contains details about the ban itself. Users can be banned from a chat permanently or temporarily. |
snippet.userBannedDetails.bannedUserDetails |
objectThis object contains information about the banned user. |
snippet.userBannedDetails.bannedUserDetails.channelId |
stringThe banned user's YouTube channel ID. |
snippet.userBannedDetails.bannedUserDetails.channelUrl |
stringThe URL of the banned user's YouTube channel. |
snippet.userBannedDetails.bannedUserDetails.displayName |
stringThe display name of the banned user's YouTube channel. |
snippet.userBannedDetails.bannedUserDetails.profileImageUrl |
stringThe avatar of the banned user's YouTube channel. |
snippet.userBannedDetails.banType |
stringThe type of ban. Valid values for this property are:
|
snippet.userBannedDetails.banDurationSeconds |
unsigned longThe duration of the ban. This property is only present if the snippet.userBannedDetails.banType property value is temporary. |
snippet.memberMilestoneChatDetails |
objectThis object contains details about a Member Milestone event. It is only present if the message type is memberMilestoneChatEvent. |
snippet.memberMilestoneChatDetails.userComment |
stringThe comment added by the member to this Member Milestone Chat. This field is empty for messages without a comment from the member. |
snippet.memberMilestoneChatDetails.memberMonth |
unsigned integerThe total amount of months (rounded up) the viewer has been a member that granted them this Member Milestone Chat. This is the same number of months as is being displayed to YouTube users. |
snippet.memberMilestoneChatDetails.memberLevelName |
stringThe name of the Level at which the viewer is a member. The Level names are defined by the YouTube channel offering the Membership. In some situations this field isn't filled. |
snippet.newSponsorDetails |
objectThis object contains details about the New Member Announcement event. This is only set if the type is newSponsorEvent. "Member" is the term for "sponsor."
|
snippet.newSponsorDetails.memberLevelName |
stringThe name of the Level at which the viewer is a member. The Level names are defined by the YouTube channel offering the Membership. In some situations, this field isn't filled. |
snippet.newSponsorDetails.isUpgrade |
boolIndicates whether the viewer just upgraded from a lower Level. For viewers that were not members at the time of purchase, the field value is false.
|
snippet.superChatDetails |
objectThis object contains details about a Super Chat event. It is only present if the message type is superChatEvent. |
snippet.superChatDetails.amountMicros |
unsigned longThe purchase amount, in micros of the purchase currency. For example, if the purchase amount is one dollar, the snippet.amountMicros property value is 1000000. |
snippet.superChatDetails.currency |
stringThe currency in which the purchase was made. The value is an ISO 4217 currency code. |
snippet.superChatDetails.amountDisplayString |
stringA string, like $1.00, that contains the purchase amount and currency. The string is intended to be displayed to the user. |
snippet.superChatDetails.userComment |
stringThe comment added by the user to this Super Chat event. |
snippet.superChatDetails.tier |
unsigned integerThe tier for the paid message. Note that in a superChatEvent resource, the snippet.messageType property contains this value.The tier is based on the amount of money spent to purchase the message. It also determines the color used to highlight the message in the live chat UI, the maximum message length, and the amount of time that the message is pinned the ticker. The Super Chat tiers are documented in the YouTube Help Center. (See the expandable section about Super Chat purchase details.) In that list, the tier with the lowest purchase amount is tier 1, the next lowest amount is tier 2, and so forth. |
snippet.superStickerDetails |
objectThis object contains details about a Super Sticker event. It is only present if the message type is superStickerEvent. |
snippet.superStickerDetails.superStickerMetadata |
objectDetails about the Super Sticker. |
snippet.superStickerDetails.superStickerMetadata.stickerId |
stringA unique ID that identifies the sticker image. Note that the image is only displayed as part of the Super Sticker message when users view the chat window on YouTube. However, the image URL is not available using the API. For reference only, you can find which Sticker IDs relate to which Super Stickers in this CSV file. |
snippet.superStickerDetails.superStickerMetadata.altText |
stringA text string that describes the sticker. The snippet.superStickerDetails.superStickerMetadata.language field identifies the language of the text. When calling the liveChatMessages.list method, set the hl parameter value to the chosen language for the text. |
snippet.superStickerDetails.superStickerMetadata.language |
stringThe language of the snippet.superStickerDetails.superStickerMetadata.altText property value. |
snippet.superStickerDetails.amountMicros |
unsigned longThe purchase amount, in micros of the purchase currency. For example, if the purchase amount is one dollar, the snippet.amountMicros property value is 1000000. |
snippet.superStickerDetails.currency |
stringThe currency in which the purchase was made. The value is an ISO 4217 currency code. |
snippet.superStickerDetails.amountDisplayString |
stringA string, like $1.00, that contains the purchase amount and currency. The string is intended to be displayed to the user. |
snippet.superStickerDetails.tier |
unsigned integerThe tier for the paid message. Note that in a superChatEvent resource, the snippet.messageType property contains this value.The tier is based on the amount of money spent to purchase the message. It also determines the color used to highlight the message in the live chat UI, the maximum message length, and the amount of time that the message is pinned the ticker. The Super Chat tiers, which also cover Super Stickers, are documented in the YouTube Help Center. (See the expandable section about Super Chat purchase details.) In that list, the tier with the lowest purchase amount is tier 1, the next lowest amount is tier 2, and so forth. |
snippet.pollDetails |
objectThis object contains details about a poll event. It is only present if the message type is pollEvent. |
snippet.pollDetails.metadata |
objectDetails about the poll event. |
snippet.pollDetails.metadata.options |
objectThe options in the live poll. |
snippet.pollDetails.metadata.options.optionText |
stringThe text of the live poll option. |
snippet.pollDetails.metadata.options.tally |
stringThe tally of the live poll option. The tally is only present if the API request is authorized by the channel owner. |
snippet.pollDetails.metadata.questionText |
stringThe text of the live poll question. |
snippet.pollDetails.metadata.status |
enumThe status of the live poll event. Valid values for this property are:
|
snippet.membershipGiftingDetails |
objectThis object contains details about a Membership Gifting event. It is only present if the message type is membershipGiftingEvent. |
snippet.membershipGiftingDetails.giftMembershipsCount |
integerThe number of gift memberships purchased by the user. |
snippet.membershipGiftingDetails.giftMembershipsLevelName |
stringThe 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 |
objectThis object contains details about a Gift Membership Received event. It is only present if the message type is giftMembershipReceivedEvent. |
snippet.giftMembershipReceivedDetails.memberLevelName |
stringThe 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 |
stringThe ID of the user that made the membership gifting purchase. This matches the snippet.authorChannelId of the associated membership gifting message. |
snippet.giftMembershipReceivedDetails.associatedMembershipGiftingMessageId |
stringThe ID of the membership gifting message that is related to this gift membership. This ID will always refer to a message whose type is membershipGiftingEvent. |
authorDetails |
objectThe authorDetails object contains additional details about the user that posted this message. |
authorDetails.channelId |
stringThe author's YouTube channel ID. |
authorDetails.channelUrl |
stringThe URL of the author's YouTube channel. |
authorDetails.displayName |
stringThe display name of the author's YouTube channel. |
authorDetails.profileImageUrl |
stringThe avatar URL of the author's YouTube channel. |
authorDetails.isVerified |
booleanThis value indicates whether the author's identity has been verified by YouTube. |
authorDetails.isChatOwner |
booleanThis value indicates whether the author is the owner of the live chat. |
authorDetails.isChatSponsor |
booleanThis value indicates whether the author is a sponsor of the live chat. |
authorDetails.isChatModerator |
booleanThis value indicates whether the author is a moderator of the live chat. |