Dynamic Ad Insertion API for LIVE streams

The Google DAI API lets you implement Google DAI-enabled streams in environments where implementing the IMA SDK is not supported. We recommend that you still use IMA on platforms where the IMA SDK is supported.

We recommend using the DAI API on the following platforms:

  • Samsung Smart TV (Tizen)
  • LG TV
  • HbbTV
  • Xbox (JavaScript apps)
  • KaiOS

The API supports the basic capabilities provided by the IMA DAI SDK. For specific questions about compatibility or supported features, reach out to your Google account manager.

Implement the DAI API for LIVE streams

The DAI API supports linear (LIVE) streams using both HLS and DASH protocols. The steps described in this guide apply to both protocols.

To integrate the API into your app for LIVE streams, complete the following steps:

1. Request a stream

To request a livestream from the DAI API, make a POST call to the stream endpoint. The JSON response contains the stream manifest as well as associated DAI API endpoints and values.

Example request body


  key1 : "value1",
  stream_parameter1 : "value2"

Example response body


Error response

In case of errors, standard HTTP error codes are returned with no JSON response body.

Parse the JSON response and store the following values:

This value can be used to identify the returned stream.
This URL is passed to your media player for stream playback.
This URL is the base endpoint for tracking playback events.
This URL is used to poll for periodic information about upcoming stream events.
This URL is used to update stream request parameters sent during the initial stream request. Note that the parameters of this request replace all parameters set for the earlier stream.
The frequency, in seconds, when requesting updated AdBreak Metadata from the DAI API.

2. Poll for new AdBreak Metadata

Set a timer to poll for new AdBreak Metadata at the polling frequency, using the metadata URL. If not specified in the stream response, the default recommended interval is 10 seconds.

Example request body


Example response body

         "description":"truman-e2e-creativeset4 ad",

3. Listen to ID3 events and track playback events

To verify that specific events have occurred in a video stream, follow these steps to handle ID3 events:

  1. Store the media events in a queue, saving each media ID along with its timestamp (if surfaced by the player).
  2. On each time update from the player, or at a set frequency (recommended 500 ms), check the media events queue for recently played events by comparing the event timestamps to the playhead.
  3. For media events that you confirm have played, check the type by looking up the media ID in the stored ad break tags. Keep in mind that the stored tags only contain a prefix of the media ID so an exact match isn't possible.
  4. Use "progress" events to keep track of whether a user is inside an ad break. Don't send these events to the media verification endpoint. For other event types, append the media ID to the media verification endpoint and make a GET request to track playback.
  5. Remove the media event from the queue.

Example request body


Example responses

Accepted for asynchronous verification - HTTP/1.1 202 Accepted
Successful empty response - HTTP/1.1 204 No Content
Media verification not found - HTTP/1.1 404 Not Found
Media verification sent by someone else - HTTP/1.1 409 Conflict

You can verify tracking events in Stream Activity Monitor.

4. Update livestream session parameters

You might want to adjust your session parameters after a stream has been created. To do so, make a request to the session update URL.

Example request body


  key1 : "value1",
  stream_parameter1 : "value2"

Example response body

Successful response would be to look for - HTTP/1.1 200


If using the API within webviews, the following limitations apply with respect to targeting:

  • UserAgent: The user agent parameter is passed as browser specific value instead of the underlying platform.
  • rdid, idtype, is_lat: The device ID is not properly passed, which limits the capabilities of the following features:
    • Frequency capping
    • Sequential ad rotation
    • Audience segmentation and targeting

Best practices

Keep in mind that the metadata endpoint for livestream indexes is based on the prefix of the corresponding ID3 tag. This is by design to prevent the use of the metadata endpoint for immediately pinging all of the verification nodes.

Additional resources