Table of content

Upload your content on Dailymotion


Uploading a video on your Dailymotion account can be done programmatically using our Platform API.

In this article, we’ll go through the complete upload workflow via the API, with detailed steps and code samples provided to help you getting started.

Note for Organizations:

All API calls and code samples in this guide can be used to upload content on child channels

Upload and publish videos

Uploading content on Dailymotion can be done through the following steps:

  1. Authenticate the user: Get an access token with the right scope to be able to upload on the channel
  2. Get an upload URL: Provide your access token to get a dedicated upload URL where you’ll be able to upload your content.
  3. Upload the video: Send your file to your upload URL
  4. Create the video: Create the video ID in your channel
  5. Publish the video: Set up the mandatory fields and publish your content
Upload content hosted on an external URL:

 

If your video has an external url, you don’t need to upload it to our servers and you can directly use this url as the video source.

Therefore, we invite you to reach the Create the video step directly and use your external URL as url value.

1. Authenticate the user

As uploading content is an action that impacts one’s account, you need to be authenticated with a user having access to the destination channel.

You will have to request an access token with the manage_videos scope to be able to upload content on the channel.

See the authentication guide for more information on how to authenticate the user and request an access token for our API calls.

Access token is required for this guide:

 

Your access token will be required for all the steps listed below.

We invite you to keep it close to you during the entiere process or add it as a variable on your project.

2. Get an upload URL

Now that you have your access token with the right scope, you’ll have to request an upload URL to Dailymotion in order to be able to send your file.

Perform a GET request to https://api.dailymotion.com/file/upload and include your access token in order to be able to get your upload URL.

The server will return 2 values :

  • The upload_url – the URL you will use in the next step to send your file on our servers
  • The progress_url – the URL you can use to track the upload status from your upload location to our servers

If you need more information about these 2 API fields, we invite you to read the File endpoint API Reference.

HTTP
cURL
GET /file/upload HTTP/1.1
Host: api.dailymotion.com
Authorization: Bearer YOUR_ACCESS_TOKEN
curl  https://api.dailymotion.com/file/upload
     -H "Authorization: Bearer ${ACCESS_TOKEN}"

Response

{
    "upload_url": "https://upload-XXX.dailymotion.com/upload?uuid=UUID&seal=SEAL&extra=CHANNEL_ID",
    "progress_url": "https://upload-XXX.dailymotion.com/progress?uuid=UUID"
}

3. Upload the video

You have generated your upload_url and you can now start your upload:

Perform a POST HTTP request to the upload_url using multipart/form-data content type and include the file field, filled with the content path to upload.

HTTP
cURL
POST /upload?uuid=XXX&seal=XXX&extra=XXX HTTP/1.1
Host: upload-XXX.dailymotion.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="YOUR_FILE"

(data)
------WebKitFormBoundary7MA4YWxkTrZu0gW--
curl -X POST \
     -F 'file=@/path/to/your/video.mp4' \
     '<UPLOAD_URL>'

Once the POST HTTP request is finished, the upload server will return in response several content metadata and the url field.

Response

{
    "acodec": "AAC",
    "bitrate": "1281806",
    "dimension": "400x848",
    "duration": "20852",
    "format": "MPEG-4",
    "hash": "XXX",
    "name": "My new upload",
    "seal": "XXX",
    "size": "3341029",
    "streamable": "Yes",
    "url": "https://upload-XXX.dailymotion.com/files/FILE_ID",
    "vcodec": "AVC"
}
Upload activity and failure:

 

About upload expiration

The upload url does not have an expiry term for uploading, although some activity has to be “seen” on started uploads at least every 4 hours.

If the upload POST fails, you need to reacquire a new upload_url.

About video upload limits

Upload is not unlimited on our platform and depends on your account type and settings.

To get more information about the upload limits, we invite you to read our rate limit section.

4. Create the video

Your video is uploading on the Dailymotion servers, and you can now use the url field value to create the Dailymotion video object on your channel.

Perform a POST call to https://api.dailymotion.com/user/<CHANNEL_ID>/videos and include the url field with its associated value.

HTTP
cURL
POST /user/CHANNEL_ID/videos HTTP/1.1
Host: api.dailymotion.com
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer YOUR_ACCESS_TOKEN

