> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.dropboxapi.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.dropboxapi.com/_mcp/server.

# Python

#### Overview

## Dropbox for Python

Here's our Python SDK for API v2, which helps you easily integrate Dropbox into your Python app.

### Code

[Dropbox for Python](https://github.com/dropbox/dropbox-sdk-python) - Dropbox for Python SDK is open source on GitHub.

### Sample apps

* [back-up-and-restore.py](https://github.com/dropbox/dropbox-sdk-python/blob/master/example/back-up-and-restore/backup-and-restore-example.py) - Simple app that shows how to back up user files and restore them to a specific revision.

* [updown.py](https://github.com/dropbox/dropbox-sdk-python/blob/master/example/updown.py) - Simple app which demonstrates how to sync a local directory with a Dropbox.

#### Install

## Install Dropbox for Python

To get started with Dropbox for Python, we recommend you add the SDK to your project using [pip](https://pip.pypa.io/).

### Install the Python SDK

Download and install the SDK.

```bash
pip install dropbox
```

Now you can do "import dropbox" in your Python app, or in a Python interpreter.

```python
import dropbox
```

That's it! Now you're ready to get started with the [tutorial](#tutorial).

#### Tutorial

## Dropbox for Python tutorial

A good way to start using the Python SDK is to follow this quick tutorial. Just make sure you have the the Python SDK [installed](#install) first!

### Register a Dropbox API app

To use the Dropbox API, you'll need to register a new app in the [App Console](https://www.dropbox.com/developers/apps). Select Dropbox API app and choose your app's permission. You'll need to use the app key created with this app to access API v2.

### Link an account

In order to make calls to the API, you'll need an instance of the Dropbox object. To instantiate, pass in the access token for the account you want to link. (Tip: You can [generate an access token](https://dropbox.tech/developers/generate-an-access-token-for-your-own-account) for your own account through the [App Console](https://www.dropbox.com/developers/apps)).

```python
dbx = dropbox.Dropbox('YOUR_ACCESS_TOKEN')
```

Test it out to make sure you've linked the right account:

```python
dbx.users_get_current_account()
```

### Try some API requests

You can use the Dropbox object you instantiated above to make API calls. Try out some of the files requests.

List all of the contents in the user's root directory:

```python
for entry in dbx.files_list_folder('').entries:
    print(entry.name)

# OUTPUT:
# Cavs vs Warriors
```

Upload a file (and take a wild guess at tomorrow's headline):

```python
dbx.files_upload(b"Potential headline: Game 5 a nail-biter as Warriors inch out Cavs", '/cavs vs warriors/game 5/story.txt')
```

Get the metadata for a file (and prove that you called it before the game was over!):

```python
print(dbx.files_get_metadata('/Cavs vs Warriors/Game 5/story.txt').server_modified)

# OUTPUT:
# 2015-06-15 02:45:12
```

You can read more in the [documentation](http://dropbox-sdk-python.readthedocs.org/). There's also a sample script called "updown.py" in the [examples](https://github.com/dropbox/dropbox-sdk-python/tree/master/example) folder. Check it out!

#### Documentation

## Dropbox for Python documentation

Here's the [full documentation](http://dropbox-sdk-python.readthedocs.org/) for the Python SDK.