We use cookies to offer an improved online experience and offer you content and services adapted to your interests.
By using Dailymotion, you are giving your consent to our cookies.
Funny Tweets by Rob Corddry & More Get Animated. Submit Yours NOW! Watch the videos
</Developer>

Graph API

Introduction

The Graph API is a simple way to access, publish and modify data on Dailymotion. The Graph API presents a simple, consistent view of the Dailymotion objects (e.g., users, videos, playlists, etc.) and connections between them (e.g., friend relationship, user’s posted videos, videos in groups/playlits, etc.).

Every object in the Dailymotion Graph API have an ID unique for a given class of object. You can access fields of an object by requesting https://api.dailymotion.com/<class>/ID, where class can be video, user, etc. Here are some example of object URLs:

All of the objects in the Dailymotion Graph API are connected to each other via relationships. A user can like a video or be friend with another user. Users can own videos, playlists, groups and playlist contains videos. All those relationships are called connections in a Graph API. You can examine the connections between objects using the URL structure https://api.dailymotion.com/CLASS/OBJECT_ID/CONNECTION_TYPE. Here are some examples of supported connections:

(Note: /me is a shortcut in the API refering to the currenly logged user. It is equivalent to /user/LOGGED_USER_ID)

All of the different types of objects and connections we support are included in the API Reference.

Response Types

All responses are JSON objects. There is two kind of JSON response types: item and list. The item response type is a JSON object with a single level of key value pairs. This kind of response is used when a single object is requested:

{
  "id":"xf2pow",
  "screenname":"John Doe",
  "language":"fr"
}

The keys are requested fields name with their corresponding values. See Fields Selection for more info.

The list response type is a JSON object with a list property containing an array of items. Some other properties are also returned like:

  • page: The current requested page number, by default the page 1 is returned. You can pass the page parameter to request other pages (maximum page number is 100).
  • limit: The current max number of item per response page. You can change this limit using the limit parameter (maximum number of items per page is 100).
  • has_more: This (Boolean) property tells if there is more pages after the current one. This can help you decide if you show a “more” button in your UI.
  • total: This property defines the total number of item in the result set. This proprety isn’t always there and may sometime return an approximative number. Do not trust this value to compute pagination as you may not be able to get the number of page this value implies. Prefer the has_more value to know if there’s a next page.
{
  "page":1,
  "limit":10,
  "has_more":true,
  "list":
  [
    {"id":"xf2pow", "title":"Tony Bennett plans Winehouse"},
    {"id":"xf2v32", "title":"Escape From City 17"},
    {"id":"xemyk2", "title":"Portal : No Escape"},
    {"id":"xf35xa", "title":"Earthquake Ignites Social Media Frenzy"},
    {"id":"xf02xp", "title":"Triple Kiss! - The Worst Generation #3"},
    {"id":"xf38x0", "title":"Billion Points Finalists"},
    {"id":"xettt9", "title":"The Best of Gamescom 11"},
    {"id":"xf3cxr", "title":"Review: If Only It Was \"30 Minutes or Less\""},
    {"id":"xf3ix6", "title":"Cold War Kids - Cold Toes On The Cold Floor"},
    {"id":"xf3jaa", "title":"Matthew Morrison Tour Rehearsal"}
  ]
}

Fields Selection

All objects are composed of fields. They all have the id plus some other fields defined in the API Reference. Some fields are publically readable, some others needs user authentication and may require additionnal permissions granted by the user.

By default, few fields are returned. To requests specific fields, you are can use the fields parameter with the list fields you need in the response. You are encouraged to always use fields to request only the fields you will use in your application. For instance, to select the id and the title fields of a video object, perform an HTTP GET request to /video/VIDEO_ID?fields=id,title. The response will be a JSON object like this:

{
  "id":"xk2kdj",
  "title":"The video title"
}

If a field is said to return an object, selecting the field will return the object id. In such case you can request a sub-field of this object by adding the sub-field name to the field, separated by a dot. For instance, on the owner field of the video object returns a user object. If you need the screenname and the url field of the video owner, you can perform a request like this: /video/VIDEO_ID?fields=id,title,owner,owner.screenname,owner.url. The response will be as follow:

{
  "id":"xk2kdj",
  "title":"The video title",
  "owner":"xw4k2d",
  "owner.screenname":"John Doe",
  "owner.url":"http://www.dailymotion.com/johndoe"
}

This also work for list of objects and connections.

Some fields are also writable. Only the owner of the object can write fields, and certain fields may require additionnal permissions granted by the user to your API key. To write a field, perform an HTTP POST request to the object URL with the fields you want to modify as query string with there new values. For instance, to modify the title and the channel fields of a video, POST the following query-string title=NEW%20TITLE&channel=CHANNEL to https://api.dailymotion.com/video/VIDEO_ID.

