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 usehttps://developer.dacast.com. Authenticate withX-Api-Keyand sendX-Format: default. A successful call returns 200. Query parameters such asstartdate/enddateare not required and are ignored.
Endpoints
| Content | JavaScript embed | iframe embed |
|---|---|---|
| VOD | GET /v2/vod/{id}/embed/javascript | GET /v2/vod/{id}/embed/iframe |
| Channel | GET /v2/channel/{id}/embed/javascript | GET /v2/channel/{id}/embed/iframe |
| Playlist | GET /v2/playlist/{id}/embed/javascript | GET /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>| API | UI | |
|---|---|---|
| Player script | player.dacast.com/js/player.js | prod-player.dacast.com/js/player.js |
| Wrapper | none | div with aspect-ratio: 1.78, min 480×270 |
| Script sizing | width / height attributes | position:absolute; width/height 100% |
| CSS class | dacast-video | dc-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
Updated about 16 hours ago
