Using YouTube API v3 to tell if a channel has a live stream

前端 未结 1 1424
情话喂你
情话喂你 2020-12-14 20:44

The goal of my YouTube API call is, given a channelId, to return whether that channel is currently live streaming. This is the call I\'m making currently:

h         


        
相关标签:
1条回答
  • 2020-12-14 21:15

    Probably late but still someone else would use it, i found the answer on google api docs:

    https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/list (Scroll to bottom, you can use their onsite api to make calls on the fly)

    The call you have to make is:

    GET https://www.googleapis.com/youtube/v3/liveBroadcasts?part=id%2Csnippet%2Cstatus&mine=true&broadcastStatus=active&key={YOUR_API_KEY}
    

    (atm, they have an issue wth the status field). You can remove the filter and check the returned results for

    { "status": { "lifeCycleStatus": "live"}}
    

    And as per google docs:

    Before you start

    You need a Google Account to access the Google Developers Console, request an >API key, and register your application. Register your application with Google so that it can submit API requests. After registering your application, select the YouTube Data API as one of the >services that your application uses:

    Go to the Developers Console and select the project that you just registered. Open the API Library in the Google Developers Console. If prompted, select a >project or create a new one. In the list of APIs, make sure the status is ON for >the YouTube Data API v3 and, if you are a YouTube Content Partner, the YouTube >Content ID API.

    Calling the Data API

    The API request must be authorized by the Google Account that owns the >broadcasting YouTube channel.

    You can check this link for generating an access(OAuth 2.0) token: https://developers.google.com/identity/protocols/OAuth2?hl=en

    I hope this helps.

    0 讨论(0)
提交回复
热议问题