Embed Codes

How do I embed content with the API?

Once you have a VOD, live channel, or playlist id, you can fetch an embed snippet with a GET. There is no create/upload step here - the endpoint only returns HTML.

📘

All examples use https://developer.dacast.com. Authenticate with X-Api-Key and send X-Format: default. A successful call returns 200. Query parameters such as startdate / enddate are not required and are ignored.

Endpoints

ContentJavaScript embediframe embed
VODGET /v2/vod/{id}/embed/javascriptGET /v2/vod/{id}/embed/iframe
ChannelGET /v2/channel/{id}/embed/javascriptGET /v2/channel/{id}/embed/iframe
PlaylistGET /v2/playlist/{id}/embed/javascriptGET /v2/playlist/{id}/embed/iframe

Use playlist (singular) for embed. Playlist CRUD is /v2/playlists; /v2/playlists/{id}/embed/… also returns 200 but builds a contentId / iframe path with playlists that the player does not use.

The rest of this page uses VOD. Channel and playlist work the same way; only the path segment and the host path in the iframe (/vod/, /live/, /playlist/) change.


Request

curl "https://developer.dacast.com/v2/vod/{vodId}/embed/javascript" \
  -H "X-Api-Key: insertYourApiKeyHere" \
  -H "X-Format: default"
fetch('https://developer.dacast.com/v2/vod/' + vodId + '/embed/javascript', {
  headers: {
    'X-Api-Key': 'insertYourApiKeyHere',
    'X-Format': 'default'
  }
})
  .then((response) => response.json())
  .then((body) => {
    // body.code is already HTML
  });

Iframe:

curl "https://developer.dacast.com/v2/vod/{vodId}/embed/iframe" \
  -H "X-Api-Key: insertYourApiKeyHere" \
  -H "X-Format: default"

Response

The body is JSON with one field, code. < / > are JSON-escaped as \u003c / \u003e. Parse the JSON and use code as HTML - do not run unescape() or html.unescape() on the raw string.

JavaScript embed:

{
  "code": "<script id=\"root_user_id-vod-VOD_ID\" width=\"100%\" height=\"100%\" src=\"https://player.dacast.com/js/player.js?contentId=root_user_id-vod-VOD_ID\"  class=\"dacast-video\"></script>"
}

iframe embed:

{
  "code": "<iframe src=\"https://iframe.dacast.com/vod/root_user_id/VOD_ID\"  width=\"512\" height=\"288\" frameborder=\"0\" scrolling=\"no\" allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen></iframe>"
}

Insert code into the page. For a channel, the iframe host path is /live/; for a playlist, /playlist/.

The src / contentId matches the UI share link. The HTML around it does not: the API still returns a legacy snippet, the UI returns a responsive one.

API vs UI

JavaScript - API (GET …/embed/javascript):

<script id="root_user_id-vod-VOD_ID" width="100%" height="100%" src="https://player.dacast.com/js/player.js?contentId=root_user_id-vod-VOD_ID"  class="dacast-video"></script>

JavaScript - UI:

<div style="min-height: 270px; min-width: 480px; width: 100%; position: relative; aspect-ratio: 1.78;">
  <script
    id="root_user_id-vod-VOD_ID"
    style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"
    src="https://prod-player.dacast.com/js/player.js?contentId=root_user_id-vod-VOD_ID"
    class="dc-video">
  </script>
</div>
APIUI
Player scriptplayer.dacast.com/js/player.jsprod-player.dacast.com/js/player.js
Wrappernonediv with aspect-ratio: 1.78, min 480×270
Script sizingwidth / height attributesposition:absolute; width/height 100%
CSS classdacast-videodc-video

iframe - API (GET …/embed/iframe): fixed width="512" height="288", no wrapper, no allow.

iframe - UI: responsive 16:9 wrapper (padding-bottom:56.25%), iframe width/height 100%, allow="autoplay;encrypted-media". Same src (https://iframe.dacast.com/vod/root_user_id/VOD_ID).

Until the API snippet matches the UI, copy the embed from the UI if you need the current player and responsive layout. The API code is enough if you only need the iframe src or contentId.

Reference: Lookup Embed Code (resource_type: vod, channel, playlist - not playlists).


After you have an embed