liveBroadcast
resource corresponds to exactly one YouTube video resource. In fact, the liveBroadcast
resource and the video
resource share the same ID. And after creating the broadcast using the Live Streaming API, you can use the YouTube Data API to provide additional metadata about the video.liveStream
liveStream
resource can be bound to exactly one liveBroadcast
resource. Similarly, the liveBroadcast
resource can only be bound to one liveStream
resource.cuepoint
liveBroadcasts.cuepoint
method to insert a cuepoint during a broadcast. video
liveBroadcast
resource is an extension of a video
resource. You can use the YouTube Data API to update metadata about the video, such as the recording location or the regions where the broadcast will be viewable.videoAdvertisingOptions
asset
asset
resources.claim
policy
The following table shows the different methods that the API supports:
Operations | |
---|---|
list | Retrieves (GET ) a list of zero or more resources. |
insert | Creates (POST ) a new resource. |
update | Modifies (PUT ) an existing resource to reflect data in your request. |
bind | Links a liveBroadcast resource with a liveStream resource or removes such a link. |
transition | Changes the status of a liveBroadcast resource and initiates any processes associated with the new status. For example, when you transition a broadcast's status to testing , YouTube starts to transmit video to that broadcast's monitor stream. |
delete | Removes (DELETE ) a specific resource. |
The table below identifies the operations that are supported for different types of resources. Operations that insert, update, or delete resources always require user authorization. In some cases, list
methods support both authorized and unauthorized requests, where unauthorized requests only retrieve public data while authorized requests can also retrieve information that is restricted to the currently authenticated user.
Supported Operations | |||||||
---|---|---|---|---|---|---|---|
list | insert | update | bind | transition | cuepoint | delete | |
liveBroadcast | |||||||
liveStream |
The API allows, and actually requires, the retrieval of partial resources so that applications avoid transferring, parsing, and storing unneeded data. This approach also ensures that the API uses network, CPU, and memory resources more efficiently.
The part
parameter is a required parameter for any API request that retrieves or returns a YouTube Data API resource. The parameter identifies one or more top-level (non-nested) resource properties that should be included in an API response. For example, a liveStream
resource has the following parts:
snippet
cdn
status
All of these parts are objects that contain nested properties, and you can think of these objects as groups of metadata fields that the API server might (or might not) retrieve. As such, the part
parameter requires you to select the resource components that your application actually uses. This requirement serves two important purposes:
Over time, as resources add more parts, these benefits will only increase since your application will not be requesting newly introduced properties that it doesn't support.
If you would like to show ads during your broadcast, you need to claim the broadcast video before the event begins. To claim content, you must be a YouTube Content Partner participating in the Content ID program.
The process for claiming your live broadcast video is different than the normal process for claiming a video. When claiming live video, you need to create your claim before the video actually exists. The API does support this, and the life of a broadcast document explains the YouTube Content ID API calls that enable you to create your claim.
Upon receiving your inbound video stream, YouTube can then broadcast that video on two different outbound streams:
The monitor stream enables you to preview (and test) your video broadcast. It is a private stream that is only accessible to you. You can only transition a broadcast to the testing
phase if the broadcast's monitor stream is enabled. The monitor stream does not show ad breaks.
The broadcast stream is the stream visible to your audience. You can set the broadcast's privacy status to either public
, private
, or unlisted
. (A private broadcast is only visible to users who have been explicitly invited to watch it, while an unlisted broadcast is visible to anyone with a link to view it.)
You can choose to delay the broadcast stream so that it does not run concurrently with the monitor stream. By delaying the broadcast stream, you can have more fine-grained control over the time that you insert cuepoints into the broadcast.
However, delaying the broadcast stream makes it difficult for your live presenters to interact with your viewing audience. In addition, delaying the broadcast increases the likelihood that viewers will discover key details about the event from sources other than your broadcast. For example, if you are broadcasting a sporting event on a 60-second delay, viewers might learn about critical moments in the event from other real-time news sources before actually seeing them in the broadcast.
YouTube recommends that you enable the monitor stream for your broadcast so that you can test your content. You should choose whether to also delay your broadcast based on your desire to control timing of cuepoints as opposed to your desire to interact with your audience or provide real-time coverage of an event.
During a broadcast, you can insert a cuepoint to indicate that an ad break should start in the broadcast as soon as possible or at a specified time. The ad break enables YouTube to run midroll ads during the broadcast.
Ad breaks have the following characteristics:
It has a predefined length of time, which you set using the cuepoint
resource's durationSecs
property. After the ad break concludes, viewers return to the live broadcast.
When an ad break happens, an ad only plays in the video player for viewers who are watching the broadcast when the cuepoint is inserted. An ad does not run when viewers refresh the page where the broadcast is playing or when visitors start watching the broadcast after the cuepoint is inserted.
The sequence of steps below reflects the best practice for inserting an ad break during your broadcast:
When inserting a cuepoint, you can specify that it should be inserted right away or that it should be inserted at a specific point in the broadcast. Your options depend on whether the broadcast stream for your video is delayed.
If your broadcast stream is not delayed, then you can insert the cuepoint immediately or use the walltimeMs
property to have the ad break start at a particular time.
liveBroadcasts.cuepoint
method. In the resource in the request body, set the insertionOffsetTimeMs
property's value to 0
or do not specify a value for that property and do not specify a value for the walltimeMs
property.Important: Note that viewers do not see the resulting ad content immediately. There may be a delay of around 30 seconds before the ad content is visible to users. During that delay, your broadcast stream will still be visible to your viewers, and you need to watch the broadcast stream to determine when the ad content actually displays instead of your monitor stream.
To start the ad break at a particular time, call the liveBroadcasts.cuepoint
method and use the walltimeMs
property to specify the desired time. The property value is an integer that represents an epoch timestamp.
If your broadcast stream is delayed, then you can insert the cuepoint immediately as described above, specify a clock time as described above, or you can specify a time offset to determine when the ad break will start. The time offset specifies a point in your broadcast when viewers should see an ad.
The offset value is measured in milliseconds from the beginning of the monitor stream for your broadcast. Note that if your broadcast has a testing phase, then the monitor stream starts when your broadcast transitions to the testing
status. Otherwise, your monitor stream starts when your broadcast transitions to the live
status.
When inserting a cuepoint, set the cuepoint
resource's insertionOffsetTimeMs
property to the desired offset.
To retrieve the offset value, call the YouTube Player API's getCurrentTime
function for the player that is playing the monitor stream. Use the retrieved value to insert the cuepoint in the broadcast stream at that time.
The possible values for the offset time can be calculated as the following range:
[(elapsed_time - broadcast_delay + Δ), (elapsed_time - Δ)]
The Δ
is a five-second buffer at the beginning and end of the possible time offsets when YouTube cannot precisely insert a cuepoint. For example:
live
status. (This is three minutes after the broadcast stream becomes visible.)In this case, the possible range of offset times is [(485,000), (535,000)]
.
These times are specified in milliseconds, and are calculated using the following values:
elapsed_time=540000
– The monitor stream has run for nine minutes (540 seconds, 540000 milliseconds) when the liveBroadcasts.cuepoint
method is called.broadcast_delay=60000
– The broadcast stream is delayed by 60 seconds, or 60000 milliseconds.Δ=5000
– The five-second buffer when the cuepoint cannot be reliably inserted.The following guidelines explain how to resolve specific problems that may arise. For the lists of errors that each API method might return, see YouTube Live Streaming API - Errors.
When a broadcast transitions from one status to another, it may temporarily be assigned with another status while YouTube completes the actions associated with the transition. For example, if you send a liveBroadcasts.transition
request to change a broadcast's status from ready
to testing
, YouTube will set the broadcast's status to testStarting
and then complete the actions associated with the status change. When all of those actions have been completed, YouTube will update the broadcast's status to testing
, thereby indicating that the transition is complete.
If a broadcast becomes stuck with a testStarting
or liveStarting
status, you need to call the liveBroadcasts.delete
method and delete the broadcast. Then create a new broadcast, bind it to your live stream, and continue with the testing process.
As noted in the liveBroadcasts.transition
method's documentation, you should confirm that the value of the status.streamStatus
property for the stream bound to your broadcast is active
before calling that method.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-03-31 UTC.