5 great things to do with Dailymotion’s API

Dailymotion API is maybe more powerful then you expected! Are you ready to code? Here are 5 cool video applications you can develop very easily using our technology.

1. Embed a video on a website

Embedding a video on your website via Dailymotion’s API allows you to enjoy the power of our video player to provide the best user experience to your visitors. Our iframe-based embed player has been made to help you in this process. To retrieve and embed code from a video, you can either:

However, you choose to proceed your code will look like this:

<iframe frameborder="0" width="480" height="270"src="https://www.dailymotion.com/embed/video/VIDEO_ID?PARAMS"allowfullscreen allow="autoplay"></iframe>

2. Customize a video player

Thanks to our API, you can customize your video player settings, such as colors, logos or even behaviors, in order to match your brand identity. PARAMS are query-string parameters that allow you to create your own and unique player (the documentation is available in the Player parameters section). You can modify a video player via the PARAMS option of the DM.player() method from the JavaScript SDK:

<script src="https://api.dmcdn.net/all.js"></script><div id="player"></div><script>var player = DM.player(document.getElementById("player"), {    video: "x6q8kum",    width: "100%",    height: "100%",    params: {        autoplay: true,        mute: true    }});</script>

Or via query-string parameters in the embed <iframe>’s src attribute:

<iframe frameborder="0" width="480" height="200"src="https://www.dailymotion.com/embed/video/x6q8kum?autoplay=1&mute=1"allowfullscreen allow="autoplay"></iframe>

Customized Player dailymotion

3. Add subtitles to a video

Dailymotion’s API can also help you to manipulate the subtitles of your videos. A subtitle object is a file resource that contains closed captioning. If you want to create a new subtitle object, you have to perform a POST request on the connection available through the video graph object.

Sample subtitle API call:

curl -X POST -H "Authorization: Bearer ${ACCESS_TOKEN}" \     -d 'language=en' \     -d 'url=https://your_site.com/subtitle_file.srt' \     -d 'format=SRT' \     https://api.dailymotion.com/video/x6q8kum/subtitles

Don’t forget to join the fields you want to specify and their value as an application/x-www-form-urlencoded payload (mandatory fields and query-string parameters here). For example, "url" is the address where you stored the subtitle file, "format" is the format of the subtitle file (“SRT” can be used as a value for the most common subtitle files format: SubRip Text) and finally, "language" is used to specify the language used in the subtitle file.

4. Protect a video with a password

You can protect the access to a video by adding a password to it. All you have to do is to set a value on the following field and the video visibility will change to “password protected”:

Password code video dailymotion
curl -X POST -H "Authorization: Bearer ${ACCESS_TOKEN}" \     -d 'password=MyPassword' \     https://api.dailymotion.com/video/x6q8kum

You can check if a video is already protected by a password by retrieving the value of the "password_protected" field:

Password video code
curl -X GET -H "Authorization: Bearer ${ACCESS_TOKEN}" \     https://api.dailymotion.com/video/x6q8kum?fields=password_protected

Tip: If you set the field to NULL, it removes the password protection and the visibility will change to “public”.

5. Manage a live streaming event

This feature has been created for Dailymotion’s partners who want to share their live video performance, as well as run advertisements and recordings on the content they are broadcasting. A video is considered as a live stream when its mode is set to live. For all operations regarding live streaming management, you need to request an access token with the manage_videos scope.

Live player dailymotion

We hope you learned a lot of new things about our API reading this article! If you feel inspired and want to join Dailymotion as a partner, check out the partnership guide for details.