The Dropbox JavaScript SDK is a lightweight, promise based interface to the Dropbox v2 API that works in both nodejs and browser environments.
Installation
Npm
Use npm for nodejs, webpack or browserify:
Script tag
The UMD build is available on unpkg:
You can find the library on window.Dropbox
.
Usage
Browser with <script>
<script src="https://unpkg.com/dropbox/dist/Dropbox-sdk.min.js"></script>
<script>
var dbx = new Dropbox({ accessToken: 'YOUR_ACCESS_TOKEN_HERE' });
dbx.filesListFolder({path: ''})
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log(error);
});
</script>
Nodejs, Browserify or Webpack
var Dropbox = require('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);
});
General documentation
Endpoints
For documentation of all of the available endpoints, the parameters they receive and the data they return, see theDropbox class definition. These methods are all available directly from an instance of the API class, ex:dbx.filesListFolder()
.
Teams
The Dropbox API has a series of actions that can be completed on a team wide level. These endpoint methods are available by using the DropboxTeam class. It can be loaded like this: var DropboxTeam = require('dropbox/team');
. For more information , see the DropboxTeam class definition.
Authentication
The Dropbox SDK uses OAuth 2 for authorizing API requests. Dropbox requires an access token to make authenticated requests. The access token can be supplied at instantiation or set later using the setAccessToken()
method.
Dropbox.getAuthenticationUrl()
is a method that is very helpful for authenticating users. See the authentication example for a basic example of how it can be used.
For more information on how to obtain an access token using OAuth, please see our OAuth Guide.
Promises implementation
The SDK returns Promises using the native Promise implementation and polyfills with jakearchibald/es6-promise when needed.
Unsupported API Endpoints
The SDK doesn't current have support for the Content-upload or Content-download endpoints. We are actively developing these and expect them to be released soon.
Examples
See examples/ for working examples of how the SDK can be used in a few different environments.
Versioning
We will try to follow semver as close as possible. That means bug fixes will be patch releases (1.0.1 -> 1.0.2), additional functionality like new endpoints will be minor releases (1.0.1 -> 1.1.0) and breaking changes to both the library and the API endpoints it hits, will be major releases (1.0.1 -> 2.0.0).
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于