YouTube API: How do I get the liveChatId?

C. Olimar picture C. Olimar · Apr 18, 2016 · Viewed 7.4k times · Source

The documentation says:

"The liveChatId parameter specifies the ID of the chat whose messages will be returned. The live chat ID associated with a broadcast is returned in the liveBroadcast resource's snippet.liveChatId property."

But when using APIs Explorer and youtube.liveBroadcasts.list to get a liveBroadcast's snippet, there is no liveChatId property on the returned result.

I'm using the following URI (key omitted):

https://www.googleapis.com/youtube/v3/liveBroadcasts?part=snippet&mine=true

What am I doing wrong?

Here is the response (some values replaced with ...):

{
 "kind": "youtube#liveBroadcastListResponse",
 "etag": "...",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 5
 },
 "items": [
  {
   "kind": "youtube#liveBroadcast",
   "etag": "...",
   "id": "...",
   "snippet": {
    "publishedAt": "2016-04-18T17:04:24.000Z",
    "channelId": "...",
    "title": "...",
    "description": "...",
    "thumbnails": {
     "default": {
      "url": "...",
      "width": 120,
      "height": 90
     },
     "medium": {
      "url": "...",
      "width": 320,
      "height": 180
     },
     "high": {
      "url": "...",
      "width": 480,
      "height": 360
     },
     "standard": {
      "url": "...",
      "width": 640,
      "height": 480
     },
     "maxres": {
      "url": "...",
      "width": 1280,
      "height": 720
     }
    },
    "scheduledStartTime": "1970-01-01T00:00:00.000Z",
    "actualStartTime": "2016-04-18T17:04:24.250Z",
    "isDefaultBroadcast": false
   }
  }
 ]
}

There is also an active conversation happening on the stream at the time of the request.

Apparently, live broadcasts created using "Stream now" do not contain a liveChatId even though they contain a live chat.

Is there a way to get the liveChatId for a "Stream now" live broadcast?

Answer

Kim Nguyen picture Kim Nguyen · Jul 17, 2017

this is a rather old post, but seeing as I searched all over the internet for an answer and could not find one, I hope someone finds this helpful.

To get the liveChatId of a live event that is not yours you can do something like the following:

first, get the videoId

response.items[0].id.videoId

Then get the liveStreamingDetails

buildApiRequest('GET',
        '/youtube/v3/videos', {
            'id': videoID,
            'part': 'snippet,contentDetails,statistics,liveStreamingDetails'
        });

Now you can get the liveChatId from the response above via:

response.items[0].liveStreamingDetails.activeLiveChatId