url=URL
curl -X POST 
    -H 'Content-Type: application/x-www-form-urlencoded' \
    -H ''Authorization: Bearer ${ACCESS_TOKEN}' \
    -d 'url=<URL>' \
     'https://api.dailymotion.com/user/<CHANNEL_ID>/videos'

This API call will create the video on your channel. The ID of the newly created video will be returned in the id field of the response.

Response

{
    "id": "NEW_VIDEO_ID",
    "title": "Sans Titre",
    "channel": null,
    "owner": "OWNER_ID"
}

5. Publish the video

Your video object is created, your content is uploaded on our server, you’re now ready to publish your content in order to finish the upload process.

Perform a POST request on https://api.dailymotion.com/video/<VIDEO_ID> with the published field set to true and fill the following mandatory fields:

  • title – The title of the video on the platform
  • is_created_for_kids – the audience targeted by your content
  • channel – The content category associated to your content (See our Channel object API Reference)

You can also specify additional content metadata such as description or tags. To get the full list of fields available for your content, we invite you to read our Video object API Reference.

HTTP
cURL
POST /video/<VIDEO_ID> HTTP/1.1
Host: api.dailymotion.com
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer YOUR_ACCESS_TOKEN

published=true
&title=YOUR_VIDEO_TITLE
&channel=news
&is_created_for_kids=true | false
curl -X POST 
    -H 'Content-Type: application/x-www-form-urlencoded' \
    -H ''Authorization: Bearer ${ACCESS_TOKEN}' \
    -d 'url=<URL>' \
     'https://api.dailymotion.com/user/<CHANNEL_ID>/videos'
About is_created_for_kids:

 

The is_created_for_kids field is a mandatory field which must be filled to identify the audience targeted by your content in order to coply with several laws such as COPPA and GDPR.

You can visit our Help Center for more information if you need additional insights on how to determine the audience of your video, and check how to use the “is_created_for_kids” mandatory field.

Upload & Publish at the same time:

 

You can perform steps 4 and 5 in a single HTTP request by passing all the extra information in the initial POST request as follows:

curl -X POST \
     -H "Authorization: Bearer ${ACCESS_TOKEN}" \
     -d 'url=<VIDEO_URL>' \
     -d 'title=Dailymotion cURL upload test' \
     -d 'channel=videogames' \
     -d 'published=true' \
     -d 'is_created_for_kids=false' \
     "https://api.dailymotion.com/user/<CHANNEL_ID>/videos"

Resume function

We provide a resume function for uploading videos. In this case, you have to replace /upload by /rupload in the upload url. The protocol is described in this NGinx module page.


Check your upload usage

To check your current limits at the video level, you can request the limits field on your own user using the API, like this: /user/<CHANNEL_ID>?fields=limits (you will need to be authenticated).


Code samples

PHP
Javascript
Python
$url = $api->uploadFile('/path/to/your/video.mp4');
$api->post(
    '/user/<CHANNEL_ID>/videos',
    array(
        'url'       => $url,
        'title'     => 'My Title',
        'channel'   => 'videogames',
        'published' => true,
        'is_created_for_kids' => false,
    )
);
// get an upload url
DM.api('/file/upload', function (response)
{
    //upload the video and get the url
    var xhr =  new XMLHttpRequest();
    xhr.open('POST', response.upload_url, true);
    var formData = new FormData(document.getElementById("fileDomId"));
    xhr.send(formData);

    // check when video is uploaded
    xhr.onreadystatechange = function ()
    {
        if (xhr.readyState == 4)
        {
            // create the video object and publish the video
            DM.api(
                '/user/<CHANNEL_ID>/videos',
                'post',
                {
                    url: JSON.parse(xhr.response).url,
                    title: 'My Title',
                    channel: 'videogames',
                    published: 'true',
                    is_created_for_kids: 'false'
                }
            );
        }
    }
});
d = dailymotion.Dailymotion()
d.set_grant_type('password', api_key=API_KEY, api_secret=API_SECRET,
    scope=['manage_videos'], info={'username': USERNAME, 'password': PASSWORD})
url = d.upload('./video.mp4')
d.post(
    "/user/<CHANNEL_ID>/videos",
    {
        "url": url,
        "title": "My Title",
        "published": "true",
        "channel": "news",
        "is_created_for_kids": "false",
    },
)