0

I am trying to integrate a system that allows my website to detect whether a livestream is available or not so I can hide or show it depending on if the video is available.

This is also being done using Wix Velo, which makes things a bit more confusing.

I tried

export async function getLiveStatus() {
    const ytKey = await getSecret("youtube_API_Key")
    try {
        const getIsLive = await fetch('https://www.googleapis.com/youtube/v3/videos?id=VIDEOID&part=snippet&key=API_KEY')
        const data = await getIsLive.json()
        return data.items[0];
    } catch (err) {
        console.log(err)
        return err
    }
}

It returned Cannot read property '0' of undefined I was expecting it to give a json output with details about the video.

Ryan
  • 11
  • 2
  • The API being used doesn't seem to be the live/broadcast APIs? – evolutionxbox Apr 03 '23 at 14:52
  • Could you point me in the right direction? @evolutionxbox – Ryan Apr 03 '23 at 14:54
  • https://developers.google.com/youtube/v3/live/docs/liveBroadcasts – evolutionxbox Apr 03 '23 at 15:06
  • @evolutionxbox thanks! I found this, https://stackoverflow.com/questions/22310972/using-youtube-api-v3-to-tell-if-a-channel-has-a-live-stream, however it is outdated and now requires an OAuth2 client ID. I don't understand the documentation on how to add my OAuth2. Would you be able to help me out? – Ryan Apr 04 '23 at 00:32

0 Answers0