Getting started overview

Integrating with the Dailymotion API allows developers to programmatically manage video content, user interactions, and channel settings. The process involves creating a Dailymotion partner account, registering an application to receive API credentials, and then authenticating requests using the OAuth 2.0 protocol. The API supports various operations, from uploading and embedding videos to managing live streams and accessing analytics data. This guide focuses on the initial steps required to make a successful API call.

The Dailymotion API is a RESTful interface, primarily using JSON for data exchange. While no official SDKs are provided by Dailymotion, developers can interact with the API using standard HTTP client libraries in their preferred programming language. The API documentation includes an interactive explorer to test endpoints directly in a browser, which can be useful for understanding request and response structures before writing code.

Quick Reference: Dailymotion API Getting Started

Step What to do Where
1. Create Account Sign up for a Dailymotion Partner account. Dailymotion Partner Plans
2. Register Application Create a new application to obtain Client ID and Client Secret. Dailymotion Developer Portal: Application Registration
3. Understand OAuth 2.0 Familiarize yourself with the OAuth 2.0 authorization code flow. Dailymotion API Authentication Guide
4. Get Authorization Code Redirect user to Dailymotion for consent and receive an authorization code. Your application's backend or frontend
5. Exchange Code for Token Use the authorization code to request an access token and refresh token. Your application's backend
6. Make API Request Include the access token in the Authorization header for API calls. API endpoint specified in Dailymotion API Reference

Create an account and get keys

To access the Dailymotion API, you must first create a Dailymotion Partner account. This account type provides access to the developer portal and tools necessary for API integration. Navigate to the Dailymotion partner plans page and select a suitable plan. The Starter plan offers a free entry point for development and basic usage, while paid plans provide expanded features and capacity suitable for publishers and businesses.

Once your partner account is active, proceed to register an application within the Dailymotion developer portal. This step is crucial for obtaining your API credentials. During application registration, you will be prompted to provide details such as your application's name, description, and a redirect URI. The redirect URI is a critical component for OAuth 2.0, as it specifies where Dailymotion should send the authorization code after a user grants your application permission. Ensure this URI is correctly configured to a URL your application controls and can process.

Upon successful registration, Dailymotion will provide you with a Client ID and a Client Secret. These are your API keys. The Client ID identifies your application to Dailymotion, while the Client Secret is a confidential key used to authenticate your application when exchanging an authorization code for an access token. It is imperative to keep your Client Secret secure and never expose it in client-side code or public repositories. Store it securely in your server-side environment variables or a secrets management system to prevent unauthorized access to your application's Dailymotion account.

Your first request

Making your first request to the Dailymotion API involves the OAuth 2.0 Authorization Code Grant Flow. This flow ensures secure delegation of user permissions without sharing their Dailymotion credentials directly with your application. The general steps are:

  1. Initiate Authorization: Redirect the user to Dailymotion's authorization endpoint. This URL will include your Client ID, the redirect URI, the requested scopes (permissions), and the response type (code). For example, to request read access to the user's videos, you might use scope=read-videos. A comprehensive list of available scopes can be found in the Dailymotion API Authentication documentation.
  2. User Consent: The user logs into Dailymotion (if not already logged in) and is prompted to grant your application the requested permissions.
  3. Receive Authorization Code: If the user grants permission, Dailymotion redirects their browser back to your specified redirect URI, appending an authorization code as a query parameter.
  4. Exchange Code for Tokens: Your application's backend should capture this authorization code and immediately exchange it for an access token and a refresh token. This is done by making a POST request to Dailymotion's token endpoint, including your Client ID, Client Secret, the authorization code, and the redirect URI. The response will be a JSON object containing the access_token, refresh_token, expires_in (in seconds), and other relevant data.
  5. Make API Call: With the access token, you can now make authenticated requests to Dailymotion API endpoints. Include the access token in the Authorization header of your HTTP requests, typically as a Bearer token (e.g., Authorization: Bearer YOUR_ACCESS_TOKEN).