Finally, some fields can be used for filtering. To filter on a field, perform an HTTP GET request to a list URL with the fields to filter on as query string. For instance, to get all french videos, GET the following URLs: https://api.dailymotion.com/videos?language=fr.

Dates

All dates are expressed a UNIX timestamp in seconds since epoch. We also support most date format as input.

Authorization

The Dailymotion API uses OAuth 2.0 for authorization. Check out the authentication guide for details on the Dailymotion’s OAuth 2.0 implementation.

At a high level, using OAuth 2.0 entails getting an access token for a Dailytmotion user via a redirect to Dailymotion. After you obtain the access token for a user, you can perform authorized requests on behalf of that user by including the access token in your API requests:

https://api.dailymotion.com/video/xettt9?access_token=<ACCESS_TOKEN>

To obtain an access token:

  • Register your application to get an API Key and secret. Your Dailymotion API Key is your client_id and your Dailymotion API secret is your client_secret.

  • Redirect the user to https://api.dailymotion.com/oauth/authorize with your client_id and the redirect_uri. The redirect_uri parameter needs to begin with the Callback URL you assigned to your API Key:

    https://api.dailymotion.com/oauth/authorize?
        client_id=<API_KEY>&
        redirect_uri=http://www.example.com/oauth_redirect
  • After the user authorizes your application, the user is then redirected back to the redirect URI you specified with a verification string on the code argument, which can be exchanged for an oauth access token. Exchange it for an access token by fetching https://api.dailymotion.com/oauth/token. Pass the exact same redirect_uri as in the previous step:

    https://api.dailymotion.com/oauth/token?
        grant_type=authorization_code&
        client_id=<API_KEY>&
        client_secret=<API_SECRET>&
        redirect_uri=http://www.example.com/oauth_redirect&
        code=<AUTHORIZATION_CODE>
  • Use the access token returned by the request above to make requests on behalf of the user:

    https://api.dailymotion.com/videos/uploaded?access_token=<ACCESS_TOKEN>

Once you authenticated a user on the API, you can use the special identifier me which refers to the currently authenticated user. So the URL https://api.dailymotion.com/me returns the active user’s profile.

Publishing

You can publish videos via the Dailymtion Graph API by issuing HTTP POST requests to the appropriate URLs (see API Reference). For example, you can post a new video by issuing a POST request to https://api.dailymotion.com/me/videos:

curl -F 'access_token=...' \
     -F 'url=http://upload-02.dailymotion.com/files/5ccb48b8e8aef3fcb8959739f993e1b9.3gp' \
     https://api.dailymotion.com/me/videos

You can edit the title of a video by posting to https://api.dailymotion.com/video/VIDEO_ID:

curl -F 'access_token=...' \
     -F 'title=My New Title' \
     https://api.dailymotion.com/video/xf38x0

You can add a comment on the video by posting to https://api.dailymotion.com/video/VIDEO_ID/comments:

curl -F 'access_token=...' \
     -F 'message=My comment text' \
     https://api.dailymotion.com/video/xf38x0/comments

You can add the video to your favorites by posting to https://api.dailymotion.com/me/favorites/VIDEO_ID:

curl -F 'access_token=...' \
     https://api.dailymotion.com/me/favorites/xf38x0

Most write operations require extended permissions through OAuth scope from the user. See the authentication guide for details on how you can request extended permissions from the user during the authentication step.

For a full list of writeable fields and connections and their supported parameters, see API Reference.

Deleting

You can delete objects by issuing HTTP DELETE requests to the object URLs, i.e.:

curl -X DELETE https://api.dailymotion.com/video/VIDEO_ID?access_token=...

To support clients that do not support all HTTP methods (like JavaScript clients), you can alternatively issue a GET request to an object URL with the additional argument method=delete to override the HTTP method. For example, you can delete a comment by issuing a GET request to https://api.dailymotion.com/comment/COMMENT_ID?method=delete.

Caching

The REST API uses HTTP cache control mechanisms. If you want to benefit from caching, you have to make sure URLs don’t change between requests. To that end, you should always sort query string parameters by alphabetic order and send the access_token using the Authorization HTTP header as follow:

curl -H 'Authorization: OAuth <ACCESS_TOKEN>' https://api.dailymotion.com/videos

As requests are transmitted over SSL, your requests’ responses cannot be stored on public intermediate proxy cache servers. However, if your application can potentially share the cache between different users, you have to be sure you only share responses marked as public in the Cache-Control header. This should be done automatically by your HTTP library if it respects the Vary header sent with private cacheable responses though.

Table Of Contents