Dropbox for JavaScript Developers

Dropbox for JavaScript

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

Code

Dropbox for JavaScript - Dropbox JavaScript SDK is open source on GitHub.

Install Dropbox for JavaScript

To get started with Dropbox for JavaScript, we recommend you add the SDK to your project using npm.

Install the JavaScript SDK

Download and install the SDK.

npm install --save dropbox

Then use with a module bundler

require('isomorphic-fetch'); // or another library of choice.
var Dropbox = require('dropbox').Dropbox;
var dbx = new Dropbox({ accessToken: 'YOUR_ACCESS_TOKEN_HERE' });
dbx.filesListFolder({path: ''})
  .then(function(response) {
    console.log(response);
  })
  .catch(function(error) {
    console.log(error);
  });

Dropbox for JavaScript tutorial

A good way to start using the JavaScript SDK is to follow this quick tutorial. Just make sure you have the the JavaScript SDK installed first!

Register a Dropbox API app

To use the Dropbox API, you'll need to register a new app in the App Console. 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 for your own account through the App Console).

var dbx = new Dropbox({ accessToken: ACCESS_TOKEN });

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

dbx.usersGetCurrentAccount()
  .then(function(response) {
    console.log(response);
  })
  .catch(function(error) {
    console.error(error);
  });

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:

dbx.filesListFolder({path: ''})
    .then(function(response) {
      console.log(response.entries);
    })
    .catch(function(error) {
      console.error(error);
    });

Documentation

You can read more in the documentation. Also checkout the examples folder on github

Dropbox for JavaScript documentation

Here's the full documentation for the JavaScript SDK