Introduction
A typical API call to the Dailymotion Platform REST API could look something like this:
GET https://api.dailymotion.com/videos?fields=id,title,language&channel=news&limit=100
In the above example, we are retrieving the following information from the Platform API: a list detailing the ID, title and language of the 100 most recent videos from the category news published on Dailymotion.com.
If this doesn't look familiar for now, this guide will introduce you to the basic elements you need to know to easily interact with the Platform API.
Endpoints
The Platform API is served over HTTPS and accessible on the following endpoint:
| Endpoint | Public API key | Private API key |
|---|---|---|
| https://api.dailymotion.com | ✔ | No - Public API key required |
| https://graphql.api.dailymotion.com | ✔ | No - Public API key required |
| https://partner.api.dailymotion.com/ | No - Private API key required | ✔ |
Encoding
We recommend using UTF-8 encoding for all interactions with the REST API.
Request types
You can interact with the Dailymotion API using the following HTTP request types:
GET
GET requests are used to retrieve resources.
Example: Retrieve public information about the video x3rdtfy.
https://api.dailymotion.com/video/x3rdtfyPOST
POST requests are used to create new resources or edit existing ones.
Example: To edit the title of a video.
curl -X POST \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
-F 'title=My New Title' \
"https://api.dailymotion.com/video/<VIDEO_ID>"DELETE
DELETE requests are used to delete resources.
Example: Delete a video.
curl -X DELETE \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
"https://api.dailymotion.com/video/<VIDEO_ID>"Objects & Connections
Objects
The Platform API works with objects and IDs.
Here is a list of the various graph objects available through the Platform API. Some of them will only be available for reading, and some others for creation and edition too. Each object within has a unique identifier automatically assigned at creation.
| Object name | Short description |
|---|---|
| **video ** | The video object is the foundation of Dailymotion service. Videos are metadata containers wrapped around media streams and can be accessed either directly or through several connections through the Platform API. |
| player | A player object holds several configuration properties (Picture-in-Picture settings, aspect ratio...) and is meant to be embedded with a <script> tag. |
| playlist | A playlist object represents an ordered list of videos created by a user. Videos in a playlist do not necessarily have anything in common. |
| subtitles | A subtitle object represents a file resource containing closed captioning for a given video. |
| user | A user object represents a Dailymotion user account. Users are at the foundation of every other graph objects, since most of them are created through — or owned by — users. Users also represent the main authentication vector to Dailymotion services. |
You can access the information of an object using this URL structure:
https://api.dailymotion.com/<OBJECT_CLASS>/<OBJECT_ID>
Example: Retrieve information about the video that has the unique ID x3rdtfy.
GET https://api.dailymotion.com/video/x3rdtfy
Connections
All of these objects are connected to each other via relationships: users own playlists, playlists own videos, videos own subtitles, etc. In a Graph API, these relationships are called connections.
You can explore the connections between objects using the URL structure
https://api.dailymotion.com/<OBJECT_CLASS>/<OBJECT_ID>/<CONNECTED_OBJECT>
Example: Retrieve the list of videos of the user identified with the ID x1fz4ii.
GET https://api.dailymotion.com/user/x1fz4ii/videos
The Platform API reference lists the supported objects and connections.
Fields
API objects are composed of fields that contain different pieces of information.
Some fields are publicly readable, some others are not and require specific scopes granted during authentication. The privacy and required scopes for each field are specified in the reference:
By default, only a few fields are returned. To request specific ones, you can use the fields parameter and list the ones you need to be returned.
Let's see different examples of fields request:
Fields by default
In the example below, we are calling the video object with the ID x3rdtfy, but we don't request any specific fields to be returned:
GET https://api.dailymotion.com/video/x3rdtfyThe JSON response to this call will return the default fields for a video object:
{
"id": "x3rdtfy",
"title": "Midnight Sun | Iceland",
"channel": "travel",
"owner": "x1aktrv"
}idof the videotitleof the videochannel: category of the videoowner: user ID of the uploader
Specific fields
In the below example, we are calling the same video object than above, but we are specifying the fields we want to be returned (see exhaustive list of fields available for a video object). To do so, we are using the fields parameter followed by each specific field we want, separated by a comma:
GET https://api.dailymotion.com/video/x3rdtfy?fields=id,url,publishedThis call will return the following JSON response:
{
"id": "x3rdtfy",
"url": "https://www.dailymotion.com/video/x3rdtfy",
"published": true
}Connected fields
Since some objets can be connected together, fields from these connected objects can also be assembled.
For instance, the owner field of a video object returns the id of a user object. Because these two objects can be connected, you can use any field of the user object (see echaustive list of user fields) and assemble it with the video field of your choice, separated by a dot.
For instance, to retrieve the screenname and url of the owner of the video x3rdtfy, you can perform this request:
GET https://partner.api.dailymotion.com/rest/video/x3rdtfy?fields=id,title,owner,owner.screenname,owner.url
The response will look like this:
{
"id": "x3rdtfy",
"title": "Midnight Sun | Iceland",
"owner": "x1aktrv",
"owner.screenname": "Zeno",
"owner.url": "https://www.dailymotion.com/zeno"
}owner.screenname: name of the user who uploaded the videoowner.url: URL of the user who uploaded the video
Filters
Some fields can also be used as filters to narrow down a list of objects.
All filters are listed in the reference, in the filters section of each object:
To use filters, perform a GET request and put your filters as query string parameters.
Example: The following request will list all english-speaking videos published in the category 'technology'.
GET https://api.dailymotion.com/videos?channel=tech&language=en
Caching
The Platform API uses HTTPS Cache Control Mechanisms so you can benefit from security and speed improvements when performing API calls.
We recommend following the below guidelines to benefit from caching:
-
If you're using fields and/or filters in your query, sort them in alphabetic order. This will ensure the same URLs is used for each specific request.
-
Send the access token in the Authorization HTTP header in order to keep this sensitive information out of the URL, like so:
curl -H "Authorization: Bearer ${ACCESS_TOKEN}" \
"https://api.dailymotion.com/file/upload"
- If your application can potentially share the cache between different users, make sure you only share responses marked as "public" in the
Cache-ControlHTTP header. If your HTTP library respects theVaryHTTP header, it should automatically manage how to share and handle cached responses.
