Dropbox for Python
A Python SDK for integrating with the Dropbox API v2. Compatible with Python 2.7 and 3.4+. Documentation is available on Read the Docs.
$ pip install dropbox
Install from source:
$ git clone git://github.com/dropbox/dropbox-sdk-python.git $ cd dropbox-sdk-python $ python setup.py install
After installation, to get started, open a Python console:
>>> import dropbox >>> dbx = dropbox.Dropbox("YOUR_ACCESS_TOKEN") >>> dbx.users_get_current_account()
Creating an Application
You need to create an Dropbox Application to make API requests.
Obtaining an Access Token
All requests need to be made with an OAuth 2 access token. To get started, once you've created an app, you can go to the app's console and generate an access token for your own Dropbox account.
An example, updown.py, can be found in the examples directory, which demonstrates how to sync a local directory with a Dropbox.
Documentation can be compiled by running
make html from the
folder. After compilation, open
you can read a hosted version from Read the Docs.
Updating API specification
To prepare the repo for generation, run these commands after cloning:
$ git submodule init $ git submodule update
You can run
git pull within these sub repositories to update the pinned
Now, run the included script:
Upgrading from v1
To ease the transition to the new API and SDK, you can still use the old
dropbox.client.DropboxClient class. In fact, v2 and v1 can be used
simultaneously. Support for the old client will be dropped once the new SDK is
at functional parity.
We use the tox package to run tests in Python
2 and 3. To install, use
pip install tox. Once installed, run tox from the
root directory. You'll need to specify a working Dropbox OAuth2 token:
$ DROPBOX_TOKEN=YOUR_TOKEN tox -- -k "'not test_team'"
Note that we skip
test_team which requires a team token with Member File Access.
To test this functionality, specify a
$ DROPBOX_TOKEN=... DROPBOX_TEAM_TOKEN=... tox
If you only want to test the API v2 client, use:
$ DROPBOX_TOKEN=... DROPBOX_TEAM_TOKEN=... tox -- -k TestDropbox