For instance, to retrieve information about the currently authenticated user, you would make a GET request to the /me endpoint:

GET https://api.dailymotion.com/me?fields=id,screenname,description
Authorization: Bearer YOUR_ACCESS_TOKEN

This request, when successful, would return a JSON object containing the authenticated user's ID, screen name, and description, based on the requested fields. The fields parameter is common across many Dailymotion API endpoints, allowing you to specify exactly which data points you need, thereby optimizing response sizes.

Common next steps

After successfully making your first authenticated API call, several common next steps can enhance your Dailymotion integration:

  • Refresh Tokens: Access tokens have a limited lifespan (indicated by expires_in). Implement a mechanism to use the refresh_token to obtain new access tokens before the current one expires, preventing service interruptions. The OAuth 2.0 specification details how to use refresh tokens to acquire new access tokens without requiring user re-authentication, as described in OAuth 2.0 Refresh Token Grant.
  • Upload Videos: Explore the Dailymotion video upload API to programmatically upload video files. This typically involves a multi-part form data request or a two-step process where you first request an upload URL, then upload the file, and finally confirm the upload with Dailymotion.
  • Manage Content: Utilize endpoints for managing uploaded videos, such as updating metadata (title, description, tags), setting privacy settings, or deleting content. The API provides extensive control over your video library.
  • Embed Videos: Learn how to generate embed codes for your videos using the API, allowing you to seamlessly integrate Dailymotion content into your websites or applications.
  • Handle Webhooks: Set up webhooks to receive real-time notifications about events, such as video processing completion, new comments, or monetization changes. This push-based communication can significantly improve the responsiveness of your application. Information on configuring webhooks is typically found within the application settings in the developer portal or specific API documentation sections.
  • Explore Live Streaming: If your Dailymotion plan supports it, investigate the API capabilities for managing and broadcasting live events.
  • Error Handling: Implement robust error handling in your application to gracefully manage API rate limits, invalid tokens, or malformed requests. The Dailymotion API returns standard HTTP status codes and JSON error responses to indicate issues.

Troubleshooting the first call

When encountering issues with your initial Dailymotion API calls, consider the following common problems and solutions:

  • Invalid Client ID or Client Secret: Double-check that you are using the correct Client ID and Client Secret values obtained from your registered application. Any mismatch will result in authentication failures.
  • Incorrect Redirect URI: The redirect URI used in your authorization request and token exchange must exactly match the one registered for your application in the Dailymotion developer portal. Even a minor difference in path or query parameters can cause an error.
  • Missing or Incorrect Scopes: Ensure that the scopes requested during the authorization step include the necessary permissions for the API call you are attempting. For example, to read user videos, you need the read-videos scope. If the requested scope is not granted or is invalid, the API call will be rejected.
  • Expired Access Token: Access tokens are temporary. If your token has expired, you will receive an authentication error. Use your refresh token to obtain a new access token. If you haven't implemented refresh token logic yet, you may need to re-authenticate the user to get a new authorization code and subsequently a new access token.
  • Incorrect Authorization Header: Verify that the Authorization header is correctly formatted as Bearer YOUR_ACCESS_TOKEN. A common mistake is omitting the "Bearer" prefix or having a typo.
  • API Rate Limits Exceeded: Dailymotion, like many APIs, imposes rate limits to prevent abuse. If you make too many requests in a short period, your requests may be temporarily blocked. Check the API documentation for specific rate limit details and implement exponential backoff or token bucket algorithms in your application to manage request frequency.
  • Network Issues: Ensure your application has proper network connectivity to reach api.dailymotion.com. Firewall rules or proxy settings can sometimes interfere with API requests.
  • Consult API Documentation: The official Dailymotion API documentation provides detailed error codes and explanations, which can be invaluable for diagnosing specific issues. Look for sections on error handling and specific endpoint behaviors.