youtube

GET /youtube/v3/liveChat/messages/stream

Changed on

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.

Request

  • Base URL
    https://youtube.googleapis.com
  • Auth
    • OAuth 2 and OAuth 2
      Implicithttps://accounts.google.com/o/oauth2/auth
      Scopeshttps://www.googleapis.com/auth/youtube
      Authorization codehttps://accounts.google.com/o/oauth2/auth
      Token URLhttps://accounts.google.com/o/oauth2/token
      Scopeshttps://www.googleapis.com/auth/youtube
    • or OAuth 2 and OAuth 2
      Implicithttps://accounts.google.com/o/oauth2/auth
      Scopeshttps://www.googleapis.com/auth/youtube.force-ssl
      Authorization codehttps://accounts.google.com/o/oauth2/auth
      Token URLhttps://accounts.google.com/o/oauth2/token
      Scopeshttps://www.googleapis.com/auth/youtube.force-ssl
    • or OAuth 2 and OAuth 2
      Implicithttps://accounts.google.com/o/oauth2/auth
      Scopeshttps://www.googleapis.com/auth/youtube.readonly
      Authorization codehttps://accounts.google.com/o/oauth2/auth
      Token URLhttps://accounts.google.com/o/oauth2/token
      Scopeshttps://www.googleapis.com/auth/youtube.readonly

Query parameters

$.xgafv, '1' | '2'

V1 error format.

access_token, string

OAuth access token.

alt, 'json' | 'media' | 'proto'

Data format for response.

callback, string

JSONP

fields, string

Selector specifying which fields to include in a partial response.

key, string

API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.

oauth_token, string

OAuth 2.0 token for the current user.

prettyPrint, boolean

Returns response with indentations and line breaks.

quotaUser, string

Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

uploadType, string

Legacy upload protocol for media (e.g. "media", "multipart").

upload_protocol, string

Upload protocol for media (e.g. "raw", "multipart").

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.

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.

maxResults, integer

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.

profileImageSize, integer

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.

Response

Successful response

LiveChatMessageListResponse required
activePollItem, 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.

etag, string

Output only. Etag of this resource.

eventId, string

Serialized EventId of the request which produced this response.

items, LiveChatMessage[]

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

kind, string

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

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.

offlineAt, string date-time

The date and time when the underlying stream went offline.

pageInfo, PageInfo

Paging details for lists of resources, including total number of items available and number of resources returned in a single page.

pollingIntervalMillis, integer

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

tokenPagination, TokenPagination

Stub token pagination template to suppress results.

visitorId, string

Identifies the visitor.

Changes

    • info

      the security scope https://www.googleapis.com/auth/youtube was added to the endpoint's security scheme Oauth2

    • info

      the security scope https://www.googleapis.com/auth/youtube was added to the endpoint's security scheme Oauth2c

    • info

      the security scope https://www.googleapis.com/auth/youtube.readonly was removed from the endpoint's security scheme Oauth2

    1 more change in this revision