apiyoutuberequestyoutube-apilivechat

YouTube API`s not retrieving liveChatId from an ended broadcast event


I'm trying to retrieve all the chat messages I got from a live streaming, which has already ended. But using the request bellow, it does not retrieves any snippet.liveChatId as mentioned in google documentation: https://developers.google.com/youtube/v3/live/docs/liveBroadcasts#snippet.liveChatId

If I try on upcoming streaming it does work properly.

How do I get the chat messages in this case, if I cannot get the proper liveChatId?

Some values replaced by MY_XPTO

Request:

    GET https://www.googleapis.com/youtube/v3/liveBroadcasts?part=snippet&id=MY_ID&key=[YOUR_API_KEY] HTTP/1.1

    Authorization: Bearer [YOUR_ACCESS_TOKEN]
    Accept: application/json

Response:

    {
     "kind": "youtube#liveBroadcastListResponse",
     "etag": "MY_ETAG",
     "pageInfo": {
      "totalResults": 0,
      "resultsPerPage": 5
     },
     "items": [
      {
       "kind": "youtube#liveBroadcast",
       "etag": "MY_ETAG,
       "id": "MY_ID",
       "snippet": {
        "publishedAt": "2020-04-03T21:23:06.000Z",
        "channelId": "MY_CHANNEL_ID",
        "title": "MY_TITLE",
        "description": "MY_DESCRIPTION",
        "thumbnails": {
         "default": {
          "url": "MYURL",
          "width": 120,
          "height": 90
         },
         "medium": {
          "url": "MY_URL",
          "width": 320,
          "height": 180
         },
         "high": {
          "url": "MY_URL",
          "width": 480,
          "height": 360
         },
         "standard": {
          "url": "MY_URL",
          "width": 640,
          "height": 480
         },
         "maxres": {
          "url": "MY_URL",
          "width": 1280,
          "height": 720
         }
        },
        "scheduledStartTime": "2020-04-07T20:00:00.000Z",
        "actualStartTime": "2020-04-07T20:01:00.326Z",
        "actualEndTime": "2020-04-07T21:43:52.000Z",
        "isDefaultBroadcast": false
       }
      }
     ]
    }


Solution

  • The documentation states that:

    string (return type) The ID of the currently active live chat attached to this video. This field is filled only if the video is a currently live broadcast that has live chat. Once the broadcast transitions to complete this field will be removed and the live chat closed down. For persistent broadcasts that live chat id will no longer be tied to this video but rather to the new video being displayed at the persistent page.

    Emphasis mine.

    This means that YouTube destroys the liveChatId after completion (more precisely, ~400 seconds after the stream or premiere ends), so acquiring the liveChatId is impossible by legal ways. Moreover, even if you manage to get that ID, you will not be able to use that to modify the chat of a previous livestream.