SDKs overview

Dailymotion provides a suite of tools for developers to integrate its video platform into their applications. These tools primarily consist of official Software Development Kits (SDKs) for server-side languages and a robust Player API for client-side interactions. The SDKs abstract the complexities of direct API requests, offering methods to interact with Dailymotion's API endpoints for video management, user data, and channel operations. The Player API focuses on embedding and controlling the Dailymotion video player within web pages and applications. Developers authenticate their applications using OAuth 2.0, which is supported across all official integration methods.

The Dailymotion API enables functionalities such as uploading videos, managing metadata, creating and organizing channels, and retrieving detailed analytics. For developers building web applications, the Player API offers granular control over playback, events, and player customization. Community-contributed libraries also extend Dailymotion's reach into additional programming languages and frameworks, providing alternative integration paths.

Official SDKs by language

Dailymotion maintains official SDKs for popular programming languages, designed to simplify interaction with their API and embed their player. These SDKs are actively maintained and documented on the official Dailymotion Developer Portal.

Language Package/Library Installation Command (Example) Maturity
PHP dailymotion/sdk composer require dailymotion/sdk Stable
Python dailymotion (via PyPI) pip install dailymotion Stable
JavaScript (Player API) Embedded script <script src="https://geo.dailymotion.com/libs/player/x2z5v.js"></script> Stable

Installation

Installation procedures vary depending on the chosen language and the specific SDK. Below are common installation methods for the official Dailymotion SDKs.

PHP SDK

The Dailymotion PHP SDK is distributed via Composer, the dependency manager for PHP. To integrate it into a PHP project, navigate to your project directory in the terminal and execute the following command:

composer require dailymotion/sdk

This command downloads the SDK and its dependencies, making them available for use in your PHP application. Further details on PHP SDK usage are available in the Dailymotion documentation.

Python SDK

The Dailymotion Python SDK is available on PyPI (Python Package Index) and can be installed using pip, the standard package installer for Python.

pip install dailymotion

After installation, the library can be imported into Python scripts to interact with the Dailymotion API. The Python SDK documentation provides examples for authentication and API calls.

JavaScript Player API

The Dailymotion Player API for JavaScript does not require a package manager installation. Instead, it is loaded directly into a web page via a <script> tag, typically placed in the <head> or before the closing </body> tag.

<script src="https://geo.dailymotion.com/libs/player/x2z5v.js"></script>

This script provides access to the DM object, which allows developers to embed players and control their behavior. The Dailymotion Player API reference details its methods and events.

Quickstart example

This example demonstrates how to embed a Dailymotion video player and subscribe to a playback event using the JavaScript Player API.

First, include the Dailymotion Player API script and create a <div> element to house the player:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Dailymotion Player Quickstart</title>
</head>
<body>
    <div id="dmplayer"></div>

    <script src="https://geo.dailymotion.com/libs/player/x2z5v.js"></script>
    <script>
        var player;
        window.onload = function() {
            player = DM.player(document.getElementById('dmplayer'), {
                video: 'x2y_t6w',
                width: '640',
                height: '360',
                params: {
                    autoplay: true
                }
            });

            player.addEventListener('apiready', function() {
                console.log('Dailymotion Player API is ready.');
                player.play();
            });

            player.addEventListener('ended', function() {
                console.log('Video has ended.');
            });
        };
    </script>
</body>
</html>

In this example:

  1. The Dailymotion Player API script is loaded.
  2. An empty <div> with the ID dmplayer is designated as the player container.
  3. Upon window load, DM.player() is called to initialize the player, specifying the container element and configuration options like the video ID (x2y_t6w is an example video ID), dimensions, and autoplay settings.
  4. Event listeners are attached to the player instance for apiready and ended events, demonstrating how to react to player state changes. The Dailymotion Player API events list provides a comprehensive overview of available events.

Community libraries

Beyond the official SDKs, the Dailymotion developer community has contributed libraries and integrations for various platforms and frameworks. While not officially supported by Dailymotion, these libraries can offer solutions for specific use cases or preferred development environments.

Examples of community contributions often include:

  • Client-side frameworks: Integrations for popular JavaScript frameworks like React, Angular, or Vue.js, simplifying the embedding and control of Dailymotion players within component-based architectures.
  • Mobile development: Libraries or wrappers for native iOS (Swift/Objective-C) or Android (Java/Kotlin) applications to streamline video playback and API interaction on mobile devices.
  • Other programming languages: Unofficial SDKs for languages not covered by Dailymotion's official offerings, developed to interface with the Dailymotion API.

Developers seeking community-supported solutions typically explore public repositories on platforms such as GitHub or package registries specific to their programming language. It is advisable to review the maintenance status, issue trackers, and community activity of any third-party library before incorporating it into a project.

When using community libraries, developers should be aware that support, updates, and compatibility with the latest Dailymotion API changes may vary. For mission-critical applications, the official SDKs and direct API integration are generally recommended due to guaranteed support and adherence to API specifications.

The Dailymotion API documentation serves as the authoritative source for all API endpoints and data models, which remains consistent irrespective of the chosen SDK or library. Developers can consult the Dailymotion API reference documentation for comprehensive details on available operations and response structures.