Method: liveChatMessages.streamList

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

When you connect, the API sends recent chat history and continues pushing new messages over the open connection, ordered from oldest to newest within each response. Each stream is short-lived and closes from the server side after about 10 seconds (with a 30-second RPC deadline). Each response includes a nextPageToken; call liveChatMessages.streamList in a loop, passing the latest nextPageToken as pageToken whenever the server ends the stream or your client disconnects. For a Python gRPC streaming example, see the Streaming Live Chat guide.

Public live chats can be read with an API key or OAuth 2.0 authorization. Private, members-only, or paygated live chats, and viewing active poll tallies as the channel owner or a voter, require OAuth 2.0 authorization. For method-specific HTTP REST and gRPC error responses, see liveChatMessages.streamList errors.

HTTP request

GET https://youtube.googleapis.com/youtube/v3/liveChat/messages/stream

The URL uses gRPC Transcoding syntax.

Query parameters

Parameters
liveChatId

string

Required. The ID of the live chat for which messages should be returned. The live chat ID associated with a broadcast is returned in the liveBroadcast resource's snippet.liveChatId property or the video resource's liveStreamingDetails.activeLiveChatId property.

hl

string

Specifies the localization language in which system messages, Super Sticker and gift text, and currency display strings are returned. For example, English (en-US, the default) formats currency as $1.50, whereas French (fr) formats it as 1,50 $.

The value must be a language code returned by i18nLanguages.list.

profileImageSize

integer (uint32 format)

Specifies the square dimensions, in pixels, of user profile images returned in authorDetails.profileImageUrl. Acceptable values are 16 to 720, inclusive. The default value is 88 (88px by 88px); out-of-range values on liveChatMessages.streamList fall back to 88.

maxResults

integer (uint32 format)

Specifies the maximum number of items returned in the result set. Acceptable values are 200 to 2000, inclusive (enforced on liveChatMessages.list), and the default value is 500. On liveChatMessages.streamList, this caps each streamed response batch.

An initial request made without a pageToken returns only the most recent messages (up to 75 messages plus ticker and gift events, which can be fewer than maxResults) and doesn't retrieve older messages.

pageToken

string

Identifies a specific page in the result set to retrieve. Pass the nextPageToken property from a previous response to fetch subsequent messages, or to reopen liveChatMessages.streamList in a loop after the server closes the stream or your client disconnects.

part[]

string

Required. Specifies a comma-separated list of liveChatMessage resource parts that the API response includes. Supported values are id, snippet, and authorDetails.

Request body

The request body must be empty.

Response body

If successful, the response body contains data with the following structure:

JSON representation
{
  "kind": string,
  "etag": string,
  "pollingIntervalMillis": integer,
  "offlineAt": string,
  "pageInfo": {
    "totalResults": integer,
    "resultsPerPage": integer
  },
  "nextPageToken": string,
  "items": [
    {
      object (LiveChatMessage)
    }
  ],
  "activePollItem": {
    object (LiveChatMessage)
  }
}
Fields
kind

string

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

etag

string

Output only. Etag of this resource.

pollingIntervalMillis

integer (uint32 format)

The amount of time, in milliseconds, that the client should wait before polling again. Returned by liveChatMessages.list only; omitted by liveChatMessages.streamList.

offlineAt

string

The date and time when the underlying livestream went offline. Only present if the stream is already offline. The value is specified in ISO 8601 (YYYY-MM-DDThh:mm:ss.sZ) format.

pageInfo

object

General pagination information.

pageInfo.totalResults

integer

The total number of results in the result set.

pageInfo.resultsPerPage

integer

The number of results included in the API response.

nextPageToken

string

The token to pass as the pageToken parameter to retrieve the next page of messages, or to reopen liveChatMessages.streamList after the server closes the stream or your client disconnects.

items[]

object (LiveChatMessage)

A list of messages. Each item is a liveChatMessage resource.

activePollItem

object (LiveChatMessage)

The active poll, returned as a liveChatMessage resource whose snippet.type is pollEvent. Set when there is an active poll; at most one active poll can exist per chat.

Authorization scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/youtube
  • https://www.googleapis.com/auth/youtube.readonly
  • https://www.googleapis.com/auth/youtube.force-ssl

For more information, see the OAuth 2.0 Overview.