---
updatedAt: 2026-07-27T10:11:30.000Z
agentTools:
  projectIndex: https://developers.dailymotion.com/v0/llms.txt
---

# Python SDK

<br />

The Python SDK for using the [Platform API](https://developers.dailymotion.com/v0/reference/password-method) is available on our [GitHub](https://github.com/dailymotion/dailymotion-sdk-python).

***

## Installation

Install the `dailymotion` module:

```python
$ pip install dailymotion
```

Or:

```python
$ git clone git@github.com:dailymotion/dailymotion-sdk-python.git
$ cd dailymotion-sdk-python
$ python setup.py install
```

***

## Authentication

The Platform API requires OAuth 2.0 authentication to access protected resources.

The Dailymotion Python SDK uses **lazy authentication**, meaning no authentication request is made until data is actually requested. When the first request is made, the SDK sends two back‑to‑back calls: one for authentication, one for data.

The SDK **abstracts the entire OAuth flow**, automatically handling access tokens, refresh tokens, and session management.

Session storage is enabled by default and can be disabled using:

```python
dailymotion.Dailymotion(session_store_enabled=False)
```

Access tokens are stored in memory by default, but storing them in your OS file system is recommended:

```python
import dailymotion

# The ./data directory
file_session = dailymotion.FileSessionStore('./data')

d = dailymotion.Dailymotion(session_storage=file_session)
...
```

***

## Tests

1. Install dependencies:

```python
$ pip install -r requirements.txt
```

2. Update the file `config.py` or use environment variables with:

```python
CLIENT_ID = '[YOUR API KEY]'
CLIENT_SECRET = '[YOUR API SECRET]'
USERNAME = '[YOUR USERNAME]'
PASSWORD = '[YOUR PASSWORD]'
REDIRECT_URI = '[YOUR REDIRECT URI]'
BASE_URL = 'https://api.dailymotion.com'
OAUTH_AUTHORIZE_URL = 'https://www.dailymotion.com/oauth/authorize'
OAUTH_TOKEN_URL = 'https://api.dailymotion.com/oauth/token'
```

3. Run tests:

```python
$ py.test TestDailymotion.py
```

***

## Examples

### API call without authentication

```python
d = dailymotion.Dailymotion()
d.get('/videos')
```

### Set your own access token (your token must still be valid)

```python
d = dailymotion.Dailymotion()
d.set_access_token(YOUR_ACCESS_TOKEN)
d.get('/me')
```

### Authenticated call

```python
d = dailymotion.Dailymotion()
d.set_grant_type(
    'password',
    api_key=API_KEY,
    api_secret=API_SECRET,
    scope=['userinfo'],
    info={'username': USERNAME, 'password': PASSWORD}
)

d.get('/me', {'fields': 'id,fullname'})
```

### Video Upload

```python
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(
    "/me/videos",
    {
        "url": url,
        "title": "MyTitle",
        "published": "true",
        "channel": "news",
        "is_created_for_kids": "false",
    },
)
```