12

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?

JAL
  • 41,701
  • 23
  • 172
  • 300
C. Olimar
  • 311
  • 1
  • 3
  • 8
  • Can you post a sample response you get from YouTube? Are you sure you are listing an event that has actually started and has a valid chat room/id? – JAL Apr 18 '16 at 15:43
  • Updated the post with the requested information. The live broadcast is streaming and the chat room is active at the time of the request. If I'm not streaming there are no items in the response, as expected. – C. Olimar Apr 18 '16 at 17:20
  • are you talking about liveBroadcast's liveChatId or the user's liveChatId (for banning or removing) ? – ReyAnthonyRenacia Apr 19 '16 at 09:52
  • The liveBroadcast's liveChatId, so I can read the stream's chat. – C. Olimar Apr 19 '16 at 16:44
  • Essentially, I just need to know where to get the liveChatId for youtube.liveChatMessages.list because the documentation is incorrect. – C. Olimar Apr 19 '16 at 17:05
  • @C.Olimar You may very well have a solution by now. But i noticed this wasn't marked solved and thought I'd share my solution. – hmedia1 May 08 '17 at 03:00

3 Answers3

17

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
Kim Nguyen
  • 201
  • 2
  • 6
3

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

Yes, you can. I have an automated system that uses just this setup for "Stream Now" streams.

From what I can see the only thing different I do, to you, is specify either broadcastType=all or broadcastType=persistent in the API URI.

You'll notice my stream is the default stream, but, it doesn't have to be. In fact, basically the only useful aspect of the LiveStream endpoint at all is the .status.configurationIssues information. (Not even the streamName ingestion address matches up)

This is how I would correlate the two endpoints. Perhaps you can fill in some blanks using this template. (All strings randomized and thumbnails section removed)

LiveStreams:

URI: https://www.googleapis.com/youtube/v3/liveStreams/?part=status,snippet&default=true 

Response:  

{
    "kind": "youtube#liveStreamListResponse",
    "etag": "\"j1yhvAPYkjsoF8yjoVGsTlIFzCS/rqgpDvaMrWOPqUrLPxJd4XUFoKg\"",
    "pageInfo": {
        "totalResults": 1,
        "resultsPerPage": 5
    },
    "items": [
    {
        "kind": "youtube#liveStream",
        "etag": "\"j1yhvAPYkjsoF8yjoVGsTlIFzCS/SRutyOE9apA9K1qAdh2s9ZYE-Dp\"",
        "id": "e5LT2xEURi9BQzf2rLe5eB3325081929219850",  <-- liveBroadcasts .boundStreamId
        "snippet": {
            "publishedAt": "2016-09-05T23:21:33.000Z",
            "channelId": "QIr0IE1wRTRj2SUku4eFj0mK",
            "title": "Default Stream",
            "description": "",
            "isDefaultStream": true
        },
        "status": {
            "streamStatus": "active",
            "healthStatus": {
                "status": "good"
            }
        }
    }
    ]
}

LiveBroadcasts:

URI: https://www.googleapis.com/youtube/v3/liveBroadcasts/?part=status,contentDetails,snippet,id&broadcastStatus=active&broadcastType=persistent

Response:

{
    "kind": "youtube#liveBroadcastListResponse",
    "etag": "\"j1yhvAPYkjsoF8yjoVGsTlIFzCS/MFvQunCBDdqlkhPMness6LN1zao\"",
    "pageInfo": {
        "totalResults": 1,
        "resultsPerPage": 5
    },
    "items": [
    {
        "kind": "youtube#liveBroadcast",
        "etag": "\"j1yhvAPYkjsoF8yjoVGsTlIFzCS/mK_CAQ9rrVulNXbKbeIveFnQPd8\"",
        "id": "eXrevq9RzVQ",
        "snippet": {
            "publishedAt": "2017-05-07T16:58:05.000Z",
            "channelId": "QIr0IE1wRTRj2SUku4eFj0mK",
            "title": "514306-pgju",
            "description": "",
            "scheduledStartTime": "1970-01-01T00:00:00.000Z",
            "actualStartTime": "2017-05-08T01:21:45.000Z",
            "isDefaultBroadcast": true,
            "liveChatId": "NiHXTCKPfAyCJrPgREDRnvMSL0N5LBiVUlZoLSULA9vqyoR"
        },
        "status": {
            "lifeCycleStatus": "live",
            "privacyStatus": "unlisted",
            "recordingStatus": "recording"
        },
        "contentDetails": {
            "boundStreamId": "e5LT2xEURi9BQzf2rLe5eB3325081929219850", <-- LiveStreams .id
            "boundStreamLastUpdateTimeMs": "2016-09-05T23:21:33.749Z",
            "monitorStream": {
                "enableMonitorStream": false
            },
            "enableEmbed": true,
            "enableDvr": true,
            "enableContentEncryption": false,
            "startWithSlate": false,
            "recordFromStart": true,
            "enableClosedCaptions": false,
            "closedCaptionsType": "closedCaptionsDisabled",
            "enableLowLatency": false,
            "projection": "rectangular"
        }
    }
    ]
}

Just a note that as you've noticed to some extent, dealing with "Stream Now" events through the API, not just specific to liveChatId, there are some configuration settings that change the way results get returned using default parameters, and sometimes they can change the order and steps involved in the process. I have even found that there is is actually a few parameters that work with the LiveStream endpoint that are not documented, and similarly for the LiveBroadcast endpoint. Additionally there are some bugs.

hmedia1
  • 5,552
  • 2
  • 22
  • 27
1

YouTube currently doesn't support mixing API calls with "Stream Now" and creating Events via the API. There is no way of getting chat messages from "Stream Now" broadcasts, only broadcasts created completely with the API.

If you believe this to be an API defect, I recommend opening an enhancement or defect ticket here.

JAL
  • 41,701
  • 23
  • 172
  • 300