├── .npmignore ├── index.js ├── config.json.dist ├── .gitignore ├── example ├── credentials.json.dist ├── test-file ├── oauth2-flow.js ├── oauth2-mixed.js ├── oauth2-token.js └── partial-upload.js ├── test ├── config.js ├── docs │ └── docs-change-detection.js ├── users │ └── users.js └── files │ ├── upload_session.js │ └── files.js ├── src ├── dropbox-api-test.js ├── utils.js ├── generate-api-examples.js ├── dropbox-api.js └── generate-api-description.js ├── generate.js ├── .github └── workflows │ ├── main.yml │ ├── ci.yml │ └── npmpublish.yml ├── package.json ├── LICENSE.md ├── README.md └── EXAMPLES.md /.npmignore: -------------------------------------------------------------------------------- 1 | config.json 2 | example -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./src/dropbox-api.js'); -------------------------------------------------------------------------------- /config.json.dist: -------------------------------------------------------------------------------- 1 | { 2 | "DROPBOX_TOKEN": "PLEASE ENTER YOU DROPBOX_TOKEN HERE" 3 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | example/credentials.json 3 | .DS_Store 4 | examples.out 5 | config.json 6 | .idea/ -------------------------------------------------------------------------------- /example/credentials.json.dist: -------------------------------------------------------------------------------- 1 | { 2 | "TOKEN": "your token", 3 | "APP_SECRET": "app secret", 4 | "APP_KEY": "app token" 5 | } -------------------------------------------------------------------------------- /test/config.js: -------------------------------------------------------------------------------- 1 | const config = require('nconf'); 2 | config.env().file({ file: './config.json' }); 3 | config.required(['DROPBOX_TOKEN']); 4 | 5 | module.exports = config; -------------------------------------------------------------------------------- /src/dropbox-api-test.js: -------------------------------------------------------------------------------- 1 | let TEST_LIB_NAME; 2 | 3 | TEST_LIB_NAME = './dropbox-api.js'; 4 | // TEST_LIB_NAME = 'dropbox-v2-api'; 5 | 6 | module.exports = require(TEST_LIB_NAME); -------------------------------------------------------------------------------- /example/test-file: -------------------------------------------------------------------------------- 1 | 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 -------------------------------------------------------------------------------- /generate.js: -------------------------------------------------------------------------------- 1 | const generateApiDescription2 = require('./src/generate-api-description.js'); 2 | generateApiDescription2() 3 | // const {decompress} = require("compress-json"); 4 | // const apiJSON = require('./src/api.json'); 5 | // console.log(decompress(apiJSON)); 6 | -------------------------------------------------------------------------------- /src/utils.js: -------------------------------------------------------------------------------- 1 | const tester = require('stream-tester'); 2 | 3 | /** 4 | * Creates read stream, which generates length-sized stream of characters (sign) 5 | * Total length of stream is (length * sign.length) 6 | */ 7 | function createMockedReadStream(sign, length){ 8 | return tester.createRandomStream(function () { 9 | return sign; 10 | }, length); 11 | } 12 | 13 | module.exports = { 14 | createMockedReadStream 15 | }; -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | repository_dispatch: {} 5 | 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@master 11 | - uses: actions/setup-node@master 12 | with: 13 | node-version: 16.x 14 | - run: npm install 15 | - name: Run a multi-line script 16 | run: | 17 | echo RUNNING GENERATE 2, 18 | npm run generate 19 | ls 20 | cat src/api.json 21 | - uses: adasq/dropbox-v2-api-watcher@v0.4 22 | env: 23 | TOKEN: ${{ secrets.TOKEN }} 24 | with: 25 | myInput: 'test' 26 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Integration Tests 2 | 3 | on: 4 | workflow_dispatch: {} 5 | push: 6 | branches: 7 | - master 8 | schedule: 9 | - cron: 0 6 * * * 10 | 11 | jobs: 12 | build: 13 | 14 | runs-on: ubuntu-latest 15 | 16 | strategy: 17 | matrix: 18 | node-version: [16.x] 19 | 20 | steps: 21 | - uses: actions/checkout@v1 22 | - name: Use Node.js ${{ matrix.node-version }} 23 | uses: actions/setup-node@v1 24 | with: 25 | node-version: ${{ matrix.node-version }} 26 | - name: npm install, build, and test 27 | run: | 28 | npm install 29 | npm run build --if-present 30 | npm test 31 | env: 32 | TOKEN: ${{ secrets.TOKEN }} 33 | DROPBOX_TOKEN: ${{ secrets.DROPBOX_TOKEN }} 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dropbox-v2-api", 3 | "version": "2.5.12", 4 | "description": "NodeJS Dropbox v2 API wrapper", 5 | "main": "index.js", 6 | "scripts": { 7 | "generate": "node generate.js", 8 | "test": "mocha test/**/*.js" 9 | }, 10 | "keywords": [ 11 | "dropbox", 12 | "api", 13 | "v2", 14 | "wrapper", 15 | "node" 16 | ], 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/adasq/dropbox-v2-api.git" 20 | }, 21 | "author": "adasq", 22 | "license": "ISC", 23 | "dependencies": { 24 | "compress-json": "2.1.2", 25 | "request": "2.88.2" 26 | }, 27 | "devDependencies": { 28 | "@hapi/hapi": "19.1.1", 29 | "async": "1.5.0", 30 | "cheerio": "0.22.0", 31 | "ejs": "2.5.6", 32 | "expect.js": "0.3.1", 33 | "js-beautify": "1.14.0", 34 | "md5": "2.3.0", 35 | "mocha": "^7.1.2", 36 | "nconf": "0.11.3", 37 | "opn": "3.0.3", 38 | "should": "8.0.2", 39 | "stream-spec": "0.3.6", 40 | "stream-tester": "0.0.5", 41 | "underscore": "^1.13.1" 42 | } 43 | } -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Adam Płócieniak 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/npmpublish.yml: -------------------------------------------------------------------------------- 1 | name: Publish to NPM 2 | 3 | on: 4 | workflow_dispatch: {} 5 | push: 6 | branches: 7 | - master 8 | paths: 9 | - 'api/*.json' 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v1 16 | - uses: actions/setup-node@v1 17 | with: 18 | node-version: 16 19 | - run: npm install 20 | version: 21 | needs: build 22 | runs-on: ubuntu-latest 23 | steps: 24 | - name: 'checkout' 25 | uses: actions/checkout@v1 26 | - name: 'update version and add tag' 27 | uses: adasq/dropbox-v2-api-watcher@prepublish 28 | with: 29 | myInput: ${{ github.event.action }} 30 | env: 31 | TOKEN: ${{ secrets.token }} 32 | OWNER: 'adasq' 33 | REPO: 'dropbox-v2-api' 34 | publish-npm: 35 | needs: version 36 | runs-on: ubuntu-latest 37 | steps: 38 | - uses: actions/checkout@v1 39 | with: 40 | ref: ${{ github.ref }} 41 | - uses: actions/setup-node@v1 42 | with: 43 | node-version: 16 44 | registry-url: https://registry.npmjs.org/ 45 | - run: npm publish 46 | env: 47 | NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} 48 | -------------------------------------------------------------------------------- /example/oauth2-flow.js: -------------------------------------------------------------------------------- 1 | /** 2 | * To run example you have to create 'credentials.json' file 3 | * in current location. 4 | * 5 | * File should contain JSON object, with 'APP_KEY' and 'APP_SECRET' properties. 6 | * 7 | * Do not forget to specify 'http://localhost:4000/oauth' in 'Redirect URIs' 8 | * section of your dropbox app settings. 9 | */ 10 | 11 | const dropboxV2Api = require('../src/dropbox-api.js'); 12 | const Hapi = require('@hapi/hapi'); 13 | const fs = require('fs'); 14 | const path = require('path'); 15 | const Opn = require('opn'); 16 | 17 | const credentials = JSON.parse(fs.readFileSync(path.join(__dirname, 'credentials.json'))); 18 | 19 | //set auth credentials 20 | const dropbox = dropboxV2Api.authenticate({ 21 | client_id: credentials.APP_KEY, 22 | client_secret: credentials.APP_SECRET, 23 | token_access_type: 'offline', 24 | redirect_uri: 'http://localhost:4000/oauth' 25 | }); 26 | 27 | //prepare server & oauth2 response callback 28 | (async () => { 29 | const server = Hapi.server({ 30 | port: 4000, 31 | host: 'localhost' 32 | }); 33 | 34 | server.route({ 35 | method: 'GET', 36 | path: '/oauth', 37 | handler: function (request, h) { 38 | var params = request.query; 39 | 40 | return new Promise((resolve) => { 41 | dropbox.getToken(params.code, function (err, response) { 42 | console.log(err); 43 | console.log('user\'s access_token: ', response.access_token); 44 | console.log('user\'s refresh_token: ', response.refresh_token); 45 | //call api 46 | dropbox({ 47 | resource: 'users/get_current_account' 48 | }, function (err, response) { 49 | console.log(err); 50 | resolve(response); 51 | }); 52 | //or refresh token! 53 | dropbox.refreshToken(response.refresh_token, (err, result) => { 54 | console.log(err); 55 | console.log(result); 56 | }) 57 | }); 58 | }) 59 | } 60 | }); 61 | 62 | await server.start(); 63 | Opn(dropbox.generateAuthUrl()); 64 | console.log('Server running on %s', server.info.uri); 65 | })() 66 | -------------------------------------------------------------------------------- /example/oauth2-mixed.js: -------------------------------------------------------------------------------- 1 | /** 2 | * To run example you have to create 'credentials.json' file 3 | * in current location. 4 | * 5 | * File should contain JSON object, with 'APP_KEY', 'APP_SECRET' and 'TOKEN' properties. 6 | * 7 | * Do not forget to specify 'http://localhost:5000/oauth' in 'Redirect URIs' 8 | * section of your dropbox app settings. 9 | */ 10 | 11 | const dropboxV2Api = require('../src/dropbox-api.js'); 12 | const Hapi = require('@hapi/hapi'); 13 | const fs = require('fs'); 14 | const path = require('path'); 15 | const Opn = require('opn'); 16 | 17 | const credentials = JSON.parse(fs.readFileSync(path.join(__dirname, 'credentials.json'))); 18 | 19 | //setup two separated sessions, dropboxSession1 and dropboxSession2 20 | const dropboxSession1 = dropboxV2Api.authenticate({ 21 | client_id: credentials.APP_KEY, 22 | client_secret: credentials.APP_SECRET, 23 | redirect_uri: 'http://localhost:5000/oauth' 24 | }); 25 | 26 | const dropboxSession2 = dropboxV2Api.authenticate({ 27 | token: credentials.TOKEN 28 | }); 29 | 30 | //prepare server & oauth2 response callback 31 | (async () => { 32 | const server = Hapi.server({ 33 | port: 5000, 34 | host: 'localhost' 35 | }); 36 | 37 | server.route({ 38 | method: 'GET', 39 | path: '/oauth', 40 | handler: function (request, h) { 41 | var params = request.query; 42 | 43 | return new Promise((resolve) => { 44 | dropboxSession1.getToken(params.code, function (err, response) { 45 | //call api 46 | dropboxSession1({ 47 | resource: 'users/get_current_account' 48 | }, function (err, dropboxSession1Response) { 49 | dropboxSession2({ 50 | resource: 'users/get_current_account' 51 | }, function (err, dropboxSession2Response) { 52 | resolve({ 53 | 'dropboxSession1 response': dropboxSession1Response.name.display_name, 54 | 'dropboxSession2 response': dropboxSession2Response.name.display_name 55 | }); 56 | }); 57 | }); 58 | }); 59 | }) 60 | } 61 | }); 62 | 63 | await server.start(); 64 | Opn(dropboxSession1.generateAuthUrl()); 65 | console.log('Server running on %s', server.info.uri); 66 | })() 67 | -------------------------------------------------------------------------------- /test/docs/docs-change-detection.js: -------------------------------------------------------------------------------- 1 | const should = require('should'); 2 | const fs = require('fs'); 3 | const md5 = require('md5'); 4 | const path = require('path'); 5 | const request = require('request'); 6 | const expect = require('expect.js'); 7 | const {decompress} = require("compress-json"); 8 | const generate = require('../../src/generate-api-description.js'); 9 | 10 | const API_DESC_FILE_PATH = path.join(__dirname, '../../src/api.json'); 11 | describe('Docs change detection', function() { 12 | this.timeout(16000); 13 | describe('', () => { 14 | afterEach(function(done) { 15 | if(this.currentTest.state === 'failed'){ 16 | notifyGithub(done); 17 | } else { 18 | done(); 19 | } 20 | }) 21 | it('contains equal content', function (done) { 22 | try { 23 | const currentDocsDescription = normalizeString(JSON.stringify(decompress(JSON.parse(fs.readFileSync(API_DESC_FILE_PATH).toString())), null, '\t')) 24 | generate((err, retrievedDocsDescription) => { 25 | console.log(err) 26 | expect(err).to.be(null); 27 | 28 | retrievedDocsDescription = normalizeString(JSON.stringify(retrievedDocsDescription, null, '\t')); 29 | expect(md5(retrievedDocsDescription)).to.be(md5(currentDocsDescription)); 30 | done(); 31 | }); 32 | } catch(err) { 33 | console.log(err); 34 | throw err; 35 | } 36 | }); 37 | function normalizeString(str) { 38 | return str.replace(/\s+/g, ''); 39 | } 40 | }); 41 | }); 42 | 43 | function notifyGithub(done) { 44 | const authorization = `Basic ${Buffer.from(`adasq:${process.env.TOKEN}`).toString('base64')}` 45 | request.post({ 46 | url: 'https://api.github.com/repos/adasq/dropbox-v2-api/dispatches', 47 | body: { event_type : 'html.preview' }, 48 | json: true, 49 | headers: { 50 | 'User-Agent': 'curl/7.54.0', 51 | Authorization: authorization, 52 | 'Content-Type': 'application/json', 53 | Accept: 'application/vnd.github.everest-preview+json' 54 | } 55 | }, (err, resp, body) => { 56 | console.log(err); 57 | console.log(resp.statusCode); 58 | console.log(body); 59 | done() 60 | }) 61 | } -------------------------------------------------------------------------------- /example/oauth2-token.js: -------------------------------------------------------------------------------- 1 | /** 2 | * To run example you have to create 'credentials.json' file 3 | * in current location. 4 | * 5 | * File should contain JSON object, with 'TOKEN' property. 6 | */ 7 | 8 | const dropboxV2Api = require('../src/dropbox-api.js'); 9 | const utils = require('../src/utils.js'); 10 | 11 | const fs = require('fs'); 12 | const path = require('path'); 13 | 14 | const credentials = JSON.parse(fs.readFileSync(path.join(__dirname, 'credentials.json'))); 15 | 16 | //set token authentication: 17 | const dropbox = dropboxV2Api.authenticate({ 18 | token: credentials.TOKEN 19 | }); 20 | 21 | function createReadStream(sign, length) { 22 | return tester.createRandomStream(function () { 23 | return sign; 24 | }, length); 25 | } 26 | 27 | const CHUNK_LENGTH = 100; 28 | const firstUploadChunkStream = () => utils.createMockedReadStream('1', CHUNK_LENGTH); 29 | const secondUploadChunkStream = () => utils.createMockedReadStream('2', CHUNK_LENGTH); 30 | 31 | sessionStart((sessionId) => { 32 | sessionAppend(sessionId, () => { 33 | sessionFinish(sessionId); 34 | }); 35 | }); 36 | 37 | function sessionStart(cb) { 38 | dropbox({ 39 | resource: 'files/upload_session/start', 40 | parameters: { 41 | close: false 42 | }, 43 | readStream: firstUploadChunkStream() 44 | }, (err, response) => { 45 | if (err) { return console.log('sessionStart error: ', err) } 46 | console.log('sessionStart response:', response); 47 | cb(response.session_id); 48 | }); 49 | } 50 | 51 | 52 | function sessionAppend(sessionId, cb) { 53 | dropbox({ 54 | resource: 'files/upload_session/append', 55 | parameters: { 56 | cursor: { 57 | session_id: sessionId, 58 | offset: CHUNK_LENGTH 59 | }, 60 | close: false, 61 | }, 62 | readStream: secondUploadChunkStream() 63 | }, (err, response) => { 64 | if (err) { return console.log('sessionAppend error: ', err) } 65 | console.log('sessionAppend response:', response); 66 | cb(); 67 | }); 68 | } 69 | 70 | function sessionFinish(sessionId) { 71 | dropbox({ 72 | resource: 'files/upload_session/finish', 73 | parameters: { 74 | cursor: { 75 | session_id: sessionId, 76 | offset: CHUNK_LENGTH * 2 77 | }, 78 | commit: { 79 | path: "/result.txt", 80 | mode: "add", 81 | autorename: true, 82 | mute: false 83 | } 84 | } 85 | }, (err, response) => { 86 | if (err) { return console.log('sessionFinish error: ', err) } 87 | console.log('sessionFinish response:', response); 88 | }); 89 | } 90 | -------------------------------------------------------------------------------- /src/generate-api-examples.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | const ejs = require('ejs'); 4 | const beautify = require('js-beautify').js_beautify; 5 | 6 | var parsedApiDescription = JSON.parse(fs.readFileSync(path.join(__dirname, '../dist/api.json'))); 7 | const options = {}; 8 | 9 | const apiNameList = Object.keys(parsedApiDescription); 10 | 11 | const mdContent = apiNameList.map(apiName => { 12 | console.log(apiName) 13 | console.log(parsedApiDescription[apiName]) 14 | 15 | parsedApiDescription[apiName].request = parsedApiDescription[apiName].request || { example: [{}] } 16 | 17 | const example = prepareExampleByApiDescription(parsedApiDescription[apiName], apiName); 18 | return ` 19 | ### ${example.name} ([see docs](${example.docs})) 20 | ${example.description} 21 | 22 | \`\`\`js 23 | ${example.code} 24 | \`\`\` 25 | `; 26 | }); 27 | 28 | 29 | fs.writeFileSync('EXAMPLES.md', mdContent.join('\n')); 30 | 31 | 32 | function prepareExampleByApiDescription(apiDescription, apiName){ 33 | 34 | function prepareUrl() { 35 | const sufix = apiName.replace(/\//g, '-'); 36 | return `https://www.dropbox.com/developers/documentation/http/documentation#${sufix}`; 37 | } 38 | 39 | const templates = { 40 | 'rpc': ` 41 | dropbox({ 42 | resource: '${apiName}'<% if(request.example[0].value) { %>, 43 | parameters: <%- JSON.stringify(request.example[0].value, null, '') %> <% } %>}, (err, result, response) => { 44 | //see docs for \`result\` parameters 45 | }); 46 | `, 47 | 'upload': ` 48 | const stream = dropbox({ 49 | resource: '${apiName}', 50 | parameters: <%- JSON.stringify(request.example[0].value, null, '') %>}, (err, result, response) => { 51 | //see docs for \`result\` parameters 52 | }); 53 | 54 | fs.createReadStream(<%- request.example[0].value.path ? '\\''+request.example[0].value.path+'\\'': '' %>).pipe(stream); 55 | `, 56 | 'download': ` 57 | const stream = dropbox({ 58 | resource: '${apiName}', 59 | parameters: <%- JSON.stringify(request.example[0].value, null, '') %>}, (err, result, response) => { 60 | //see docs for \`result\` parameters 61 | }); 62 | 63 | stream 64 | .pipe(fs.createWriteStream(<%- request.example[0].value.path ? '\\''+request.example[0].value.path+'\\'': '' %>)); //pipe the stream 65 | ` 66 | } 67 | 68 | const template = ejs.compile(templates[apiDescription.format], options); 69 | const code = beautify(template(apiDescription), { indent_size: 4 }).replace(/\"/g, '\''); 70 | 71 | return { 72 | docs: prepareUrl(), 73 | name: apiName, 74 | description: apiDescription.description, 75 | code 76 | }; 77 | 78 | } 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /test/users/users.js: -------------------------------------------------------------------------------- 1 | const should = require('should'); 2 | const dropboxV2Api = require('../../src/dropbox-api-test.js'); 3 | const config = require('./../config.js'); 4 | 5 | let dropbox, dropboxMalformed; 6 | 7 | 8 | describe('Namespace', function() { 9 | this.timeout(6000); 10 | before(function() { 11 | dropbox = dropboxV2Api.authenticate({ 12 | token: config.get('DROPBOX_TOKEN') 13 | }); 14 | dropboxMalformed = dropboxV2Api.authenticate({ 15 | token: config.get('DROPBOX_TOKEN') + '1' 16 | }); 17 | }); 18 | beforeEach(function(){ 19 | console.log('-------------------------'); 20 | }); 21 | describe('users', () => { 22 | it('get_account fails', function (done) { 23 | dropboxMalformed({ 24 | resource: 'users/get_account', 25 | parameters: { 26 | account_id: 'dbid:AAA-vESAc6wjBUxydOH4U-J9hM5SNoQVMNk' 27 | } 28 | }, (err) => { 29 | err.error['.tag'].should.match(/invalid_access_token/); 30 | done(); 31 | }); 32 | }); 33 | it('get_account', function (done) { 34 | dropbox({ 35 | resource: 'users/get_account', 36 | parameters: { 37 | account_id: 'dbid:AAA-vESAc6wjBUxydOH4U-J9hM5SNoQVMNk' 38 | } 39 | }, (err, result, response) => { 40 | if(err){ throw err; } 41 | result.should.have.property('account_id'); 42 | response.headers.should.have.property('content-type', 'application/json'); 43 | done(); 44 | }); 45 | }); 46 | it('get_current_account', function (done) { 47 | dropbox({ 48 | resource: 'users/get_current_account' 49 | }, (err, result) => { 50 | if(err){ throw err; } 51 | result.should.have.property('account_id'); 52 | done(); 53 | }); 54 | }); 55 | 56 | it('get_space_usage', function (done) { 57 | dropbox({ 58 | resource: 'users/get_space_usage' 59 | }, (err, result) => { 60 | if(err){ throw err; } 61 | result.should.have.property('used'); 62 | done(); 63 | }); 64 | }); 65 | it('get_account_batch', function (done) { 66 | dropbox({ 67 | resource: 'users/get_account_batch', 68 | parameters: { 69 | account_ids: ['dbid:AAA-vESAc6wjBUxydOH4U-J9hM5SNoQVMNk'] 70 | } 71 | }, (err, result) => { 72 | if(err){ throw err; } 73 | result.should.be.an.Array(); 74 | done(); 75 | }); 76 | }); 77 | }); 78 | }); -------------------------------------------------------------------------------- /test/files/upload_session.js: -------------------------------------------------------------------------------- 1 | const should = require('should'); 2 | const expect = require('expect.js'); 3 | 4 | const dropboxV2Api = require('../../src/dropbox-api-test.js'); 5 | const utils = require('../../src/utils.js'); 6 | const config = require('./../config.js'); 7 | 8 | const CHUNK_LENGTH = 100; 9 | const firstUploadChunkStream = () => utils.createMockedReadStream('1', CHUNK_LENGTH); 10 | const secondUploadChunkStream = () => utils.createMockedReadStream('2', CHUNK_LENGTH); 11 | 12 | let dropbox; 13 | 14 | describe('Namespace ', function() { 15 | this.timeout(10 * 000); 16 | before(function() { 17 | dropbox = dropboxV2Api.authenticate({ 18 | token: config.get('DROPBOX_TOKEN') 19 | }); 20 | }); 21 | describe('files/upload_session', () => { 22 | it('upload_session', function (done) { 23 | sessionStart((sessionId) => { 24 | sessionAppend(sessionId, () => { 25 | sessionFinish(sessionId, () => { 26 | done(); 27 | }); 28 | }); 29 | }); 30 | function sessionStart(cb) { 31 | dropbox({ 32 | resource: 'files/upload_session/start', 33 | parameters: { 34 | close: false 35 | }, 36 | readStream: firstUploadChunkStream() 37 | }, (err, response) => { 38 | if(err){ return console.log('sessionStart error: ', err) } 39 | expect(response).to.have.key('session_id'); 40 | cb(response.session_id); 41 | }); 42 | } 43 | 44 | 45 | function sessionAppend(sessionId, cb) { 46 | dropbox({ 47 | resource: 'files/upload_session/append_v2', 48 | parameters: { 49 | cursor: { 50 | session_id: sessionId, 51 | offset: CHUNK_LENGTH 52 | }, 53 | close: false, 54 | }, 55 | readStream: secondUploadChunkStream() 56 | }, (err, response) => { 57 | if(err){ return console.log('sessionAppend error: ', err) } 58 | should(response).be.exactly(null) 59 | cb(); 60 | }); 61 | } 62 | 63 | function sessionFinish(sessionId, cb) { 64 | dropbox({ 65 | resource: 'files/upload_session/finish', 66 | parameters: { 67 | cursor: { 68 | session_id: sessionId, 69 | offset: CHUNK_LENGTH * 2 70 | }, 71 | commit: { 72 | path: "/result.txt", 73 | mode: "add", 74 | autorename: true, 75 | mute: false 76 | } 77 | } 78 | }, (err, response) => { 79 | if(err){ return console.log('sessionFinish error: ', err) } 80 | expect(response.size).to.be(CHUNK_LENGTH * 2); 81 | cb(); 82 | }); 83 | } 84 | 85 | }); 86 | }); 87 | }); 88 | 89 | -------------------------------------------------------------------------------- /example/partial-upload.js: -------------------------------------------------------------------------------- 1 | /** 2 | * To run example you have to create 'credentials.json' file 3 | * in current location. 4 | * 5 | * File should contain JSON object, with 'TOKEN' property. 6 | */ 7 | 8 | const dropboxV2Api = require('../src/dropbox-api.js'); 9 | 10 | const fs = require('fs'); 11 | const path = require('path'); 12 | 13 | const credentials = JSON.parse(fs.readFileSync(path.join(__dirname, 'credentials.json'))); 14 | 15 | //set token authentication: 16 | const dropbox = dropboxV2Api.authenticate({ 17 | token: credentials.TOKEN 18 | }); 19 | 20 | const CHUNK_LENGTH = 41; 21 | 22 | const FILE_PATH = path.join(__dirname, 'test-file'); 23 | const FILE_SIZE = fs.statSync(FILE_PATH).size; 24 | 25 | const getNextChunkStream = (start, end) => fs.createReadStream(FILE_PATH, { start, end }); 26 | 27 | const append = (sessionId, start, end) => { 28 | if (start === FILE_SIZE) { // this means we have entire file uploaded, so commit 29 | return sessionFinish(sessionId); 30 | } 31 | 32 | if (end > FILE_SIZE) { // this last chunk might be smaller 33 | end = FILE_SIZE - 1; 34 | console.log(`uploading ${end - start + 1} bytes (from ${start} to ${end}) (last smaller chunk)`); 35 | return sessionAppend(sessionId, start, FILE_SIZE - 1, () => { 36 | return sessionFinish(sessionId, FILE_SIZE); 37 | }) 38 | } 39 | console.log(`uploading ${end - start + 1} bytes (from ${start} to ${end})`); 40 | sessionAppend(sessionId, start, end, () => { 41 | append(sessionId, end + 1, end + CHUNK_LENGTH) 42 | }); 43 | } 44 | 45 | sessionStart((sessionId) => { 46 | append(sessionId, 0, CHUNK_LENGTH - 1) // first chunk 47 | }); 48 | 49 | function sessionStart(cb) { 50 | dropbox({ 51 | resource: 'files/upload_session/start', 52 | parameters: { 53 | close: false 54 | }, 55 | }, (err, result, response) => { 56 | if (err) { return console.log('sessionStart error: ', err) } 57 | console.log('sessionStart result:', result); 58 | cb(result.session_id); 59 | }); 60 | } 61 | 62 | function sessionAppend(sessionId, start, end, cb) { 63 | dropbox({ 64 | resource: 'files/upload_session/append', 65 | parameters: { 66 | cursor: { 67 | session_id: sessionId, 68 | offset: start 69 | }, 70 | close: false, 71 | }, 72 | readStream: getNextChunkStream(start, end) 73 | }, (err, result, response) => { 74 | if (err) { return console.log('sessionAppend error: ', err) } 75 | cb(); 76 | }); 77 | } 78 | 79 | function sessionFinish(sessionId) { 80 | dropbox({ 81 | resource: 'files/upload_session/finish', 82 | parameters: { 83 | cursor: { 84 | session_id: sessionId, 85 | offset: FILE_SIZE 86 | }, 87 | commit: { 88 | path: "/result.txt", 89 | mode: "add", 90 | autorename: true, 91 | mute: false 92 | } 93 | } 94 | }, (err, result, response) => { 95 | if (err) { return console.log('sessionFinish error: ', err) } 96 | console.log('sessionFinish result:', result); 97 | }); 98 | } -------------------------------------------------------------------------------- /test/files/files.js: -------------------------------------------------------------------------------- 1 | const should = require('should'); 2 | const spec = require('stream-spec'); 3 | 4 | const dropboxV2Api = require('../../src/dropbox-api-test.js'); 5 | const utils = require('../../src/utils.js'); 6 | const config = require('./../config.js'); 7 | 8 | let dropbox; 9 | 10 | const sleep = async ms => { 11 | return new Promise(resolve => { 12 | setTimeout(resolve, ms); 13 | }); 14 | }; 15 | 16 | describe('Namespace', function() { 17 | this.timeout(6000); 18 | before(function() { 19 | dropbox = dropboxV2Api.authenticate({ 20 | token: config.get('DROPBOX_TOKEN') 21 | }); 22 | }); 23 | beforeEach(async function(){ 24 | console.log('-------------------------'); 25 | }); 26 | describe('files', () => { 27 | const timestamp = (+new Date()); 28 | var dirName = `dropbox-api-test-${timestamp}`; 29 | var dirPath = `/${dirName}` 30 | 31 | it('create_folder', (done) => { 32 | dropbox({ 33 | resource: 'files/create_folder', 34 | parameters: { 35 | path: dirPath 36 | } 37 | }, (err, result) => { 38 | if(err){ throw err; } 39 | result.should.have.property('name', dirName); 40 | done(); 41 | }); 42 | }); 43 | it('get_metadata', (done) => { 44 | dropbox({ 45 | resource: 'files/get_metadata', 46 | parameters: { 47 | path: dirPath, 48 | include_media_info: false, 49 | include_deleted: false, 50 | include_has_explicit_shared_members: false 51 | } 52 | }, (err, result) => { 53 | if(err){ throw err; } 54 | result.should.have.property('.tag', 'folder'); 55 | result.should.have.property('path_lower', dirPath); 56 | 57 | done(); 58 | }); 59 | }); 60 | it('upload', (done) => { 61 | var filePath = `${dirPath}/alpha-üpload.txt`; 62 | dropbox({ 63 | resource: 'files/upload', 64 | parameters: { 65 | path: filePath 66 | }, 67 | readStream: utils.createMockedReadStream('1', 50) 68 | }, (err, result) => { 69 | if(err){ throw err; } 70 | result.should.have.property('path_lower', filePath); 71 | done(); 72 | }); 73 | }); 74 | it('upload', (done) => { 75 | var filePath = `${dirPath}/upload.txt`; 76 | dropbox({ 77 | resource: 'files/upload', 78 | parameters: { 79 | path: filePath 80 | }, 81 | readStream: utils.createMockedReadStream('2', 30) 82 | }, (err, result) => { 83 | if(err){ throw err; } 84 | result.should.have.property('path_lower', filePath); 85 | done(); 86 | }); 87 | }); 88 | it('list_folder', (done) => { 89 | dropbox({ 90 | resource: 'files/list_folder', 91 | parameters: { 92 | path: dirPath, 93 | "include_media_info": true, 94 | "include_has_explicit_shared_members": true, 95 | "include_non_downloadable_files": true 96 | } 97 | }, (err, result) => { 98 | if(err){ throw err; } 99 | result.entries[0].should.have.property('size', 50); 100 | result.entries[1].should.have.property('size', 30); 101 | done(); 102 | }); 103 | }); 104 | it('download', (done) => { 105 | var filePath = `${dirPath}/upload.txt`; 106 | var dropboxStream = dropbox({ 107 | resource: 'files/download', 108 | parameters: { 109 | path: filePath 110 | } 111 | }, (err, result) => { 112 | if(err){ throw err; } 113 | result.should.have.property('path_lower', filePath); 114 | done(); 115 | }); 116 | }); 117 | it('download -> upload combination', (done) => { 118 | var downloadFilePath = `${dirPath}/upload.txt`; 119 | var uploadFilePath = `${dirPath}/upload-2.txt`; 120 | 121 | const dlStream = dropbox({ 122 | resource: 'files/download', 123 | parameters: { 124 | path: downloadFilePath 125 | } 126 | }); 127 | 128 | const uploadSteram = dropbox({ 129 | resource: 'files/upload', 130 | parameters: { 131 | path: uploadFilePath 132 | } 133 | }, (err, result) => { 134 | result.should.have.property('size', 30); 135 | done(); 136 | }); 137 | 138 | dlStream.pipe(uploadSteram); 139 | }); 140 | it('copy', (done) => { 141 | const sourceFileName = `${dirPath}/upload-2.txt`; 142 | const targetFileName = `${dirPath}/upload-2-copied.txt`; 143 | dropbox({ 144 | resource: 'files/copy', 145 | parameters: { 146 | 'from_path': sourceFileName, 147 | 'to_path': targetFileName 148 | } 149 | }, (err, result) => { 150 | if(err){ throw err; } 151 | result.should.have.property('path_lower', targetFileName); 152 | done(); 153 | }); 154 | }); 155 | it('delete', (done) => { 156 | var fileToDeleteName = `${dirPath}/upload-2-copied.txt`; 157 | dropbox({ 158 | resource: 'files/delete', 159 | parameters: { 160 | 'path': fileToDeleteName 161 | } 162 | }, (err, result) => { 163 | if(err){ throw err; } 164 | result.should.have.property('path_lower', fileToDeleteName); 165 | done(); 166 | }); 167 | }); 168 | it('move', (done) => { 169 | var targetFileName = `${dirPath}/upload-moved.txt`; 170 | dropbox({ 171 | resource: 'files/copy', 172 | parameters: { 173 | 'from_path': `${dirPath}/upload.txt`, 174 | 'to_path': targetFileName 175 | } 176 | }, (err, result) => { 177 | if(err){ throw err; } 178 | result.should.have.property('path_lower', targetFileName); 179 | done(); 180 | }); 181 | }); 182 | }); 183 | }); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dropbox-v2-api 2 | 3 | [![Actions Status](https://github.com/adasq/dropbox-v2-api/workflows/Integration%20Tests/badge.svg)](https://github.com/adasq/dropbox-v2-api/actions) 4 | [![NPM Downloads](https://img.shields.io/npm/dm/dropbox-v2-api.svg?style=flat)](https://www.npmjs.org/package/dropbox-v2-api) 5 | [![NPM Downloads](https://img.shields.io/npm/dt/dropbox-v2-api.svg?style=flat)](https://www.npmjs.org/package/dropbox-v2-api) 6 | [![npm version](https://badge.fury.io/js/dropbox-v2-api.svg)](https://badge.fury.io/js/dropbox-v2-api) 7 | 8 | The API is generated programmatically, based on [endpoints description JSON][api.json] fetched from [official docs][docs]. 9 | 10 | [api.json]: 11 | ## Why this package? 12 | 13 | - Always **up-to-date API** (PRs with changes are generated automatically, [see most recent][change-detection-pr]) 14 | - Simple API (**no custom function names**, see [full API showcase](#full-api-showcase)) 15 | - Full support for **streams** (see [upload/download](#upload-and-download-examples) examples) 16 | - Supports Dropbox **Paper API** 17 | - **Examples** for all endpoints ([see more][examples]) 18 | 19 | 20 | ## Get started 21 | ```js 22 | $ npm i -s dropbox-v2-api 23 | ``` 24 | 25 | ```js 26 | const dropboxV2Api = require('dropbox-v2-api'); 27 | ``` 28 | 29 | ## Auth 30 | 31 | - using token 32 | 33 | ```js 34 | // create session ref: 35 | const dropbox = dropboxV2Api.authenticate({ 36 | token: 'your token' 37 | }); 38 | 39 | // use session ref to call API, i.e.: 40 | dropbox({ 41 | resource: 'users/get_account', 42 | parameters: { 43 | 'account_id': 'dbid:AAH4f99T0taONIb-OurWxbNQ6ywGRopQngc' 44 | } 45 | }, (err, result, response) => { 46 | if (err) { return console.log(err); } 47 | console.log(result); 48 | }); 49 | 50 | ``` 51 | - using oauth2 flow (see [example app][example-auth-flow]) 52 | ```js 53 | //set credentials 54 | const dropbox = dropboxV2Api.authenticate({ 55 | client_id: 'APP_KEY', 56 | client_secret: 'APP_SECRET', 57 | redirect_uri: 'REDIRECT_URI', 58 | token_access_type: 'offline', // if you need an offline long-living refresh token 59 | state: 'OPTIONAL_STATE_VALUE' 60 | }); 61 | //generate and visit authorization sevice 62 | const authUrl = dropbox.generateAuthUrl(); 63 | //after redirection, you should receive code 64 | dropbox.getToken(code, (err, result, response) => { 65 | // you are authorized now! 66 | // 67 | // ...then you can refresh your token! (flow for token_access_type='offline') 68 | dropbox.refreshToken(response.refresh_token, (err, result, response) => { 69 | //token is refreshed! 70 | }); 71 | }); 72 | // 73 | 74 | ``` 75 | 76 | ## Full API showcase 77 | 78 | ```js 79 | dropbox({ 80 | resource: (string), 81 | parameters: (object?), 82 | readStream: (readable stream object?) 83 | }, (err, result, response) => { 84 | if (err) { return console.log('err:', err); } 85 | console.log(result); 86 | console.log(response.headers); 87 | }); 88 | 89 | ``` 90 | - `resource` (*string*) represent API target. It contains Dropbox's namespace and method name. eg. `'users/get_account'`, `'users/get_space_usage'`, `'files/upload'`, `'files/list_folder/longpoll'`, `'sharing/share_folder'` [more at official documentation][docs] 91 | - `parameters` (*object?*) optional parameters, depends on `resource` field 92 | - `readStream` (*readable stream?*) Upload-type requests might contains `readStream` field, which is readable stream 93 | 94 | For Download-type requests, the function ```dropbox``` returns readable stream. 95 | 96 | ## Upload and Download examples 97 | 98 | #### upload [see docs][files-upload] 99 | 100 | Upload-type requests might contains `readStream` field, which is readable stream 101 | ```js 102 | dropbox({ 103 | resource: 'files/upload', 104 | parameters: { 105 | path: '/dropbox/path/to/file.js' 106 | }, 107 | readStream: fs.createReadStream('path/to/file.js') 108 | }, (err, result, response) => { 109 | //upload completed 110 | }); 111 | ``` 112 | or, using streams: 113 | 114 | ```js 115 | const dropboxUploadStream = dropbox({ 116 | resource: 'files/upload', 117 | parameters: { 118 | path: '/dropbox/path/to/file.js' 119 | } 120 | }, (err, result, response) => { 121 | //upload completed 122 | }); 123 | 124 | fs.createReadStream('path/to/file.js').pipe(dropboxUploadStream); 125 | ``` 126 | 127 | #### download [see docs][files-download] 128 | 129 | Download-type requests return `writableStream` 130 | ```js 131 | dropbox({ 132 | resource: 'files/download', 133 | parameters: { 134 | path: '/dropbox/image.jpg' 135 | } 136 | }, (err, result, response) => { 137 | //download completed 138 | }) 139 | .pipe(fs.createWriteStream('./image.jpg')); 140 | ``` 141 | 142 | Problems with downloading? More [here](#downloading-issues) 143 | 144 | #### download & upload 145 | 146 | You can easely use streams: 147 | ```js 148 | const downloadStream = dropbox({ 149 | resource: 'files/download', 150 | parameters: { path: '/source/file/path' } 151 | }); 152 | 153 | const uploadStream = dropbox({ 154 | resource: 'files/upload', 155 | parameters: { path: '/target/file/path' } 156 | }, (err, result, response) => { 157 | //upload finished 158 | }); 159 | 160 | downloadStream.pipe(uploadStream); 161 | ``` 162 | 163 | ## API call examples 164 | 165 | #### get_current_account [see docs][get_current_account] 166 | 167 | ```js 168 | dropbox({ 169 | resource: 'users/get_current_account' 170 | }, (err, result, response) => { 171 | if (err) { return console.log('err:', err); } 172 | console.log(result); 173 | }); 174 | ``` 175 | 176 | #### get_metadata [see docs][get_metadata] 177 | 178 | ```js 179 | dropbox({ 180 | resource: 'files/get_metadata', 181 | parameters: { 182 | path: '/dropbox/path/to/file.js', 183 | include_media_info: false 184 | } 185 | }, (err, result, response) => { 186 | if(err){ return console.log('err:', err); } 187 | console.log(result); 188 | }); 189 | ``` 190 | 191 | #### upload_session [see docs][session-upload] 192 | 193 | ```js 194 | const CHUNK_LENGTH = 100; 195 | //create read streams, which generates set of 100 (CHUNK_LENGTH) characters of values: 1 and 2 196 | const firstUploadChunkStream = () => utils.createMockedReadStream('1', CHUNK_LENGTH); 197 | const secondUploadChunkStream = () => utils.createMockedReadStream('2', CHUNK_LENGTH); 198 | 199 | sessionStart((sessionId) => { 200 | sessionAppend(sessionId, () => { 201 | sessionFinish(sessionId); 202 | }); 203 | }); 204 | 205 | function sessionStart(cb) { 206 | dropbox({ 207 | resource: 'files/upload_session/start', 208 | parameters: { 209 | close: false 210 | }, 211 | readStream: firstUploadChunkStream() 212 | }, (err, result, response) => { 213 | if (err) { return console.log('sessionStart error: ', err) } 214 | console.log('sessionStart result:', result); 215 | cb(result.session_id); 216 | }); 217 | } 218 | 219 | 220 | function sessionAppend(sessionId, cb) { 221 | dropbox({ 222 | resource: 'files/upload_session/append', 223 | parameters: { 224 | cursor: { 225 | session_id: sessionId, 226 | offset: CHUNK_LENGTH 227 | }, 228 | close: false, 229 | }, 230 | readStream: secondUploadChunkStream() 231 | }, (err, result, response) => { 232 | if(err){ return console.log('sessionAppend error: ', err) } 233 | console.log('sessionAppend result:', result); 234 | cb(); 235 | }); 236 | } 237 | 238 | function sessionFinish(sessionId) { 239 | dropbox({ 240 | resource: 'files/upload_session/finish', 241 | parameters: { 242 | cursor: { 243 | session_id: sessionId, 244 | offset: CHUNK_LENGTH * 2 245 | }, 246 | commit: { 247 | path: "/result.txt", 248 | mode: "add", 249 | autorename: true, 250 | mute: false 251 | } 252 | } 253 | }, (err, result, response) => { 254 | if (err) { return console.log('sessionFinish error: ', err) } 255 | console.log('sessionFinish result:', result); 256 | }); 257 | } 258 | ``` 259 | 260 | ### Downloading issues 261 | 262 | 1. `FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory` 263 | 264 | You can increase your default memory limit for an app: 265 | `$ NODE_OPTIONS=--max_old_space_size= 4096 node app.js` 266 | where `4096` stands for 4GB. 267 | 268 | #### check [test cases][tests] or [examples][examples] for more examples... 269 | 270 | [change-detection-pr]: 271 | [examples]: 272 | [tests]: 273 | [session-upload]: 274 | 275 | [files-upload]: 276 | 277 | [files-download]: 278 | 279 | [get_current_account]: 280 | [get_metadata]: 281 | 282 | [docs]: 283 | [example-auth-flow]: 284 | -------------------------------------------------------------------------------- /src/dropbox-api.js: -------------------------------------------------------------------------------- 1 | const request = require('request'); 2 | const stream = require('stream'); 3 | const {decompress} = require("compress-json"); 4 | const apiJSON = require('./api.json'); 5 | 6 | const RPC_RESOURCE_CATEGORY = 'rpc'; 7 | const UPLOAD_RESOURCE_CATEGORY = 'upload'; 8 | const DOWNLOAD_RESOURCE_CATEGORY = 'download'; 9 | 10 | const DB_HEADER_API_ARGS = 'Dropbox-API-Arg'; 11 | const DB_API_RESULT_HEADER_NAME = 'dropbox-api-result'; 12 | const OAUTH2_AUTHORIZE = 'https://www.dropbox.com/1/oauth2/authorize'; 13 | const OAUTH2_TOKEN = 'https://api.dropboxapi.com/1/oauth2/token'; 14 | 15 | // https://www.dropbox.com/developers/reference/json-encoding 16 | const charsToEncode = /[\u007f-\uffff]/g; 17 | 18 | // This function is simple and has OK performance compared to more 19 | // complicated ones: http://jsperf.com/json-escape-unicode/4 20 | function http_header_safe_json(v) { 21 | return JSON.stringify(v).replace(charsToEncode, 22 | function (c) { 23 | return '\\u' + ('000' + c.charCodeAt(0).toString(16)).slice(-4); 24 | } 25 | ); 26 | } 27 | 28 | const updateRequestOptsFnList = [ 29 | /* For requests, which requires auth header, set valid header */ 30 | (requestOpts, {auth}, userOpts, config) => { 31 | if (auth !== 'noauth') { 32 | if (!config.token) { 33 | throwError('No "token" specified!'); 34 | } 35 | requestOpts.headers['Authorization'] = `Bearer ${config.token}`; 36 | } 37 | }, 38 | /* If resource requires upload stream, provide valid header */ 39 | (requestOpts, {format}, userOpts) => { 40 | if (format === 'upload') { 41 | requestOpts.headers['Content-Type'] = 'application/octet-stream'; 42 | } 43 | }, 44 | /* Sets request parameter as request body (for RPC requests) or as header (for DOWNLOAD / UPLOAD requests) */ 45 | (requestOpts, resourceDescription, userOpts, config) => { 46 | const resourceCategory = resourceDescription.format; 47 | const userParameters = userOpts.parameters; 48 | 49 | if (resourceCategory === RPC_RESOURCE_CATEGORY) { 50 | //RPC, put it as body 51 | requestOpts.body = resourceDescription.request ? userParameters : null; 52 | } else { 53 | //if not RPC, then we have 2 options: download or upload type request 54 | requestOpts.headers[DB_HEADER_API_ARGS] = isObject(userParameters) ? http_header_safe_json(userParameters) : ''; 55 | } 56 | } 57 | ]; 58 | 59 | const resourcesDescriptionList = loadResourcesDescriptionList(); 60 | 61 | //------------------------------------------------------------------------------------ 62 | 63 | function generateResourcesHandlingFunctions(resourcesDescriptionList, config) { 64 | const resourcesHandlingFunctions = {}; 65 | Object.keys(resourcesDescriptionList).forEach((resourceName) => { 66 | const resourceDescription = resourcesDescriptionList[resourceName]; 67 | const resourceCategory = resourceDescription.format; 68 | 69 | resourcesHandlingFunctions[resourceName] = function (userOpts, userCb) { 70 | //create default request object 71 | const requestOpts = createDefaultRequestOptObject(resourceDescription); 72 | 73 | //prepare requestOpts based on userOpts, config, etc. 74 | updateRequestOptsFnList.forEach( 75 | (updateRequestOptsFn) => updateRequestOptsFn(requestOpts, resourceDescription, userOpts, config) 76 | ); 77 | 78 | const callback = userCb && prepareCallback(userCb); 79 | 80 | //send request 81 | if (resourceCategory === UPLOAD_RESOURCE_CATEGORY) { 82 | //it's upload type request, so pipe 83 | requestOpts.headers['Content-Type'] = 'application/octet-stream' 84 | if (userOpts.readStream) { 85 | // read stream specified, so pipe it 86 | return userOpts.readStream.pipe(request(requestOpts, callback)); 87 | } else { 88 | // readStream not specified, so return writable stream 89 | return request(requestOpts, callback); 90 | } 91 | } else if (resourceCategory === DOWNLOAD_RESOURCE_CATEGORY) { 92 | return request(requestOpts, callback).pipe(createTransformStream()); 93 | } else { 94 | //ordinary api call request 95 | return request(requestOpts, callback); 96 | } 97 | 98 | function prepareCallback(userCb) { 99 | return (err, response, body) => { 100 | if (err) { 101 | return userCb(err, null, response); 102 | } 103 | 104 | const responseContentType = response.headers['content-type']; 105 | const statusCode = response.statusCode; 106 | 107 | const handleResponseByContentType = { 108 | /* it's content-stream response type, so response object is located inside header */ 109 | 'application/octet-stream': () => { 110 | const dropboxApiResultContent = response.headers[DB_API_RESULT_HEADER_NAME]; 111 | return dropboxApiResultContent && userCb(null, JSON.parse(dropboxApiResultContent), response); 112 | }, 113 | /* it's ordinary RPC response, so result object is located inside body */ 114 | 'application/json': () => { 115 | const json = body; 116 | if (statusCode === 200) { 117 | return userCb(null, json, response); 118 | } else { 119 | json.code = statusCode; 120 | return userCb(json, null, response); 121 | } 122 | }, 123 | /* text type response */ 124 | 'text/plain; charset=utf-8': () => { 125 | const text = body; 126 | if (statusCode === 200) { 127 | return userCb(null, text, response); 128 | } else { 129 | return userCb({ 130 | code: statusCode, 131 | text: text 132 | }, null, response); 133 | } 134 | } 135 | }; 136 | 137 | const responseHandlerFn = handleResponseByContentType[responseContentType]; 138 | if (responseHandlerFn) { 139 | responseHandlerFn(); 140 | } else { 141 | userCb(err || {}); 142 | } 143 | } 144 | } 145 | }; 146 | }); 147 | return resourcesHandlingFunctions; 148 | } 149 | 150 | module.exports = { 151 | authenticate: function (config) { 152 | const resourceHandlingFunctions = generateResourcesHandlingFunctions(resourcesDescriptionList, config); 153 | const clientSession = function (userOpt, cb) { 154 | const opt = { 155 | parameters: userOpt.parameters || {}, 156 | resource: userOpt.resource || '', 157 | readStream: userOpt.readStream 158 | }; 159 | const resourceName = opt.resource; 160 | if (resourceHandlingFunctions[resourceName]) { 161 | return resourceHandlingFunctions[resourceName](opt, cb); 162 | } else { 163 | throwError(`resource "${opt.resource}" is invalid.`); 164 | } 165 | }; 166 | Object.assign(clientSession, { 167 | generateAuthUrl: (input) => { 168 | return `${OAUTH2_AUTHORIZE}?client_id=${config.client_id}&response_type=code${config.token_access_type ? `&token_access_type=${config.token_access_type}` : ''}&redirect_uri=${config.redirect_uri}${config.state ? `&state=${config.state}` : ''}`; 169 | }, 170 | getToken: (code, userCb) => { 171 | request({ 172 | method: 'POST', 173 | uri: OAUTH2_TOKEN, 174 | followRedirect: true, 175 | json: true, 176 | form: { 177 | code: code, 178 | client_id: config.client_id, 179 | client_secret: config.client_secret, 180 | grant_type: 'authorization_code', 181 | redirect_uri: config.redirect_uri 182 | } 183 | }, (err, resp, body) => { 184 | if (err || body.error) { 185 | userCb(body.error || {}); 186 | } 187 | config.token = body.access_token; 188 | userCb(false, body); 189 | }); 190 | }, 191 | refreshToken: (refreshToken, userCb) => { 192 | request({ 193 | method: 'POST', 194 | uri: OAUTH2_TOKEN, 195 | followRedirect: true, 196 | json: true, 197 | form: { 198 | refresh_token: refreshToken, 199 | client_id: config.client_id, 200 | client_secret: config.client_secret, 201 | grant_type: 'refresh_token' 202 | } 203 | }, (err, resp, body) => { 204 | if (err || body.error) { 205 | userCb(body.error || {}); 206 | } 207 | config.token = body.access_token; 208 | userCb(false, body); 209 | }); 210 | } 211 | }); 212 | return clientSession; 213 | } 214 | } 215 | 216 | function throwError(content) { 217 | throw content; 218 | } 219 | 220 | function createTransformStream() { 221 | const streamInstance = new stream.Transform(); 222 | streamInstance._transform = function (chunk, enc, done) { 223 | this.push(chunk); 224 | done(); 225 | }; 226 | return streamInstance; 227 | } 228 | 229 | function loadResourcesDescriptionList() { 230 | return decompress(apiJSON); 231 | } 232 | 233 | function createDefaultRequestOptObject(resourceDescription) { 234 | return { 235 | method: 'POST', 236 | uri: `https://${resourceDescription.subdomain}.dropboxapi.com/2/${resourceDescription.key}`, 237 | json: true, 238 | followRedirect: false, 239 | headers: {} 240 | } 241 | } 242 | 243 | function isObject(obj) { 244 | return (typeof obj) === 'object' && !!obj; 245 | } 246 | -------------------------------------------------------------------------------- /src/generate-api-description.js: -------------------------------------------------------------------------------- 1 | var cheerio = require('cheerio'); 2 | var request = require('request'); 3 | var fs = require('fs'); 4 | var async = require('async'); 5 | var _ = require('underscore'); 6 | const compressor = require('compress-json'); 7 | //------------------------------------------- 8 | 9 | var $, 10 | HEADER_AUTH = '--header \"Authorization: Bearer', 11 | HEADER_CT_OCTET_STREAM = '--header \"Content-Type: application/octet-stream', 12 | ENDPOINT_RPC = 'api.dropboxapi.com', 13 | ENDPOINT_CONTENT = 'content.dropboxapi.com', 14 | utils = { 15 | contains: function (text, sub) { 16 | return (text.indexOf(sub) > -1); 17 | }, 18 | hasClass: function (className, classText) { 19 | return classText.trim().split(' ').indexOf(className) > -1; 20 | }, 21 | getTextNode: function (arr) { 22 | var node = _.filter(arr, function (item) { 23 | return item.type === 'text'; 24 | }); 25 | return _.pluck(node, 'data').join(' ').trim(); 26 | } 27 | }; 28 | 29 | module.exports = generateApiDescription2 30 | 31 | async function generateApiDescription2(cb) { 32 | const NAMESPACES = ['account', 'auth', 'check', 'contacts', 'file_properties', 'file_requests', 'files', 'sharing', 'users'] 33 | let error = null; 34 | const apiExamples = {}; 35 | 36 | try { 37 | for (let i = 0; i < NAMESPACES.length; i++) { 38 | const namespace = NAMESPACES[i]; 39 | const endpoints = await fetchNamespace(namespace); 40 | endpoints.forEach(endpoint => { 41 | const key = `${namespace}/${endpoint.name}${endpoint.version === 1 ? '' : `_v${endpoint.version}`}`; 42 | apiExamples[key] = { 43 | key, 44 | ...endpoint 45 | } 46 | }) 47 | } 48 | } catch (err) { 49 | error = err; 50 | console.log(error) 51 | } 52 | 53 | 54 | if (cb) { 55 | cb(error, apiExamples); 56 | } else { 57 | // fs.writeFileSync('./dist/api.json', JSON.stringify(apiExamples, null, '\t')); 58 | fs.writeFileSync('./src/api.json', JSON.stringify(compressor.compress(apiExamples))); 59 | } 60 | 61 | } 62 | 63 | function fetchNamespace(NAMESPACE) { 64 | const CSFR = 'PlVbZNc_MK8fTovNsjHXdXGa'; 65 | return new Promise((resolve, reject) => { 66 | request({ 67 | method: 'POST', 68 | uri: 'https://www.dropbox.com/2/api_developers/get_namespace_routes', 69 | json: true, 70 | headers: { 71 | cookie: `t=${CSFR}`, 72 | 'x-csrf-token': CSFR 73 | }, 74 | body: ({ 75 | mode: "external", 76 | p_namespace: NAMESPACE 77 | }) 78 | }, function (err, resp, body) { 79 | if (err) return reject(err); 80 | body.route_groups = JSON.parse(body.route_groups); 81 | resolve(body.route_groups.map(a => a.routeVersions).flat()); 82 | }) 83 | }) 84 | } 85 | 86 | //------------------------------------------- 87 | 88 | function getAPIDescriptionElems() { 89 | var resp = $('.documentation__routes'); 90 | var namespaces = _.map(resp.children(), function (sectionChild) { 91 | var namespace = { 92 | name: sectionChild.attribs.id.replace(/\s/, ''), 93 | }; 94 | var methodDescWrapElems = _.map(sectionChild.children, function (child, i) { 95 | if (child.attribs && child.attribs.class && utils.hasClass('toc-el', child.attribs.class)) { 96 | return child; 97 | } 98 | }); 99 | namespace.el = _.compact(methodDescWrapElems); 100 | return namespace; 101 | }); 102 | return namespaces; 103 | } 104 | 105 | function getTextByElem(el) { 106 | el.find('br').replaceWith('\n'); 107 | const links = el.find('a'); 108 | let text = el.text(); 109 | if (links.length > 0) { 110 | _.each(links, (link, i) => { 111 | link = links.eq(i); 112 | const linkText = link.text(); 113 | const linkHref = link.attr('href').replace(/-/g, ''); 114 | if ('#' + linkText === linkHref || linkHref[0] !== '#') return; 115 | link.text(`[${linkText}](${linkHref}-see-docs)`); 116 | }); 117 | } 118 | text = el.text(); 119 | return text.replace(/\n/g, ' ').trim(); 120 | } 121 | 122 | function getTextByElem2(el) { 123 | return el.text().trim().replace(/\\s+/g, ' '); 124 | } 125 | 126 | function getExampleData(el) { 127 | return el.find('pre').text(); 128 | } 129 | 130 | function getReturns(el) { 131 | const parametersExample = el.find('.literal-block').eq(0).text(); 132 | let parametersExampleObject = null; 133 | if (parametersExample.length > 0) { 134 | parametersExampleObject = JSON.parse(parametersExample); 135 | } 136 | return parametersExampleObject; 137 | } 138 | 139 | function getParameterList(el) { 140 | 141 | const parametersExample = el.find('.literal-block').eq(0).text(); 142 | let parametersExampleObject = null; 143 | if (parametersExample.length > 0) { 144 | parametersExampleObject = JSON.parse(parametersExample); 145 | } 146 | 147 | return { 148 | list: getParameterListInner(el), 149 | example: parametersExampleObject 150 | }; 151 | 152 | function getParameterListInner(el) { 153 | return _.map(el.find('.field'), function (item) { 154 | var desc = utils.getTextNode(item.children); 155 | item = $(item); 156 | var nestedWrap = item.find('.nested-child'); 157 | if (!!nestedWrap.length) { 158 | const name = item.find('b code').eq(0).text(); 159 | return { 160 | name, 161 | type: item.find('.type').eq(0).text(), 162 | desc: desc, 163 | parameters: _.flatten(_.map(nestedWrap, function (item) { 164 | return getParameterList($(item)) 165 | })) 166 | }; 167 | } else { 168 | const name = item.find('b code').text(); 169 | return { 170 | name, 171 | type: item.find('.type').text(), 172 | desc: desc 173 | }; 174 | } 175 | 176 | }); 177 | } 178 | } 179 | 180 | function parseMethodElement(wrap) { 181 | var parsers = { 182 | 'Description': getTextByElem, 183 | 'URL Structure': getTextByElem2, 184 | 'Parameters': getParameterList, 185 | 'Returns': getReturns, 186 | 'Endpoint format': function (elem) { 187 | const endpointCategory = elem.text().trim().toLowerCase(); 188 | const categories = { 189 | 'rpc': 'RPC', 190 | 'content-upload': 'UPLOAD', 191 | 'content-download': 'DOWNLOAD' 192 | }; 193 | return categories[endpointCategory] || null; 194 | }, 195 | 'Example': getExampleData 196 | }; 197 | 198 | var h3 = wrap.find('h3'); 199 | var dl = wrap.find('dl'); 200 | 201 | var dts = $(dl).find('dt'); 202 | 203 | var apiMethod = { 204 | name: h3.text() 205 | }; 206 | _.each(dts, function (dt, i) { 207 | var name = $(dts[i]).text(); 208 | var valueEl = $(dt.nextSibling.nextSibling); 209 | if (parsers[name]) { 210 | var value = parsers[name](valueEl); 211 | apiMethod[name] = value 212 | } else { 213 | // console.log('no parser for', name); 214 | } 215 | }); 216 | return apiMethod; 217 | } 218 | 219 | function generateApiDescription(cb) { 220 | request('https://www.dropbox.com/developers/documentation/http/documentation', function (err, resp, body) { 221 | if (err) { 222 | console.log('could not retrive documentaion page...'); 223 | return cb ? cb(err) : err; 224 | } 225 | parseBody(body); 226 | }); 227 | 228 | function parseBody(body) { 229 | $ = cheerio.load(body); 230 | var fullApi = _.map(getAPIDescriptionElems(), function (section) { 231 | return { 232 | name: section.name, 233 | methods: _.map(section.el, function (el) { 234 | var methodDescription = parseMethodElement($(el)); 235 | return methodDescription; 236 | }) 237 | }; 238 | }); 239 | const fullApiObject = parseApiDescription(fullApi); 240 | const fullApiContent = JSON.stringify(fullApiObject, null, '\t'); 241 | 242 | const apiObject = createApiObject(fullApiObject); 243 | const apiContent = JSON.stringify(apiObject, null, '\t'); 244 | 245 | if (cb) { 246 | cb(null, fullApiContent); 247 | } else { 248 | fs.writeFileSync('./dist/api.json', apiContent); 249 | fs.writeFileSync('./dist/api-examples.json', fullApiContent); 250 | } 251 | 252 | console.log('api description has been generated...'); 253 | 254 | } 255 | } 256 | 257 | function createApiObject(fullApiObject) { 258 | Object.keys(fullApiObject).forEach((name => { 259 | const apiDescription = fullApiObject[name]; 260 | delete apiDescription.description; 261 | delete apiDescription.returnParameters; 262 | delete apiDescription.parameters.example; 263 | apiDescription.parameters.available = apiDescription.parameters.list.length > 0; 264 | delete apiDescription.parameters.list; 265 | 266 | })); 267 | return fullApiObject; 268 | } 269 | 270 | function parseApiDescription(apiDescription) { 271 | var parsedApiDescription = {}; 272 | _.each(apiDescription, function (namespace) { 273 | var namespaceName = namespace.name; 274 | _.each(namespace.methods, function (method) { 275 | 276 | var methodName = method.name.substr(1); 277 | var resourceName = [namespaceName, methodName].join('/'); 278 | 279 | var methodUri = method['URL Structure']; 280 | var methodExample = method['Example'] || null; 281 | var methodParameters = method['Parameters'] || []; 282 | var returnParameters = method['Returns'] || null; 283 | var endpointFormat = method['Endpoint format'] || null; 284 | var description = method['Description'] || null; 285 | 286 | var requiresAuthHeader = methodExample === null ? true : utils.contains(methodExample, HEADER_AUTH); 287 | var requiresReadableStream = methodExample === null ? false : utils.contains(methodExample, HEADER_CT_OCTET_STREAM); 288 | 289 | parsedApiDescription[resourceName] = { 290 | uri: methodUri, 291 | requiresAuthHeader: requiresAuthHeader, 292 | requiresReadableStream: requiresReadableStream, 293 | category: endpointFormat, 294 | description: description, 295 | parameters: methodParameters, 296 | returnParameters: returnParameters 297 | }; 298 | }); 299 | }); 300 | return parsedApiDescription; 301 | } 302 | -------------------------------------------------------------------------------- /EXAMPLES.md: -------------------------------------------------------------------------------- 1 | 2 | ### account/set_profile_photo ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#account-set_profile_photo)) 3 | Sets a user's profile photo. 4 | 5 | ```js 6 | dropbox({ 7 | resource: 'account/set_profile_photo', 8 | parameters: { 9 | 'photo': { 10 | '.tag': 'base64_data', 11 | 'base64_data': 'SW1hZ2UgZGF0YSBpbiBiYXNlNjQtZW5jb2RlZCBieXRlcy4gTm90IGEgdmFsaWQgZXhhbXBsZS4=' 12 | } 13 | } 14 | }, (err, result, response) => { 15 | //see docs for `result` parameters 16 | }); 17 | ``` 18 | 19 | 20 | ### auth/token/from_oauth1 ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#auth-token-from_oauth1)) 21 | Creates an OAuth 2.0 access token from the supplied OAuth 1.0 access token. 22 | 23 | ```js 24 | dropbox({ 25 | resource: 'auth/token/from_oauth1', 26 | parameters: { 27 | 'oauth1_token': 'qievr8hamyg6ndck', 28 | 'oauth1_token_secret': 'qomoftv0472git7' 29 | } 30 | }, (err, result, response) => { 31 | //see docs for `result` parameters 32 | }); 33 | ``` 34 | 35 | 36 | ### auth/token/revoke ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#auth-token-revoke)) 37 | Disables the access token used to authenticate the call. If there is a corresponding refresh token for the access token, this disables that refresh token, as well as any other access tokens for that refresh token. 38 | 39 | ```js 40 | dropbox({ 41 | resource: 'auth/token/revoke' 42 | }, (err, result, response) => { 43 | //see docs for `result` parameters 44 | }); 45 | ``` 46 | 47 | 48 | ### check/app ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#check-app)) 49 | This endpoint performs App Authentication, validating the supplied app key and secret, and returns the supplied string, to allow you to test your code and connection to the Dropbox API. It has no other effect. If you receive an HTTP 200 response with the supplied query, it indicates at least part of the Dropbox API infrastructure is working and that the app key and secret valid. 50 | 51 | ```js 52 | dropbox({ 53 | resource: 'check/app', 54 | parameters: { 55 | 'query': 'foo' 56 | } 57 | }, (err, result, response) => { 58 | //see docs for `result` parameters 59 | }); 60 | ``` 61 | 62 | 63 | ### check/user ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#check-user)) 64 | This endpoint performs User Authentication, validating the supplied access token, and returns the supplied string, to allow you to test your code and connection to the Dropbox API. It has no other effect. If you receive an HTTP 200 response with the supplied query, it indicates at least part of the Dropbox API infrastructure is working and that the access token is valid. 65 | 66 | ```js 67 | dropbox({ 68 | resource: 'check/user', 69 | parameters: { 70 | 'query': 'foo' 71 | } 72 | }, (err, result, response) => { 73 | //see docs for `result` parameters 74 | }); 75 | ``` 76 | 77 | 78 | ### contacts/delete_manual_contacts ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#contacts-delete_manual_contacts)) 79 | Removes all manually added contacts. You'll still keep contacts who are on your team or who you imported. New contacts will be added when you share. 80 | 81 | ```js 82 | dropbox({ 83 | resource: 'contacts/delete_manual_contacts' 84 | }, (err, result, response) => { 85 | //see docs for `result` parameters 86 | }); 87 | ``` 88 | 89 | 90 | ### contacts/delete_manual_contacts_batch ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#contacts-delete_manual_contacts_batch)) 91 | Removes manually added contacts from the given list. 92 | 93 | ```js 94 | dropbox({ 95 | resource: 'contacts/delete_manual_contacts_batch', 96 | parameters: { 97 | 'email_addresses': ['contactemailaddress1@domain.com', 'contactemailaddress2@domain.com'] 98 | } 99 | }, (err, result, response) => { 100 | //see docs for `result` parameters 101 | }); 102 | ``` 103 | 104 | 105 | ### file_properties/properties/add ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#file_properties-properties-add)) 106 | Add property groups to a Dropbox file. See :route:`templates/add_for_user` or :route:`templates/add_for_team` to create new templates. 107 | 108 | ```js 109 | dropbox({ 110 | resource: 'file_properties/properties/add', 111 | parameters: { 112 | 'path': '/my_awesome/word.docx', 113 | 'property_groups': [{ 114 | 'template_id': 'ptid:1a5n2i6d3OYEAAAAAAAAAYa', 115 | 'fields': [{ 116 | 'name': 'Security Policy', 117 | 'value': 'Confidential' 118 | }] 119 | }] 120 | } 121 | }, (err, result, response) => { 122 | //see docs for `result` parameters 123 | }); 124 | ``` 125 | 126 | 127 | ### file_properties/properties/overwrite ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#file_properties-properties-overwrite)) 128 | Overwrite property groups associated with a file. This endpoint should be used instead of :route:`properties/update` when property groups are being updated via a "snapshot" instead of via a "delta". In other words, this endpoint will delete all omitted fields from a property group, whereas :route:`properties/update` will only delete fields that are explicitly marked for deletion. 129 | 130 | ```js 131 | dropbox({ 132 | resource: 'file_properties/properties/overwrite', 133 | parameters: { 134 | 'path': '/my_awesome/word.docx', 135 | 'property_groups': [{ 136 | 'template_id': 'ptid:1a5n2i6d3OYEAAAAAAAAAYa', 137 | 'fields': [{ 138 | 'name': 'Security Policy', 139 | 'value': 'Confidential' 140 | }] 141 | }] 142 | } 143 | }, (err, result, response) => { 144 | //see docs for `result` parameters 145 | }); 146 | ``` 147 | 148 | 149 | ### file_properties/properties/remove ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#file_properties-properties-remove)) 150 | Permanently removes the specified property group from the file. To remove specific property field key value pairs, see :route:`properties/update`. To update a template, see :route:`templates/update_for_user` or :route:`templates/update_for_team`. To remove a template, see :route:`templates/remove_for_user` or :route:`templates/remove_for_team`. 151 | 152 | ```js 153 | dropbox({ 154 | resource: 'file_properties/properties/remove', 155 | parameters: { 156 | 'path': '/my_awesome/word.docx', 157 | 'property_template_ids': ['ptid:1a5n2i6d3OYEAAAAAAAAAYa'] 158 | } 159 | }, (err, result, response) => { 160 | //see docs for `result` parameters 161 | }); 162 | ``` 163 | 164 | 165 | ### file_properties/properties/search ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#file_properties-properties-search)) 166 | Search across property templates for particular property field values. 167 | 168 | ```js 169 | dropbox({ 170 | resource: 'file_properties/properties/search', 171 | parameters: { 172 | 'queries': [{ 173 | 'query': 'Confidential', 174 | 'mode': { 175 | '.tag': 'field_name', 176 | 'field_name': 'Security' 177 | }, 178 | 'logical_operator': 'or_operator' 179 | }], 180 | 'template_filter': 'filter_none' 181 | } 182 | }, (err, result, response) => { 183 | //see docs for `result` parameters 184 | }); 185 | ``` 186 | 187 | 188 | ### file_properties/properties/search/continue ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#file_properties-properties-search-continue)) 189 | Once a cursor has been retrieved from :route:`properties/search`, use this to paginate through all search results. 190 | 191 | ```js 192 | dropbox({ 193 | resource: 'file_properties/properties/search/continue', 194 | parameters: { 195 | 'cursor': 'ZtkX9_EHj3x7PMkVuFIhwKYXEpwpLwyxp9vMKomUhllil9q7eWiAu' 196 | } 197 | }, (err, result, response) => { 198 | //see docs for `result` parameters 199 | }); 200 | ``` 201 | 202 | 203 | ### file_properties/properties/update ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#file_properties-properties-update)) 204 | Add, update or remove properties associated with the supplied file and templates. This endpoint should be used instead of :route:`properties/overwrite` when property groups are being updated via a "delta" instead of via a "snapshot" . In other words, this endpoint will not delete any omitted fields from a property group, whereas :route:`properties/overwrite` will delete any fields that are omitted from a property group. 205 | 206 | ```js 207 | dropbox({ 208 | resource: 'file_properties/properties/update', 209 | parameters: { 210 | 'path': '/my_awesome/word.docx', 211 | 'update_property_groups': [{ 212 | 'template_id': 'ptid:1a5n2i6d3OYEAAAAAAAAAYa', 213 | 'add_or_update_fields': [{ 214 | 'name': 'Security Policy', 215 | 'value': 'Confidential' 216 | }], 217 | 'remove_fields': [] 218 | }] 219 | } 220 | }, (err, result, response) => { 221 | //see docs for `result` parameters 222 | }); 223 | ``` 224 | 225 | 226 | ### file_properties/templates/add_for_user ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#file_properties-templates-add_for_user)) 227 | Add a template associated with a user. See :route:`properties/add` to add properties to a file. This endpoint can't be called on a team member or admin's behalf. 228 | 229 | ```js 230 | dropbox({ 231 | resource: 'file_properties/templates/add_for_user', 232 | parameters: { 233 | 'name': 'Security', 234 | 'description': 'These properties describe how confidential this file or folder is.', 235 | 'fields': [{ 236 | 'name': 'Security Policy', 237 | 'description': 'This is the security policy of the file or folder described.\nPolicies can be Confidential, Public or Internal.', 238 | 'type': 'string' 239 | }] 240 | } 241 | }, (err, result, response) => { 242 | //see docs for `result` parameters 243 | }); 244 | ``` 245 | 246 | 247 | ### file_properties/templates/get_for_user ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#file_properties-templates-get_for_user)) 248 | Get the schema for a specified template. This endpoint can't be called on a team member or admin's behalf. 249 | 250 | ```js 251 | dropbox({ 252 | resource: 'file_properties/templates/get_for_user', 253 | parameters: { 254 | 'template_id': 'ptid:1a5n2i6d3OYEAAAAAAAAAYa' 255 | } 256 | }, (err, result, response) => { 257 | //see docs for `result` parameters 258 | }); 259 | ``` 260 | 261 | 262 | ### file_properties/templates/list_for_user ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#file_properties-templates-list_for_user)) 263 | Get the template identifiers for a team. To get the schema of each template use :route:`templates/get_for_user`. This endpoint can't be called on a team member or admin's behalf. 264 | 265 | ```js 266 | dropbox({ 267 | resource: 'file_properties/templates/list_for_user' 268 | }, (err, result, response) => { 269 | //see docs for `result` parameters 270 | }); 271 | ``` 272 | 273 | 274 | ### file_properties/templates/remove_for_user ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#file_properties-templates-remove_for_user)) 275 | Permanently removes the specified template created from :route:`templates/add_for_user`. All properties associated with the template will also be removed. This action cannot be undone. 276 | 277 | ```js 278 | dropbox({ 279 | resource: 'file_properties/templates/remove_for_user', 280 | parameters: { 281 | 'template_id': 'ptid:1a5n2i6d3OYEAAAAAAAAAYa' 282 | } 283 | }, (err, result, response) => { 284 | //see docs for `result` parameters 285 | }); 286 | ``` 287 | 288 | 289 | ### file_properties/templates/update_for_user ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#file_properties-templates-update_for_user)) 290 | Update a template associated with a user. This route can update the template name, the template description and add optional properties to templates. This endpoint can't be called on a team member or admin's behalf. 291 | 292 | ```js 293 | dropbox({ 294 | resource: 'file_properties/templates/update_for_user', 295 | parameters: { 296 | 'template_id': 'ptid:1a5n2i6d3OYEAAAAAAAAAYa', 297 | 'name': 'New Security Template Name', 298 | 'description': 'These properties will describe how confidential this file or folder is.', 299 | 'add_fields': [{ 300 | 'name': 'Security Policy', 301 | 'description': 'This is the security policy of the file or folder described.\nPolicies can be Confidential, Public or Internal.', 302 | 'type': 'string' 303 | }] 304 | } 305 | }, (err, result, response) => { 306 | //see docs for `result` parameters 307 | }); 308 | ``` 309 | 310 | 311 | ### file_requests/count ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#file_requests-count)) 312 | Returns the total number of file requests owned by this user. Includes both open and closed file requests. 313 | 314 | ```js 315 | dropbox({ 316 | resource: 'file_requests/count' 317 | }, (err, result, response) => { 318 | //see docs for `result` parameters 319 | }); 320 | ``` 321 | 322 | 323 | ### file_requests/create ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#file_requests-create)) 324 | Creates a file request for this user. 325 | 326 | ```js 327 | dropbox({ 328 | resource: 'file_requests/create', 329 | parameters: { 330 | 'title': 'Homework submission', 331 | 'destination': '/File Requests/Homework', 332 | 'deadline': { 333 | 'deadline': '2020-10-12T17:00:00Z', 334 | 'allow_late_uploads': 'seven_days' 335 | }, 336 | 'open': true 337 | } 338 | }, (err, result, response) => { 339 | //see docs for `result` parameters 340 | }); 341 | ``` 342 | 343 | 344 | ### file_requests/delete ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#file_requests-delete)) 345 | Delete a batch of closed file requests. 346 | 347 | ```js 348 | dropbox({ 349 | resource: 'file_requests/delete', 350 | parameters: { 351 | 'ids': ['oaCAVmEyrqYnkZX9955Y', 'BaZmehYoXMPtaRmfTbSG'] 352 | } 353 | }, (err, result, response) => { 354 | //see docs for `result` parameters 355 | }); 356 | ``` 357 | 358 | 359 | ### file_requests/delete_all_closed ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#file_requests-delete_all_closed)) 360 | Delete all closed file requests owned by this user. 361 | 362 | ```js 363 | dropbox({ 364 | resource: 'file_requests/delete_all_closed' 365 | }, (err, result, response) => { 366 | //see docs for `result` parameters 367 | }); 368 | ``` 369 | 370 | 371 | ### file_requests/get ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#file_requests-get)) 372 | Returns the specified file request. 373 | 374 | ```js 375 | dropbox({ 376 | resource: 'file_requests/get', 377 | parameters: { 378 | 'id': 'oaCAVmEyrqYnkZX9955Y' 379 | } 380 | }, (err, result, response) => { 381 | //see docs for `result` parameters 382 | }); 383 | ``` 384 | 385 | 386 | ### file_requests/list ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#file_requests-list)) 387 | Returns a list of file requests owned by this user. For apps with the app folder permission, this will only return file requests with destinations in the app folder. 388 | 389 | ```js 390 | dropbox({ 391 | resource: 'file_requests/list' 392 | }, (err, result, response) => { 393 | //see docs for `result` parameters 394 | }); 395 | ``` 396 | 397 | 398 | ### file_requests/list_v2 ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#file_requests-list_v2)) 399 | Returns a list of file requests owned by this user. For apps with the app folder permission, this will only return file requests with destinations in the app folder. 400 | 401 | ```js 402 | dropbox({ 403 | resource: 'file_requests/list_v2', 404 | parameters: { 405 | 'limit': 1000 406 | } 407 | }, (err, result, response) => { 408 | //see docs for `result` parameters 409 | }); 410 | ``` 411 | 412 | 413 | ### file_requests/list/continue ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#file_requests-list-continue)) 414 | Once a cursor has been retrieved from :route:`list:2`, use this to paginate through all file requests. The cursor must come from a previous call to :route:`list:2` or :route:`list/continue`. 415 | 416 | ```js 417 | dropbox({ 418 | resource: 'file_requests/list/continue', 419 | parameters: { 420 | 'cursor': 'ZtkX9_EHj3x7PMkVuFIhwKYXEpwpLwyxp9vMKomUhllil9q7eWiAu' 421 | } 422 | }, (err, result, response) => { 423 | //see docs for `result` parameters 424 | }); 425 | ``` 426 | 427 | 428 | ### file_requests/update ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#file_requests-update)) 429 | Update a file request. 430 | 431 | ```js 432 | dropbox({ 433 | resource: 'file_requests/update', 434 | parameters: { 435 | 'id': 'oaCAVmEyrqYnkZX9955Y', 436 | 'title': 'Homework submission', 437 | 'destination': '/File Requests/Homework', 438 | 'deadline': { 439 | '.tag': 'update', 440 | 'deadline': '2020-10-12T17:00:00Z', 441 | 'allow_late_uploads': 'seven_days' 442 | }, 443 | 'open': true 444 | } 445 | }, (err, result, response) => { 446 | //see docs for `result` parameters 447 | }); 448 | ``` 449 | 450 | 451 | ### files/copy ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-copy)) 452 | Copy a file or folder to a different location in the user's Dropbox. 453 | If the source path is a folder all its contents will be copied. 454 | 455 | ```js 456 | dropbox({ 457 | resource: 'files/copy', 458 | parameters: { 459 | 'from_path': '/Homework/math', 460 | 'to_path': '/Homework/algebra', 461 | 'allow_shared_folder': false, 462 | 'autorename': false, 463 | 'allow_ownership_transfer': false 464 | } 465 | }, (err, result, response) => { 466 | //see docs for `result` parameters 467 | }); 468 | ``` 469 | 470 | 471 | ### files/copy_v2 ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-copy_v2)) 472 | Copy a file or folder to a different location in the user's Dropbox. 473 | If the source path is a folder all its contents will be copied. 474 | 475 | ```js 476 | dropbox({ 477 | resource: 'files/copy_v2', 478 | parameters: { 479 | 'from_path': '/Homework/math', 480 | 'to_path': '/Homework/algebra', 481 | 'allow_shared_folder': false, 482 | 'autorename': false, 483 | 'allow_ownership_transfer': false 484 | } 485 | }, (err, result, response) => { 486 | //see docs for `result` parameters 487 | }); 488 | ``` 489 | 490 | 491 | ### files/copy_batch ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-copy_batch)) 492 | Copy multiple files or folders to different locations at once in the user's Dropbox. 493 | This route will return job ID immediately and do the async copy job in background. Please use :route:`copy_batch/check:1` to check the job status. 494 | 495 | ```js 496 | dropbox({ 497 | resource: 'files/copy_batch', 498 | parameters: { 499 | 'entries': [{ 500 | 'from_path': '/Homework/math', 501 | 'to_path': '/Homework/algebra' 502 | }], 503 | 'autorename': false, 504 | 'allow_shared_folder': false, 505 | 'allow_ownership_transfer': false 506 | } 507 | }, (err, result, response) => { 508 | //see docs for `result` parameters 509 | }); 510 | ``` 511 | 512 | 513 | ### files/copy_batch_v2 ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-copy_batch_v2)) 514 | Copy multiple files or folders to different locations at once in the user's Dropbox. 515 | This route will replace :route:`copy_batch:1`. The main difference is this route will return status for each entry, while :route:`copy_batch:1` raises failure if any entry fails. 516 | This route will either finish synchronously, or return a job ID and do the async copy job in background. Please use :route:`copy_batch/check:2` to check the job status. 517 | 518 | ```js 519 | dropbox({ 520 | resource: 'files/copy_batch_v2', 521 | parameters: { 522 | 'entries': [{ 523 | 'from_path': '/Homework/math', 524 | 'to_path': '/Homework/algebra' 525 | }], 526 | 'autorename': false 527 | } 528 | }, (err, result, response) => { 529 | //see docs for `result` parameters 530 | }); 531 | ``` 532 | 533 | 534 | ### files/copy_batch/check ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-copy_batch-check)) 535 | Returns the status of an asynchronous job for :route:`copy_batch:1`. If success, it returns list of results for each entry. 536 | 537 | ```js 538 | dropbox({ 539 | resource: 'files/copy_batch/check', 540 | parameters: { 541 | 'async_job_id': '34g93hh34h04y384084' 542 | } 543 | }, (err, result, response) => { 544 | //see docs for `result` parameters 545 | }); 546 | ``` 547 | 548 | 549 | ### files/copy_batch/check_v2 ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-copy_batch-check_v2)) 550 | Returns the status of an asynchronous job for :route:`copy_batch:2`. It returns list of results for each entry. 551 | 552 | ```js 553 | dropbox({ 554 | resource: 'files/copy_batch/check_v2', 555 | parameters: { 556 | 'async_job_id': '34g93hh34h04y384084' 557 | } 558 | }, (err, result, response) => { 559 | //see docs for `result` parameters 560 | }); 561 | ``` 562 | 563 | 564 | ### files/copy_reference/get ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-copy_reference-get)) 565 | Get a copy reference to a file or folder. This reference string can be used to save that file or folder to another user's Dropbox by passing it to :route:`copy_reference/save`. 566 | 567 | ```js 568 | dropbox({ 569 | resource: 'files/copy_reference/get', 570 | parameters: { 571 | 'path': '/video.mp4' 572 | } 573 | }, (err, result, response) => { 574 | //see docs for `result` parameters 575 | }); 576 | ``` 577 | 578 | 579 | ### files/copy_reference/save ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-copy_reference-save)) 580 | Save a copy reference returned by :route:`copy_reference/get` to the user's Dropbox. 581 | 582 | ```js 583 | dropbox({ 584 | resource: 'files/copy_reference/save', 585 | parameters: { 586 | 'copy_reference': 'z1X6ATl6aWtzOGq0c3g5Ng', 587 | 'path': '/video.mp4' 588 | } 589 | }, (err, result, response) => { 590 | //see docs for `result` parameters 591 | }); 592 | ``` 593 | 594 | 595 | ### files/create_folder ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-create_folder)) 596 | Create a folder at a given path. 597 | 598 | ```js 599 | dropbox({ 600 | resource: 'files/create_folder', 601 | parameters: { 602 | 'path': '/Homework/math', 603 | 'autorename': false 604 | } 605 | }, (err, result, response) => { 606 | //see docs for `result` parameters 607 | }); 608 | ``` 609 | 610 | 611 | ### files/create_folder_v2 ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-create_folder_v2)) 612 | Create a folder at a given path. 613 | 614 | ```js 615 | dropbox({ 616 | resource: 'files/create_folder_v2', 617 | parameters: { 618 | 'path': '/Homework/math', 619 | 'autorename': false 620 | } 621 | }, (err, result, response) => { 622 | //see docs for `result` parameters 623 | }); 624 | ``` 625 | 626 | 627 | ### files/create_folder_batch ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-create_folder_batch)) 628 | Create multiple folders at once. 629 | This route is asynchronous for large batches, which returns a job ID immediately and runs the create folder batch asynchronously. Otherwise, creates the folders and returns the result synchronously for smaller inputs. You can force asynchronous behaviour by using the :field:`CreateFolderBatchArg.force_async` flag. Use :route:`create_folder_batch/check` to check the job status. 630 | 631 | ```js 632 | dropbox({ 633 | resource: 'files/create_folder_batch', 634 | parameters: { 635 | 'paths': ['/Homework/math'], 636 | 'autorename': false, 637 | 'force_async': false 638 | } 639 | }, (err, result, response) => { 640 | //see docs for `result` parameters 641 | }); 642 | ``` 643 | 644 | 645 | ### files/create_folder_batch/check ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-create_folder_batch-check)) 646 | Returns the status of an asynchronous job for :route:`create_folder_batch`. If success, it returns list of result for each entry. 647 | 648 | ```js 649 | dropbox({ 650 | resource: 'files/create_folder_batch/check', 651 | parameters: { 652 | 'async_job_id': '34g93hh34h04y384084' 653 | } 654 | }, (err, result, response) => { 655 | //see docs for `result` parameters 656 | }); 657 | ``` 658 | 659 | 660 | ### files/delete ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-delete)) 661 | Delete the file or folder at a given path. 662 | If the path is a folder, all its contents will be deleted too. 663 | A successful response indicates that the file or folder was deleted. The returned metadata will be the corresponding :type:`FileMetadata` or :type:`FolderMetadata` for the item at time of deletion, and not a :type:`DeletedMetadata` object. 664 | 665 | ```js 666 | dropbox({ 667 | resource: 'files/delete', 668 | parameters: { 669 | 'path': '/Homework/math/Prime_Numbers.txt' 670 | } 671 | }, (err, result, response) => { 672 | //see docs for `result` parameters 673 | }); 674 | ``` 675 | 676 | 677 | ### files/delete_v2 ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-delete_v2)) 678 | Delete the file or folder at a given path. 679 | If the path is a folder, all its contents will be deleted too. 680 | A successful response indicates that the file or folder was deleted. The returned metadata will be the corresponding :type:`FileMetadata` or :type:`FolderMetadata` for the item at time of deletion, and not a :type:`DeletedMetadata` object. 681 | 682 | ```js 683 | dropbox({ 684 | resource: 'files/delete_v2', 685 | parameters: { 686 | 'path': '/Homework/math/Prime_Numbers.txt' 687 | } 688 | }, (err, result, response) => { 689 | //see docs for `result` parameters 690 | }); 691 | ``` 692 | 693 | 694 | ### files/delete_batch ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-delete_batch)) 695 | Delete multiple files/folders at once. 696 | This route is asynchronous, which returns a job ID immediately and runs the delete batch asynchronously. Use :route:`delete_batch/check` to check the job status. 697 | 698 | ```js 699 | dropbox({ 700 | resource: 'files/delete_batch', 701 | parameters: { 702 | 'entries': [{ 703 | 'path': '/Homework/math/Prime_Numbers.txt' 704 | }] 705 | } 706 | }, (err, result, response) => { 707 | //see docs for `result` parameters 708 | }); 709 | ``` 710 | 711 | 712 | ### files/delete_batch/check ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-delete_batch-check)) 713 | Returns the status of an asynchronous job for :route:`delete_batch`. If success, it returns list of result for each entry. 714 | 715 | ```js 716 | dropbox({ 717 | resource: 'files/delete_batch/check', 718 | parameters: { 719 | 'async_job_id': '34g93hh34h04y384084' 720 | } 721 | }, (err, result, response) => { 722 | //see docs for `result` parameters 723 | }); 724 | ``` 725 | 726 | 727 | ### files/download ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-download)) 728 | Download a file from a user's Dropbox. 729 | 730 | ```js 731 | const stream = dropbox({ 732 | resource: 'files/download', 733 | parameters: { 734 | 'path': '/Homework/math/Prime_Numbers.txt' 735 | } 736 | }, (err, result, response) => { 737 | //see docs for `result` parameters 738 | }); 739 | 740 | stream 741 | .pipe(fs.createWriteStream('/Homework/math/Prime_Numbers.txt')); //pipe the stream 742 | ``` 743 | 744 | 745 | ### files/download_zip ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-download_zip)) 746 | Download a folder from the user's Dropbox, as a zip file. The folder must be less than 20 GB in size and any single file within must be less than 4 GB in size. The resulting zip must have fewer than 10,000 total file and folder entries, including the top level folder. The input cannot be a single file. 747 | Note: this endpoint does not support HTTP range requests. 748 | 749 | ```js 750 | const stream = dropbox({ 751 | resource: 'files/download_zip', 752 | parameters: { 753 | 'path': '/Homework/math' 754 | } 755 | }, (err, result, response) => { 756 | //see docs for `result` parameters 757 | }); 758 | 759 | stream 760 | .pipe(fs.createWriteStream('/Homework/math')); //pipe the stream 761 | ``` 762 | 763 | 764 | ### files/export ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-export)) 765 | Export a file from a user's Dropbox. This route only supports exporting files that cannot be downloaded directly and whose :field:`ExportResult.file_metadata` has :field:`ExportInfo.export_as` populated. 766 | 767 | ```js 768 | const stream = dropbox({ 769 | resource: 'files/export', 770 | parameters: { 771 | 'path': '/Homework/math/Prime_Numbers.gsheet' 772 | } 773 | }, (err, result, response) => { 774 | //see docs for `result` parameters 775 | }); 776 | 777 | stream 778 | .pipe(fs.createWriteStream('/Homework/math/Prime_Numbers.gsheet')); //pipe the stream 779 | ``` 780 | 781 | 782 | ### files/get_file_lock_batch ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-get_file_lock_batch)) 783 | Return the lock metadata for the given list of paths. 784 | 785 | ```js 786 | dropbox({ 787 | resource: 'files/get_file_lock_batch', 788 | parameters: { 789 | 'entries': [{ 790 | 'path': '/John Doe/sample/test.pdf' 791 | }] 792 | } 793 | }, (err, result, response) => { 794 | //see docs for `result` parameters 795 | }); 796 | ``` 797 | 798 | 799 | ### files/get_metadata ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-get_metadata)) 800 | Returns the metadata for a file or folder. 801 | Note: Metadata for the root folder is unsupported. 802 | 803 | ```js 804 | dropbox({ 805 | resource: 'files/get_metadata', 806 | parameters: { 807 | 'path': '/Homework/math', 808 | 'include_media_info': false, 809 | 'include_deleted': false, 810 | 'include_has_explicit_shared_members': false 811 | } 812 | }, (err, result, response) => { 813 | //see docs for `result` parameters 814 | }); 815 | ``` 816 | 817 | 818 | ### files/get_preview ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-get_preview)) 819 | Get a preview for a file. 820 | Currently, PDF previews are generated for files with the following extensions: .ai, .doc, .docm, .docx, .eps, .gdoc, .gslides, .odp, .odt, .pps, .ppsm, .ppsx, .ppt, .pptm, .pptx, .rtf. 821 | HTML previews are generated for files with the following extensions: .csv, .ods, .xls, .xlsm, .gsheet, .xlsx. 822 | Other formats will return an unsupported extension error. 823 | 824 | ```js 825 | const stream = dropbox({ 826 | resource: 'files/get_preview', 827 | parameters: { 828 | 'path': '/word.docx' 829 | } 830 | }, (err, result, response) => { 831 | //see docs for `result` parameters 832 | }); 833 | 834 | stream 835 | .pipe(fs.createWriteStream('/word.docx')); //pipe the stream 836 | ``` 837 | 838 | 839 | ### files/get_temporary_link ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-get_temporary_link)) 840 | Get a temporary link to stream content of a file. This link will expire in four hours and afterwards you will get 410 Gone. This URL should not be used to display content directly in the browser. The Content-Type of the link is determined automatically by the file's mime type. 841 | 842 | ```js 843 | dropbox({ 844 | resource: 'files/get_temporary_link', 845 | parameters: { 846 | 'path': '/video.mp4' 847 | } 848 | }, (err, result, response) => { 849 | //see docs for `result` parameters 850 | }); 851 | ``` 852 | 853 | 854 | ### files/get_temporary_upload_link ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-get_temporary_upload_link)) 855 | Get a one-time use temporary upload link to upload a file to a Dropbox location. 856 | 857 | This endpoint acts as a delayed :route:`upload`. The returned temporary upload link may be used to make a POST request with the data to be uploaded. The upload will then be perfomed with the :type:`CommitInfo` previously provided to :route:`get_temporary_upload_link` but evaluated only upon consumption. Hence, errors stemming from invalid :type:`CommitInfo` with respect to the state of the user's Dropbox will only be communicated at consumption time. Additionally, these errors are surfaced as generic HTTP 409 Conflict responses, potentially hiding issue details. The maximum temporary upload link duration is 4 hours. Upon consumption or expiration, a new link will have to be generated. Multiple links may exist for a specific upload path at any given time. 858 | 859 | The POST request on the temporary upload link must have its Content-Type set to "application/octet-stream". 860 | 861 | Example temporary upload link consumption request: 862 | 863 | curl -X POST https://content.dropboxapi.com/apitul/1/bNi2uIYF51cVBND 864 | --header "Content-Type: application/octet-stream" 865 | --data-binary @local_file.txt 866 | 867 | A successful temporary upload link consumption request returns the content hash of the uploaded data in JSON format. 868 | 869 | Example successful temporary upload link consumption response: 870 | {"content-hash": "599d71033d700ac892a0e48fa61b125d2f5994"} 871 | 872 | An unsuccessful temporary upload link consumption request returns any of the following status codes: 873 | 874 | HTTP 400 Bad Request: Content-Type is not one of application/octet-stream and text/plain or request is invalid. 875 | HTTP 409 Conflict: The temporary upload link does not exist or is currently unavailable, the upload failed, or another error happened. 876 | HTTP 410 Gone: The temporary upload link is expired or consumed. 877 | 878 | Example unsuccessful temporary upload link consumption response: 879 | Temporary upload link has been recently consumed. 880 | 881 | ```js 882 | dropbox({ 883 | resource: 'files/get_temporary_upload_link', 884 | parameters: { 885 | 'commit_info': { 886 | 'path': '/Homework/math/Matrices.txt', 887 | 'mode': 'add', 888 | 'autorename': true, 889 | 'mute': false, 890 | 'strict_conflict': false 891 | }, 892 | 'duration': 3600 893 | } 894 | }, (err, result, response) => { 895 | //see docs for `result` parameters 896 | }); 897 | ``` 898 | 899 | 900 | ### files/get_thumbnail ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-get_thumbnail)) 901 | Get a thumbnail for an image. 902 | This method currently supports files with the following file extensions: jpg, jpeg, png, tiff, tif, gif, webp, ppm and bmp. Photos that are larger than 20MB in size won't be converted to a thumbnail. 903 | 904 | ```js 905 | const stream = dropbox({ 906 | resource: 'files/get_thumbnail', 907 | parameters: { 908 | 'path': '/image.jpg', 909 | 'format': 'jpeg', 910 | 'size': 'w64h64', 911 | 'mode': 'strict' 912 | } 913 | }, (err, result, response) => { 914 | //see docs for `result` parameters 915 | }); 916 | 917 | stream 918 | .pipe(fs.createWriteStream('/image.jpg')); //pipe the stream 919 | ``` 920 | 921 | 922 | ### files/get_thumbnail_v2 ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-get_thumbnail_v2)) 923 | Get a thumbnail for an image. 924 | This method currently supports files with the following file extensions: jpg, jpeg, png, tiff, tif, gif, webp, ppm and bmp. Photos that are larger than 20MB in size won't be converted to a thumbnail. 925 | 926 | ```js 927 | const stream = dropbox({ 928 | resource: 'files/get_thumbnail_v2', 929 | parameters: { 930 | 'resource': { 931 | '.tag': 'path', 932 | 'path': '/a.docx' 933 | }, 934 | 'format': 'jpeg', 935 | 'size': 'w64h64', 936 | 'mode': 'strict' 937 | } 938 | }, (err, result, response) => { 939 | //see docs for `result` parameters 940 | }); 941 | 942 | stream 943 | .pipe(fs.createWriteStream()); //pipe the stream 944 | ``` 945 | 946 | 947 | ### files/get_thumbnail_batch ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-get_thumbnail_batch)) 948 | Get thumbnails for a list of images. We allow up to 25 thumbnails in a single batch. 949 | This method currently supports files with the following file extensions: jpg, jpeg, png, tiff, tif, gif, webp, ppm and bmp. Photos that are larger than 20MB in size won't be converted to a thumbnail. 950 | 951 | ```js 952 | dropbox({ 953 | resource: 'files/get_thumbnail_batch', 954 | parameters: { 955 | 'entries': [{ 956 | 'path': '/image.jpg', 957 | 'format': 'jpeg', 958 | 'size': 'w64h64', 959 | 'mode': 'strict' 960 | }] 961 | } 962 | }, (err, result, response) => { 963 | //see docs for `result` parameters 964 | }); 965 | ``` 966 | 967 | 968 | ### files/list_folder ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder)) 969 | Starts returning the contents of a folder. If the result's :field:`ListFolderResult.has_more` field is :val:`true`, call :route:`list_folder/continue` with the returned :field:`ListFolderResult.cursor` to retrieve more entries. 970 | If you're using :field:`ListFolderArg.recursive` set to :val:`true` to keep a local cache of the contents of a Dropbox account, iterate through each entry in order and process them as follows to keep your local state in sync: 971 | For each :type:`FileMetadata`, store the new entry at the given path in your local state. If the required parent folders don't exist yet, create them. If there's already something else at the given path, replace it and remove all its children. 972 | For each :type:`FolderMetadata`, store the new entry at the given path in your local state. If the required parent folders don't exist yet, create them. If there's already something else at the given path, replace it but leave the children as they are. Check the new entry's :field:`FolderSharingInfo.read_only` and set all its children's read-only statuses to match. 973 | For each :type:`DeletedMetadata`, if your local state has something at the given path, remove it and all its children. If there's nothing at the given path, ignore this entry. 974 | Note: :type:`auth.RateLimitError` may be returned if multiple :route:`list_folder` or :route:`list_folder/continue` calls with same parameters are made simultaneously by same API app for same user. If your app implements retry logic, please hold off the retry until the previous request finishes. 975 | 976 | ```js 977 | dropbox({ 978 | resource: 'files/list_folder', 979 | parameters: { 980 | 'path': '/Homework/math', 981 | 'recursive': false, 982 | 'include_media_info': false, 983 | 'include_deleted': false, 984 | 'include_has_explicit_shared_members': false, 985 | 'include_mounted_folders': true, 986 | 'include_non_downloadable_files': true 987 | } 988 | }, (err, result, response) => { 989 | //see docs for `result` parameters 990 | }); 991 | ``` 992 | 993 | 994 | ### files/list_folder/continue ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder-continue)) 995 | Once a cursor has been retrieved from :route:`list_folder`, use this to paginate through all files and retrieve updates to the folder, following the same rules as documented for :route:`list_folder`. 996 | 997 | ```js 998 | dropbox({ 999 | resource: 'files/list_folder/continue', 1000 | parameters: { 1001 | 'cursor': 'ZtkX9_EHj3x7PMkVuFIhwKYXEpwpLwyxp9vMKomUhllil9q7eWiAu' 1002 | } 1003 | }, (err, result, response) => { 1004 | //see docs for `result` parameters 1005 | }); 1006 | ``` 1007 | 1008 | 1009 | ### files/list_folder/get_latest_cursor ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder-get_latest_cursor)) 1010 | A way to quickly get a cursor for the folder's state. Unlike :route:`list_folder`, :route:`list_folder/get_latest_cursor` doesn't return any entries. This endpoint is for app which only needs to know about new files and modifications and doesn't need to know about files that already exist in Dropbox. 1011 | 1012 | ```js 1013 | dropbox({ 1014 | resource: 'files/list_folder/get_latest_cursor', 1015 | parameters: { 1016 | 'path': '/Homework/math', 1017 | 'recursive': false, 1018 | 'include_media_info': false, 1019 | 'include_deleted': false, 1020 | 'include_has_explicit_shared_members': false, 1021 | 'include_mounted_folders': true, 1022 | 'include_non_downloadable_files': true 1023 | } 1024 | }, (err, result, response) => { 1025 | //see docs for `result` parameters 1026 | }); 1027 | ``` 1028 | 1029 | 1030 | ### files/list_folder/longpoll ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder-longpoll)) 1031 | A longpoll endpoint to wait for changes on an account. In conjunction with :route:`list_folder/continue`, this call gives you a low-latency way to monitor an account for file changes. The connection will block until there are changes available or a timeout occurs. This endpoint is useful mostly for client-side apps. If you're looking for server-side notifications, check out our :link:`webhooks documentation https://www.dropbox.com/developers/reference/webhooks`. 1032 | 1033 | ```js 1034 | dropbox({ 1035 | resource: 'files/list_folder/longpoll', 1036 | parameters: { 1037 | 'cursor': 'ZtkX9_EHj3x7PMkVuFIhwKYXEpwpLwyxp9vMKomUhllil9q7eWiAu', 1038 | 'timeout': 30 1039 | } 1040 | }, (err, result, response) => { 1041 | //see docs for `result` parameters 1042 | }); 1043 | ``` 1044 | 1045 | 1046 | ### files/list_revisions ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-list_revisions)) 1047 | Returns revisions for files based on a file path or a file id. The file path or file id is identified from the latest file entry at the given file path or id. This end point allows your app to query either by file path or file id by setting the mode parameter appropriately. 1048 | In the :field:`ListRevisionsMode.path` (default) mode, all revisions at the same file path as the latest file entry are returned. If revisions with the same file id are desired, then mode must be set to :field:`ListRevisionsMode.id`. The :field:`ListRevisionsMode.id` mode is useful to retrieve revisions for a given file across moves or renames. 1049 | 1050 | ```js 1051 | dropbox({ 1052 | resource: 'files/list_revisions', 1053 | parameters: { 1054 | 'path': '/root/word.docx', 1055 | 'mode': 'path', 1056 | 'limit': 10 1057 | } 1058 | }, (err, result, response) => { 1059 | //see docs for `result` parameters 1060 | }); 1061 | ``` 1062 | 1063 | 1064 | ### files/lock_file_batch ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-lock_file_batch)) 1065 | Lock the files at the given paths. A locked file will be writable only by the lock holder. A successful response indicates that the file has been locked. Returns a list of the locked file paths and their metadata after this operation. 1066 | 1067 | ```js 1068 | dropbox({ 1069 | resource: 'files/lock_file_batch', 1070 | parameters: { 1071 | 'entries': [{ 1072 | 'path': '/John Doe/sample/test.pdf' 1073 | }] 1074 | } 1075 | }, (err, result, response) => { 1076 | //see docs for `result` parameters 1077 | }); 1078 | ``` 1079 | 1080 | 1081 | ### files/move ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-move)) 1082 | Move a file or folder to a different location in the user's Dropbox. 1083 | If the source path is a folder all its contents will be moved. 1084 | 1085 | ```js 1086 | dropbox({ 1087 | resource: 'files/move', 1088 | parameters: { 1089 | 'from_path': '/Homework/math', 1090 | 'to_path': '/Homework/algebra', 1091 | 'allow_shared_folder': false, 1092 | 'autorename': false, 1093 | 'allow_ownership_transfer': false 1094 | } 1095 | }, (err, result, response) => { 1096 | //see docs for `result` parameters 1097 | }); 1098 | ``` 1099 | 1100 | 1101 | ### files/move_v2 ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-move_v2)) 1102 | Move a file or folder to a different location in the user's Dropbox. 1103 | If the source path is a folder all its contents will be moved. 1104 | Note that we do not currently support case-only renaming. 1105 | 1106 | ```js 1107 | dropbox({ 1108 | resource: 'files/move_v2', 1109 | parameters: { 1110 | 'from_path': '/Homework/math', 1111 | 'to_path': '/Homework/algebra', 1112 | 'allow_shared_folder': false, 1113 | 'autorename': false, 1114 | 'allow_ownership_transfer': false 1115 | } 1116 | }, (err, result, response) => { 1117 | //see docs for `result` parameters 1118 | }); 1119 | ``` 1120 | 1121 | 1122 | ### files/move_batch ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-move_batch)) 1123 | Move multiple files or folders to different locations at once in the user's Dropbox. 1124 | This route will return job ID immediately and do the async moving job in background. Please use :route:`move_batch/check:1` to check the job status. 1125 | 1126 | ```js 1127 | dropbox({ 1128 | resource: 'files/move_batch', 1129 | parameters: { 1130 | 'entries': [{ 1131 | 'from_path': '/Homework/math', 1132 | 'to_path': '/Homework/algebra' 1133 | }], 1134 | 'autorename': false, 1135 | 'allow_shared_folder': false, 1136 | 'allow_ownership_transfer': false 1137 | } 1138 | }, (err, result, response) => { 1139 | //see docs for `result` parameters 1140 | }); 1141 | ``` 1142 | 1143 | 1144 | ### files/move_batch_v2 ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-move_batch_v2)) 1145 | Move multiple files or folders to different locations at once in the user's Dropbox. Note that we do not currently support case-only renaming. 1146 | This route will replace :route:`move_batch:1`. The main difference is this route will return status for each entry, while :route:`move_batch:1` raises failure if any entry fails. 1147 | This route will either finish synchronously, or return a job ID and do the async move job in background. Please use :route:`move_batch/check:2` to check the job status. 1148 | 1149 | ```js 1150 | dropbox({ 1151 | resource: 'files/move_batch_v2', 1152 | parameters: { 1153 | 'entries': [{ 1154 | 'from_path': '/Homework/math', 1155 | 'to_path': '/Homework/algebra' 1156 | }], 1157 | 'autorename': false, 1158 | 'allow_ownership_transfer': false 1159 | } 1160 | }, (err, result, response) => { 1161 | //see docs for `result` parameters 1162 | }); 1163 | ``` 1164 | 1165 | 1166 | ### files/move_batch/check ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-move_batch-check)) 1167 | Returns the status of an asynchronous job for :route:`move_batch:1`. If success, it returns list of results for each entry. 1168 | 1169 | ```js 1170 | dropbox({ 1171 | resource: 'files/move_batch/check', 1172 | parameters: { 1173 | 'async_job_id': '34g93hh34h04y384084' 1174 | } 1175 | }, (err, result, response) => { 1176 | //see docs for `result` parameters 1177 | }); 1178 | ``` 1179 | 1180 | 1181 | ### files/move_batch/check_v2 ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-move_batch-check_v2)) 1182 | Returns the status of an asynchronous job for :route:`move_batch:2`. It returns list of results for each entry. 1183 | 1184 | ```js 1185 | dropbox({ 1186 | resource: 'files/move_batch/check_v2', 1187 | parameters: { 1188 | 'async_job_id': '34g93hh34h04y384084' 1189 | } 1190 | }, (err, result, response) => { 1191 | //see docs for `result` parameters 1192 | }); 1193 | ``` 1194 | 1195 | 1196 | ### files/paper/create ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-paper-create)) 1197 | Creates a new Paper doc with the provided content. 1198 | 1199 | ```js 1200 | const stream = dropbox({ 1201 | resource: 'files/paper/create', 1202 | parameters: { 1203 | 'path': '/Paper Docs/New Doc.paper', 1204 | 'import_format': 'html' 1205 | } 1206 | }, (err, result, response) => { 1207 | //see docs for `result` parameters 1208 | }); 1209 | 1210 | fs.createReadStream('/Paper Docs/New Doc.paper').pipe(stream); 1211 | ``` 1212 | 1213 | 1214 | ### files/paper/update ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-paper-update)) 1215 | Updates an existing Paper doc with the provided content. 1216 | 1217 | ```js 1218 | const stream = dropbox({ 1219 | resource: 'files/paper/update', 1220 | parameters: { 1221 | 'path': '/Paper Docs/My Doc.paper', 1222 | 'import_format': 'html', 1223 | 'doc_update_policy': 'update', 1224 | 'paper_revision': 123 1225 | } 1226 | }, (err, result, response) => { 1227 | //see docs for `result` parameters 1228 | }); 1229 | 1230 | fs.createReadStream('/Paper Docs/My Doc.paper').pipe(stream); 1231 | ``` 1232 | 1233 | 1234 | ### files/permanently_delete ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-permanently_delete)) 1235 | Permanently delete the file or folder at a given path (see https://www.dropbox.com/en/help/40). 1236 | If the given file or folder is not yet deleted, this route will first delete it. It is possible for this route to successfully delete, then fail to permanently delete. 1237 | Note: This endpoint is only available for Dropbox Business apps. 1238 | 1239 | ```js 1240 | dropbox({ 1241 | resource: 'files/permanently_delete', 1242 | parameters: { 1243 | 'path': '/Homework/math/Prime_Numbers.txt' 1244 | } 1245 | }, (err, result, response) => { 1246 | //see docs for `result` parameters 1247 | }); 1248 | ``` 1249 | 1250 | 1251 | ### files/restore ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-restore)) 1252 | Restore a specific revision of a file to the given path. 1253 | 1254 | ```js 1255 | dropbox({ 1256 | resource: 'files/restore', 1257 | parameters: { 1258 | 'path': '/root/word.docx', 1259 | 'rev': 'a1c10ce0dd78' 1260 | } 1261 | }, (err, result, response) => { 1262 | //see docs for `result` parameters 1263 | }); 1264 | ``` 1265 | 1266 | 1267 | ### files/save_url ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-save_url)) 1268 | Save the data from a specified URL into a file in user's Dropbox. 1269 | Note that the transfer from the URL must complete within 5 minutes, or the operation will time out and the job will fail. 1270 | If the given path already exists, the file will be renamed to avoid the conflict (e.g. myfile (1).txt). 1271 | 1272 | ```js 1273 | dropbox({ 1274 | resource: 'files/save_url', 1275 | parameters: { 1276 | 'path': '/a.txt', 1277 | 'url': 'http://example.com/a.txt' 1278 | } 1279 | }, (err, result, response) => { 1280 | //see docs for `result` parameters 1281 | }); 1282 | ``` 1283 | 1284 | 1285 | ### files/save_url/check_job_status ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-save_url-check_job_status)) 1286 | Check the status of a :route:`save_url` job. 1287 | 1288 | ```js 1289 | dropbox({ 1290 | resource: 'files/save_url/check_job_status', 1291 | parameters: { 1292 | 'async_job_id': '34g93hh34h04y384084' 1293 | } 1294 | }, (err, result, response) => { 1295 | //see docs for `result` parameters 1296 | }); 1297 | ``` 1298 | 1299 | 1300 | ### files/search ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-search)) 1301 | Searches for files and folders. 1302 | Note: Recent changes will be reflected in search results within a few seconds and older revisions of existing files may still match your query for up to a few days. 1303 | 1304 | ```js 1305 | dropbox({ 1306 | resource: 'files/search', 1307 | parameters: { 1308 | 'path': '', 1309 | 'query': 'prime numbers', 1310 | 'start': 0, 1311 | 'max_results': 100, 1312 | 'mode': 'filename' 1313 | } 1314 | }, (err, result, response) => { 1315 | //see docs for `result` parameters 1316 | }); 1317 | ``` 1318 | 1319 | 1320 | ### files/search_v2 ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-search_v2)) 1321 | Searches for files and folders. 1322 | Note: :route:`search:2` along with :route:`search/continue:2` can only be used to retrieve a maximum of 10,000 matches. 1323 | Recent changes may not immediately be reflected in search results due to a short delay in indexing. Duplicate results may be returned across pages. Some results may not be returned. 1324 | 1325 | ```js 1326 | dropbox({ 1327 | resource: 'files/search_v2', 1328 | parameters: { 1329 | 'query': 'cat', 1330 | 'options': { 1331 | 'path': '/Folder', 1332 | 'max_results': 20, 1333 | 'file_status': 'active', 1334 | 'filename_only': false 1335 | }, 1336 | 'match_field_options': { 1337 | 'include_highlights': false 1338 | } 1339 | } 1340 | }, (err, result, response) => { 1341 | //see docs for `result` parameters 1342 | }); 1343 | ``` 1344 | 1345 | 1346 | ### files/search/continue_v2 ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-search-continue_v2)) 1347 | Fetches the next page of search results returned from :route:`search:2`. 1348 | Note: :route:`search:2` along with :route:`search/continue:2` can only be used to retrieve a maximum of 10,000 matches. 1349 | Recent changes may not immediately be reflected in search results due to a short delay in indexing. Duplicate results may be returned across pages. Some results may not be returned. 1350 | 1351 | ```js 1352 | dropbox({ 1353 | resource: 'files/search/continue_v2', 1354 | parameters: { 1355 | 'cursor': 'ZtkX9_EHj3x7PMkVuFIhwKYXEpwpLwyxp9vMKomUhllil9q7eWiAu' 1356 | } 1357 | }, (err, result, response) => { 1358 | //see docs for `result` parameters 1359 | }); 1360 | ``` 1361 | 1362 | 1363 | ### files/tags/add ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-tags-add)) 1364 | Add a tag to an item. A tag is a string. The strings are automatically converted to lowercase letters. No more than 20 tags can be added to a given item. 1365 | 1366 | ```js 1367 | dropbox({ 1368 | resource: 'files/tags/add', 1369 | parameters: { 1370 | 'path': '/Prime_Numbers.txt', 1371 | 'tag_text': 'my_tag' 1372 | } 1373 | }, (err, result, response) => { 1374 | //see docs for `result` parameters 1375 | }); 1376 | ``` 1377 | 1378 | 1379 | ### files/tags/get ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-tags-get)) 1380 | Get list of tags assigned to items. 1381 | 1382 | ```js 1383 | dropbox({ 1384 | resource: 'files/tags/get', 1385 | parameters: { 1386 | 'paths': ['/Prime_Numbers.txt'] 1387 | } 1388 | }, (err, result, response) => { 1389 | //see docs for `result` parameters 1390 | }); 1391 | ``` 1392 | 1393 | 1394 | ### files/tags/remove ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-tags-remove)) 1395 | Remove a tag from an item. 1396 | 1397 | ```js 1398 | dropbox({ 1399 | resource: 'files/tags/remove', 1400 | parameters: { 1401 | 'path': '/Prime_Numbers.txt', 1402 | 'tag_text': 'my_tag' 1403 | } 1404 | }, (err, result, response) => { 1405 | //see docs for `result` parameters 1406 | }); 1407 | ``` 1408 | 1409 | 1410 | ### files/unlock_file_batch ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-unlock_file_batch)) 1411 | Unlock the files at the given paths. A locked file can only be unlocked by the lock holder or, if a business account, a team admin. A successful response indicates that the file has been unlocked. Returns a list of the unlocked file paths and their metadata after this operation. 1412 | 1413 | ```js 1414 | dropbox({ 1415 | resource: 'files/unlock_file_batch', 1416 | parameters: { 1417 | 'entries': [{ 1418 | 'path': '/John Doe/sample/test.pdf' 1419 | }] 1420 | } 1421 | }, (err, result, response) => { 1422 | //see docs for `result` parameters 1423 | }); 1424 | ``` 1425 | 1426 | 1427 | ### files/upload ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-upload)) 1428 | Create a new file with the contents provided in the request. 1429 | Do not use this to upload a file larger than 150 MB. Instead, create an upload session with :route:`upload_session/start`. 1430 | Calls to this endpoint will count as data transport calls for any Dropbox Business teams with a limit on the number of data transport calls allowed per month. For more information, see the :link:`Data transport limit page https://www.dropbox.com/developers/reference/data-transport-limit`. 1431 | 1432 | ```js 1433 | const stream = dropbox({ 1434 | resource: 'files/upload', 1435 | parameters: { 1436 | 'path': '/Homework/math/Matrices.txt', 1437 | 'mode': 'add', 1438 | 'autorename': false, 1439 | 'mute': false, 1440 | 'strict_conflict': false 1441 | } 1442 | }, (err, result, response) => { 1443 | //see docs for `result` parameters 1444 | }); 1445 | 1446 | fs.createReadStream('/Homework/math/Matrices.txt').pipe(stream); 1447 | ``` 1448 | 1449 | 1450 | ### files/upload_session/append ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-append)) 1451 | Append more data to an upload session. 1452 | A single request should not upload more than 150 MB. The maximum size of a file one can upload to an upload session is 350 GB. 1453 | Calls to this endpoint will count as data transport calls for any Dropbox Business teams with a limit on the number of data transport calls allowed per month. For more information, see the :link:`Data transport limit page https://www.dropbox.com/developers/reference/data-transport-limit`. 1454 | 1455 | ```js 1456 | const stream = dropbox({ 1457 | resource: 'files/upload_session/append', 1458 | parameters: { 1459 | 'session_id': '1234faaf0678bcde', 1460 | 'offset': 0 1461 | } 1462 | }, (err, result, response) => { 1463 | //see docs for `result` parameters 1464 | }); 1465 | 1466 | fs.createReadStream().pipe(stream); 1467 | ``` 1468 | 1469 | 1470 | ### files/upload_session/append_v2 ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-append_v2)) 1471 | Append more data to an upload session. 1472 | When the parameter close is set, this call will close the session. 1473 | A single request should not upload more than 150 MB. The maximum size of a file one can upload to an upload session is 350 GB. 1474 | Calls to this endpoint will count as data transport calls for any Dropbox Business teams with a limit on the number of data transport calls allowed per month. For more information, see the :link:`Data transport limit page https://www.dropbox.com/developers/reference/data-transport-limit`. 1475 | 1476 | ```js 1477 | const stream = dropbox({ 1478 | resource: 'files/upload_session/append_v2', 1479 | parameters: { 1480 | 'cursor': { 1481 | 'session_id': '1234faaf0678bcde', 1482 | 'offset': 0 1483 | }, 1484 | 'close': false 1485 | } 1486 | }, (err, result, response) => { 1487 | //see docs for `result` parameters 1488 | }); 1489 | 1490 | fs.createReadStream().pipe(stream); 1491 | ``` 1492 | 1493 | 1494 | ### files/upload_session/finish ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-finish)) 1495 | Finish an upload session and save the uploaded data to the given file path. 1496 | A single request should not upload more than 150 MB. The maximum size of a file one can upload to an upload session is 350 GB. 1497 | Calls to this endpoint will count as data transport calls for any Dropbox Business teams with a limit on the number of data transport calls allowed per month. For more information, see the :link:`Data transport limit page https://www.dropbox.com/developers/reference/data-transport-limit`. 1498 | 1499 | ```js 1500 | const stream = dropbox({ 1501 | resource: 'files/upload_session/finish', 1502 | parameters: { 1503 | 'cursor': { 1504 | 'session_id': '1234faaf0678bcde', 1505 | 'offset': 0 1506 | }, 1507 | 'commit': { 1508 | 'path': '/Homework/math/Matrices.txt', 1509 | 'mode': 'add', 1510 | 'autorename': true, 1511 | 'mute': false, 1512 | 'strict_conflict': false 1513 | } 1514 | } 1515 | }, (err, result, response) => { 1516 | //see docs for `result` parameters 1517 | }); 1518 | 1519 | fs.createReadStream().pipe(stream); 1520 | ``` 1521 | 1522 | 1523 | ### files/upload_session/finish_batch ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-finish_batch)) 1524 | This route helps you commit many files at once into a user's Dropbox. Use :route:`upload_session/start` and :route:`upload_session/append:2` to upload file contents. We recommend uploading many files in parallel to increase throughput. Once the file contents have been uploaded, rather than calling :route:`upload_session/finish`, use this route to finish all your upload sessions in a single request. 1525 | :field:`UploadSessionStartArg.close` or :field:`UploadSessionAppendArg.close` needs to be true for the last :route:`upload_session/start` or :route:`upload_session/append:2` call. The maximum size of a file one can upload to an upload session is 350 GB. 1526 | This route will return a job_id immediately and do the async commit job in background. Use :route:`upload_session/finish_batch/check` to check the job status. 1527 | For the same account, this route should be executed serially. That means you should not start the next job before current job finishes. We allow up to 1000 entries in a single request. 1528 | Calls to this endpoint will count as data transport calls for any Dropbox Business teams with a limit on the number of data transport calls allowed per month. For more information, see the :link:`Data transport limit page https://www.dropbox.com/developers/reference/data-transport-limit`. 1529 | 1530 | ```js 1531 | dropbox({ 1532 | resource: 'files/upload_session/finish_batch', 1533 | parameters: { 1534 | 'entries': [{ 1535 | 'cursor': { 1536 | 'session_id': '1234faaf0678bcde', 1537 | 'offset': 0 1538 | }, 1539 | 'commit': { 1540 | 'path': '/Homework/math/Matrices.txt', 1541 | 'mode': 'add', 1542 | 'autorename': true, 1543 | 'mute': false, 1544 | 'strict_conflict': false 1545 | } 1546 | }] 1547 | } 1548 | }, (err, result, response) => { 1549 | //see docs for `result` parameters 1550 | }); 1551 | ``` 1552 | 1553 | 1554 | ### files/upload_session/finish_batch_v2 ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-finish_batch_v2)) 1555 | This route helps you commit many files at once into a user's Dropbox. Use :route:`upload_session/start` and :route:`upload_session/append:2` to upload file contents. We recommend uploading many files in parallel to increase throughput. Once the file contents have been uploaded, rather than calling :route:`upload_session/finish`, use this route to finish all your upload sessions in a single request. 1556 | :field:`UploadSessionStartArg.close` or :field:`UploadSessionAppendArg.close` needs to be true for the last :route:`upload_session/start` or :route:`upload_session/append:2` call of each upload session. The maximum size of a file one can upload to an upload session is 350 GB. 1557 | We allow up to 1000 entries in a single request. 1558 | Calls to this endpoint will count as data transport calls for any Dropbox Business teams with a limit on the number of data transport calls allowed per month. For more information, see the :link:`Data transport limit page https://www.dropbox.com/developers/reference/data-transport-limit`. 1559 | 1560 | ```js 1561 | dropbox({ 1562 | resource: 'files/upload_session/finish_batch_v2', 1563 | parameters: { 1564 | 'entries': [{ 1565 | 'cursor': { 1566 | 'session_id': '1234faaf0678bcde', 1567 | 'offset': 0 1568 | }, 1569 | 'commit': { 1570 | 'path': '/Homework/math/Matrices.txt', 1571 | 'mode': 'add', 1572 | 'autorename': true, 1573 | 'mute': false, 1574 | 'strict_conflict': false 1575 | } 1576 | }] 1577 | } 1578 | }, (err, result, response) => { 1579 | //see docs for `result` parameters 1580 | }); 1581 | ``` 1582 | 1583 | 1584 | ### files/upload_session/finish_batch/check ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-finish_batch-check)) 1585 | Returns the status of an asynchronous job for :route:`upload_session/finish_batch`. If success, it returns list of result for each entry. 1586 | 1587 | ```js 1588 | dropbox({ 1589 | resource: 'files/upload_session/finish_batch/check', 1590 | parameters: { 1591 | 'async_job_id': '34g93hh34h04y384084' 1592 | } 1593 | }, (err, result, response) => { 1594 | //see docs for `result` parameters 1595 | }); 1596 | ``` 1597 | 1598 | 1599 | ### files/upload_session/start ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-start)) 1600 | Upload sessions allow you to upload a single file in one or more requests, for example where the size of the file is greater than 150 MB. This call starts a new upload session with the given data. You can then use :route:`upload_session/append:2` to add more data and :route:`upload_session/finish` to save all the data to a file in Dropbox. 1601 | A single request should not upload more than 150 MB. The maximum size of a file one can upload to an upload session is 350 GB. 1602 | An upload session can be used for a maximum of 7 days. Attempting to use an :field:`UploadSessionStartResult.session_id` with :route:`upload_session/append:2` or :route:`upload_session/finish` more than 7 days after its creation will return a :field:`UploadSessionLookupError.not_found`. 1603 | Calls to this endpoint will count as data transport calls for any Dropbox Business teams with a limit on the number of data transport calls allowed per month. For more information, see the :link:`Data transport limit page https://www.dropbox.com/developers/reference/data-transport-limit`. 1604 | By default, upload sessions require you to send content of the file in sequential order via consecutive :route:`upload_session/start`, :route:`upload_session/append:2`, :route:`upload_session/finish` calls. For better performance, you can instead optionally use a :field:`UploadSessionType.concurrent` upload session. To start a new concurrent session, set :field:`UploadSessionStartArg.session_type` to :field:`UploadSessionType.concurrent`. After that, you can send file data in concurrent :route:`upload_session/append:2` requests. Finally finish the session with :route:`upload_session/finish`. 1605 | There are couple of constraints with concurrent sessions to make them work. You can not send data with :route:`upload_session/start` or :route:`upload_session/finish` call, only with :route:`upload_session/append:2` call. Also data uploaded in :route:`upload_session/append:2` call must be multiple of 4194304 bytes (except for last :route:`upload_session/append:2` with :field:`UploadSessionStartArg.close` to :val:`true`, that may contain any remaining data). 1606 | 1607 | ```js 1608 | const stream = dropbox({ 1609 | resource: 'files/upload_session/start', 1610 | parameters: { 1611 | 'close': false 1612 | } 1613 | }, (err, result, response) => { 1614 | //see docs for `result` parameters 1615 | }); 1616 | 1617 | fs.createReadStream().pipe(stream); 1618 | ``` 1619 | 1620 | 1621 | ### files/upload_session/start_batch ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-upload_session-start_batch)) 1622 | This route starts batch of upload_sessions. Please refer to `upload_session/start` usage. 1623 | Calls to this endpoint will count as data transport calls for any Dropbox Business teams with a limit on the number of data transport calls allowed per month. For more information, see the :link:`Data transport limit page https://www.dropbox.com/developers/reference/data-transport-limit`. 1624 | 1625 | ```js 1626 | dropbox({ 1627 | resource: 'files/upload_session/start_batch', 1628 | parameters: { 1629 | 'num_sessions': 1 1630 | } 1631 | }, (err, result, response) => { 1632 | //see docs for `result` parameters 1633 | }); 1634 | ``` 1635 | 1636 | 1637 | ### files/alpha/get_metadata ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-alpha-get_metadata)) 1638 | Returns the metadata for a file or folder. This is an alpha endpoint compatible with the properties API. 1639 | Note: Metadata for the root folder is unsupported. 1640 | 1641 | ```js 1642 | dropbox({ 1643 | resource: 'files/alpha/get_metadata', 1644 | parameters: { 1645 | 'path': '/Homework/math', 1646 | 'include_media_info': false, 1647 | 'include_deleted': false, 1648 | 'include_has_explicit_shared_members': false 1649 | } 1650 | }, (err, result, response) => { 1651 | //see docs for `result` parameters 1652 | }); 1653 | ``` 1654 | 1655 | 1656 | ### files/alpha/upload ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-alpha-upload)) 1657 | Create a new file with the contents provided in the request. Note that the behavior of this alpha endpoint is unstable and subject to change. 1658 | Do not use this to upload a file larger than 150 MB. Instead, create an upload session with :route:`upload_session/start`. 1659 | 1660 | ```js 1661 | const stream = dropbox({ 1662 | resource: 'files/alpha/upload', 1663 | parameters: { 1664 | 'path': '/Homework/math/Matrices.txt', 1665 | 'mode': 'add', 1666 | 'autorename': false, 1667 | 'mute': false, 1668 | 'strict_conflict': false 1669 | } 1670 | }, (err, result, response) => { 1671 | //see docs for `result` parameters 1672 | }); 1673 | 1674 | fs.createReadStream('/Homework/math/Matrices.txt').pipe(stream); 1675 | ``` 1676 | 1677 | 1678 | ### files/properties/add ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-properties-add)) 1679 | undefined 1680 | 1681 | ```js 1682 | dropbox({ 1683 | resource: 'files/properties/add', 1684 | parameters: { 1685 | 'path': '/my_awesome/word.docx', 1686 | 'property_groups': [{ 1687 | 'template_id': 'ptid:1a5n2i6d3OYEAAAAAAAAAYa', 1688 | 'fields': [{ 1689 | 'name': 'Security Policy', 1690 | 'value': 'Confidential' 1691 | }] 1692 | }] 1693 | } 1694 | }, (err, result, response) => { 1695 | //see docs for `result` parameters 1696 | }); 1697 | ``` 1698 | 1699 | 1700 | ### files/properties/overwrite ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-properties-overwrite)) 1701 | undefined 1702 | 1703 | ```js 1704 | dropbox({ 1705 | resource: 'files/properties/overwrite', 1706 | parameters: { 1707 | 'path': '/my_awesome/word.docx', 1708 | 'property_groups': [{ 1709 | 'template_id': 'ptid:1a5n2i6d3OYEAAAAAAAAAYa', 1710 | 'fields': [{ 1711 | 'name': 'Security Policy', 1712 | 'value': 'Confidential' 1713 | }] 1714 | }] 1715 | } 1716 | }, (err, result, response) => { 1717 | //see docs for `result` parameters 1718 | }); 1719 | ``` 1720 | 1721 | 1722 | ### files/properties/remove ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-properties-remove)) 1723 | undefined 1724 | 1725 | ```js 1726 | dropbox({ 1727 | resource: 'files/properties/remove', 1728 | parameters: { 1729 | 'path': '/my_awesome/word.docx', 1730 | 'property_template_ids': ['ptid:1a5n2i6d3OYEAAAAAAAAAYa'] 1731 | } 1732 | }, (err, result, response) => { 1733 | //see docs for `result` parameters 1734 | }); 1735 | ``` 1736 | 1737 | 1738 | ### files/properties/template/get ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-properties-template-get)) 1739 | undefined 1740 | 1741 | ```js 1742 | dropbox({ 1743 | resource: 'files/properties/template/get', 1744 | parameters: { 1745 | 'template_id': 'ptid:1a5n2i6d3OYEAAAAAAAAAYa' 1746 | } 1747 | }, (err, result, response) => { 1748 | //see docs for `result` parameters 1749 | }); 1750 | ``` 1751 | 1752 | 1753 | ### files/properties/template/list ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-properties-template-list)) 1754 | undefined 1755 | 1756 | ```js 1757 | dropbox({ 1758 | resource: 'files/properties/template/list' 1759 | }, (err, result, response) => { 1760 | //see docs for `result` parameters 1761 | }); 1762 | ``` 1763 | 1764 | 1765 | ### files/properties/update ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#files-properties-update)) 1766 | undefined 1767 | 1768 | ```js 1769 | dropbox({ 1770 | resource: 'files/properties/update', 1771 | parameters: { 1772 | 'path': '/my_awesome/word.docx', 1773 | 'update_property_groups': [{ 1774 | 'template_id': 'ptid:1a5n2i6d3OYEAAAAAAAAAYa', 1775 | 'add_or_update_fields': [{ 1776 | 'name': 'Security Policy', 1777 | 'value': 'Confidential' 1778 | }], 1779 | 'remove_fields': [] 1780 | }] 1781 | } 1782 | }, (err, result, response) => { 1783 | //see docs for `result` parameters 1784 | }); 1785 | ``` 1786 | 1787 | 1788 | ### sharing/add_file_member ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-add_file_member)) 1789 | Adds specified members to a file. 1790 | 1791 | ```js 1792 | dropbox({ 1793 | resource: 'sharing/add_file_member', 1794 | parameters: { 1795 | 'file': 'id:3kmLmQFnf1AAAAAAAAAAAw', 1796 | 'members': [{ 1797 | '.tag': 'email', 1798 | 'email': 'justin@example.com' 1799 | }], 1800 | 'custom_message': 'This is a custom message about ACME.doc', 1801 | 'quiet': false, 1802 | 'access_level': 'viewer', 1803 | 'add_message_as_comment': false 1804 | } 1805 | }, (err, result, response) => { 1806 | //see docs for `result` parameters 1807 | }); 1808 | ``` 1809 | 1810 | 1811 | ### sharing/add_folder_member ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-add_folder_member)) 1812 | Allows an owner or editor (if the ACL update policy allows) of a shared folder to add another member. 1813 | For the new member to get access to all the functionality for this folder, you will need to call :route:`mount_folder` on their behalf. 1814 | 1815 | ```js 1816 | dropbox({ 1817 | resource: 'sharing/add_folder_member', 1818 | parameters: { 1819 | 'shared_folder_id': '84528192421', 1820 | 'members': [{ 1821 | 'member': { 1822 | '.tag': 'email', 1823 | 'email': 'justin@example.com' 1824 | }, 1825 | 'access_level': 'editor' 1826 | }, { 1827 | 'member': { 1828 | '.tag': 'dropbox_id', 1829 | 'dropbox_id': 'dbid:AAEufNrMPSPe0dMQijRP0N_aZtBJRm26W4Q' 1830 | }, 1831 | 'access_level': 'viewer' 1832 | }], 1833 | 'quiet': false, 1834 | 'custom_message': 'Documentation for launch day' 1835 | } 1836 | }, (err, result, response) => { 1837 | //see docs for `result` parameters 1838 | }); 1839 | ``` 1840 | 1841 | 1842 | ### sharing/check_job_status ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-check_job_status)) 1843 | Returns the status of an asynchronous job. 1844 | 1845 | ```js 1846 | dropbox({ 1847 | resource: 'sharing/check_job_status', 1848 | parameters: { 1849 | 'async_job_id': '34g93hh34h04y384084' 1850 | } 1851 | }, (err, result, response) => { 1852 | //see docs for `result` parameters 1853 | }); 1854 | ``` 1855 | 1856 | 1857 | ### sharing/check_remove_member_job_status ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-check_remove_member_job_status)) 1858 | Returns the status of an asynchronous job for sharing a folder. 1859 | 1860 | ```js 1861 | dropbox({ 1862 | resource: 'sharing/check_remove_member_job_status', 1863 | parameters: { 1864 | 'async_job_id': '34g93hh34h04y384084' 1865 | } 1866 | }, (err, result, response) => { 1867 | //see docs for `result` parameters 1868 | }); 1869 | ``` 1870 | 1871 | 1872 | ### sharing/check_share_job_status ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-check_share_job_status)) 1873 | Returns the status of an asynchronous job for sharing a folder. 1874 | 1875 | ```js 1876 | dropbox({ 1877 | resource: 'sharing/check_share_job_status', 1878 | parameters: { 1879 | 'async_job_id': '34g93hh34h04y384084' 1880 | } 1881 | }, (err, result, response) => { 1882 | //see docs for `result` parameters 1883 | }); 1884 | ``` 1885 | 1886 | 1887 | ### sharing/create_shared_link_with_settings ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-create_shared_link_with_settings)) 1888 | Create a shared link with custom settings. If no settings are given then the default visibility is :field:`RequestedVisibility.public` (The resolved visibility, though, may depend on other aspects such as team and shared folder settings). 1889 | 1890 | ```js 1891 | dropbox({ 1892 | resource: 'sharing/create_shared_link_with_settings', 1893 | parameters: { 1894 | 'path': '/Prime_Numbers.txt', 1895 | 'settings': { 1896 | 'audience': 'public', 1897 | 'access': 'viewer', 1898 | 'requested_visibility': 'public', 1899 | 'allow_download': true 1900 | } 1901 | } 1902 | }, (err, result, response) => { 1903 | //see docs for `result` parameters 1904 | }); 1905 | ``` 1906 | 1907 | 1908 | ### sharing/get_file_metadata ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_file_metadata)) 1909 | Returns shared file metadata. 1910 | 1911 | ```js 1912 | dropbox({ 1913 | resource: 'sharing/get_file_metadata', 1914 | parameters: { 1915 | 'file': 'id:3kmLmQFnf1AAAAAAAAAAAw', 1916 | 'actions': [] 1917 | } 1918 | }, (err, result, response) => { 1919 | //see docs for `result` parameters 1920 | }); 1921 | ``` 1922 | 1923 | 1924 | ### sharing/get_file_metadata/batch ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_file_metadata-batch)) 1925 | Returns shared file metadata. 1926 | 1927 | ```js 1928 | dropbox({ 1929 | resource: 'sharing/get_file_metadata/batch', 1930 | parameters: { 1931 | 'files': ['id:3kmLmQFnf1AAAAAAAAAAAw', 'id:VvTaJu2VZzAAAAAAAAAADQ'], 1932 | 'actions': [] 1933 | } 1934 | }, (err, result, response) => { 1935 | //see docs for `result` parameters 1936 | }); 1937 | ``` 1938 | 1939 | 1940 | ### sharing/get_folder_metadata ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_folder_metadata)) 1941 | Returns shared folder metadata by its folder ID. 1942 | 1943 | ```js 1944 | dropbox({ 1945 | resource: 'sharing/get_folder_metadata', 1946 | parameters: { 1947 | 'shared_folder_id': '84528192421', 1948 | 'actions': [] 1949 | } 1950 | }, (err, result, response) => { 1951 | //see docs for `result` parameters 1952 | }); 1953 | ``` 1954 | 1955 | 1956 | ### sharing/get_shared_link_file ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_file)) 1957 | Download the shared link's file from a user's Dropbox. 1958 | 1959 | ```js 1960 | const stream = dropbox({ 1961 | resource: 'sharing/get_shared_link_file', 1962 | parameters: { 1963 | 'url': 'https://www.dropbox.com/s/2sn712vy1ovegw8/Prime_Numbers.txt?dl=0', 1964 | 'path': '/Prime_Numbers.txt' 1965 | } 1966 | }, (err, result, response) => { 1967 | //see docs for `result` parameters 1968 | }); 1969 | 1970 | stream 1971 | .pipe(fs.createWriteStream('/Prime_Numbers.txt')); //pipe the stream 1972 | ``` 1973 | 1974 | 1975 | ### sharing/get_shared_link_metadata ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_metadata)) 1976 | Get the shared link's metadata. 1977 | 1978 | ```js 1979 | dropbox({ 1980 | resource: 'sharing/get_shared_link_metadata', 1981 | parameters: { 1982 | 'url': 'https://www.dropbox.com/s/2sn712vy1ovegw8/Prime_Numbers.txt?dl=0', 1983 | 'path': '/Prime_Numbers.txt' 1984 | } 1985 | }, (err, result, response) => { 1986 | //see docs for `result` parameters 1987 | }); 1988 | ``` 1989 | 1990 | 1991 | ### sharing/list_file_members ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_file_members)) 1992 | Use to obtain the members who have been invited to a file, both inherited and uninherited members. 1993 | 1994 | ```js 1995 | dropbox({ 1996 | resource: 'sharing/list_file_members', 1997 | parameters: { 1998 | 'file': 'id:3kmLmQFnf1AAAAAAAAAAAw', 1999 | 'include_inherited': true, 2000 | 'limit': 100 2001 | } 2002 | }, (err, result, response) => { 2003 | //see docs for `result` parameters 2004 | }); 2005 | ``` 2006 | 2007 | 2008 | ### sharing/list_file_members/batch ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_file_members-batch)) 2009 | Get members of multiple files at once. The arguments to this route are more limited, and the limit on query result size per file is more strict. To customize the results more, use the individual file endpoint. 2010 | Inherited users and groups are not included in the result, and permissions are not returned for this endpoint. 2011 | 2012 | ```js 2013 | dropbox({ 2014 | resource: 'sharing/list_file_members/batch', 2015 | parameters: { 2016 | 'files': ['id:3kmLmQFnf1AAAAAAAAAAAw', 'id:VvTaJu2VZzAAAAAAAAAADQ'], 2017 | 'limit': 10 2018 | } 2019 | }, (err, result, response) => { 2020 | //see docs for `result` parameters 2021 | }); 2022 | ``` 2023 | 2024 | 2025 | ### sharing/list_file_members/continue ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_file_members-continue)) 2026 | Once a cursor has been retrieved from :route:`list_file_members` or :route:`list_file_members/batch`, use this to paginate through all shared file members. 2027 | 2028 | ```js 2029 | dropbox({ 2030 | resource: 'sharing/list_file_members/continue', 2031 | parameters: { 2032 | 'cursor': 'ZtkX9_EHj3x7PMkVuFIhwKYXEpwpLwyxp9vMKomUhllil9q7eWiAu' 2033 | } 2034 | }, (err, result, response) => { 2035 | //see docs for `result` parameters 2036 | }); 2037 | ``` 2038 | 2039 | 2040 | ### sharing/list_folder_members ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_folder_members)) 2041 | Returns shared folder membership by its folder ID. 2042 | 2043 | ```js 2044 | dropbox({ 2045 | resource: 'sharing/list_folder_members', 2046 | parameters: { 2047 | 'shared_folder_id': '84528192421', 2048 | 'actions': [], 2049 | 'limit': 10 2050 | } 2051 | }, (err, result, response) => { 2052 | //see docs for `result` parameters 2053 | }); 2054 | ``` 2055 | 2056 | 2057 | ### sharing/list_folder_members/continue ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_folder_members-continue)) 2058 | Once a cursor has been retrieved from :route:`list_folder_members`, use this to paginate through all shared folder members. 2059 | 2060 | ```js 2061 | dropbox({ 2062 | resource: 'sharing/list_folder_members/continue', 2063 | parameters: { 2064 | 'cursor': 'ZtkX9_EHj3x7PMkVuFIhwKYXEpwpLwyxp9vMKomUhllil9q7eWiAu' 2065 | } 2066 | }, (err, result, response) => { 2067 | //see docs for `result` parameters 2068 | }); 2069 | ``` 2070 | 2071 | 2072 | ### sharing/list_folders ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_folders)) 2073 | Return the list of all shared folders the current user has access to. 2074 | 2075 | ```js 2076 | dropbox({ 2077 | resource: 'sharing/list_folders', 2078 | parameters: { 2079 | 'limit': 100, 2080 | 'actions': [] 2081 | } 2082 | }, (err, result, response) => { 2083 | //see docs for `result` parameters 2084 | }); 2085 | ``` 2086 | 2087 | 2088 | ### sharing/list_folders/continue ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_folders-continue)) 2089 | Once a cursor has been retrieved from :route:`list_folders`, use this to paginate through all shared folders. The cursor must come from a previous call to :route:`list_folders` or :route:`list_folders/continue`. 2090 | 2091 | ```js 2092 | dropbox({ 2093 | resource: 'sharing/list_folders/continue', 2094 | parameters: { 2095 | 'cursor': 'ZtkX9_EHj3x7PMkVuFIhwKYXEpwpLwyxp9vMKomUhllil9q7eWiAu' 2096 | } 2097 | }, (err, result, response) => { 2098 | //see docs for `result` parameters 2099 | }); 2100 | ``` 2101 | 2102 | 2103 | ### sharing/list_mountable_folders ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_mountable_folders)) 2104 | Return the list of all shared folders the current user can mount or unmount. 2105 | 2106 | ```js 2107 | dropbox({ 2108 | resource: 'sharing/list_mountable_folders', 2109 | parameters: { 2110 | 'limit': 100, 2111 | 'actions': [] 2112 | } 2113 | }, (err, result, response) => { 2114 | //see docs for `result` parameters 2115 | }); 2116 | ``` 2117 | 2118 | 2119 | ### sharing/list_mountable_folders/continue ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_mountable_folders-continue)) 2120 | Once a cursor has been retrieved from :route:`list_mountable_folders`, use this to paginate through all mountable shared folders. The cursor must come from a previous call to :route:`list_mountable_folders` or :route:`list_mountable_folders/continue`. 2121 | 2122 | ```js 2123 | dropbox({ 2124 | resource: 'sharing/list_mountable_folders/continue', 2125 | parameters: { 2126 | 'cursor': 'ZtkX9_EHj3x7PMkVuFIhwKYXEpwpLwyxp9vMKomUhllil9q7eWiAu' 2127 | } 2128 | }, (err, result, response) => { 2129 | //see docs for `result` parameters 2130 | }); 2131 | ``` 2132 | 2133 | 2134 | ### sharing/list_received_files ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_received_files)) 2135 | Returns a list of all files shared with current user. 2136 | Does not include files the user has received via shared folders, and does not include unclaimed invitations. 2137 | 2138 | ```js 2139 | dropbox({ 2140 | resource: 'sharing/list_received_files', 2141 | parameters: { 2142 | 'limit': 100, 2143 | 'actions': [] 2144 | } 2145 | }, (err, result, response) => { 2146 | //see docs for `result` parameters 2147 | }); 2148 | ``` 2149 | 2150 | 2151 | ### sharing/list_received_files/continue ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_received_files-continue)) 2152 | Get more results with a cursor from :route:`list_received_files`. 2153 | 2154 | ```js 2155 | dropbox({ 2156 | resource: 'sharing/list_received_files/continue', 2157 | parameters: { 2158 | 'cursor': 'AzJJbGlzdF90eXBdofe9c3RPbGlzdGFyZ3NfYnlfZ2lkMRhcbric7Rdog9emfGRlc2MCRWxpbWl0BGRId' 2159 | } 2160 | }, (err, result, response) => { 2161 | //see docs for `result` parameters 2162 | }); 2163 | ``` 2164 | 2165 | 2166 | ### sharing/list_shared_links ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_shared_links)) 2167 | List shared links of this user. 2168 | If no path is given, returns a list of all shared links for the current user. For members of business teams using team space and member folders, returns all shared links in the team member's home folder unless the team space ID is specified in the request header. For more information, refer to the :link:`Namespace Guide https://www.dropbox.com/developers/reference/namespace-guide`. 2169 | If a non-empty path is given, returns a list of all shared links that allow access to the given path - direct links to the given path and links to parent folders of the given path. Links to parent folders can be suppressed by setting direct_only to true. 2170 | 2171 | ```js 2172 | dropbox({ 2173 | resource: 'sharing/list_shared_links', 2174 | parameters: { 2175 | 'cursor': 'ZtkX9_EHj3x7PMkVuFIhwKYXEpwpLwyxp9vMKomUhllil9q7eWiAu' 2176 | } 2177 | }, (err, result, response) => { 2178 | //see docs for `result` parameters 2179 | }); 2180 | ``` 2181 | 2182 | 2183 | ### sharing/modify_shared_link_settings ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-modify_shared_link_settings)) 2184 | Modify the shared link's settings. 2185 | If the requested visibility conflict with the shared links policy of the team or the shared folder (in case the linked file is part of a shared folder) then the :field:`LinkPermissions.resolved_visibility` of the returned :type:`SharedLinkMetadata` will reflect the actual visibility of the shared link and the :field:`LinkPermissions.requested_visibility` will reflect the requested visibility. 2186 | 2187 | ```js 2188 | dropbox({ 2189 | resource: 'sharing/modify_shared_link_settings', 2190 | parameters: { 2191 | 'url': 'https://www.dropbox.com/s/2sn712vy1ovegw8/Prime_Numbers.txt?dl=0', 2192 | 'settings': { 2193 | 'audience': 'public', 2194 | 'access': 'viewer', 2195 | 'requested_visibility': 'public', 2196 | 'allow_download': true 2197 | }, 2198 | 'remove_expiration': false 2199 | } 2200 | }, (err, result, response) => { 2201 | //see docs for `result` parameters 2202 | }); 2203 | ``` 2204 | 2205 | 2206 | ### sharing/mount_folder ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-mount_folder)) 2207 | The current user mounts the designated folder. 2208 | Mount a shared folder for a user after they have been added as a member. Once mounted, the shared folder will appear in their Dropbox. 2209 | 2210 | ```js 2211 | dropbox({ 2212 | resource: 'sharing/mount_folder', 2213 | parameters: { 2214 | 'shared_folder_id': '84528192421' 2215 | } 2216 | }, (err, result, response) => { 2217 | //see docs for `result` parameters 2218 | }); 2219 | ``` 2220 | 2221 | 2222 | ### sharing/relinquish_file_membership ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-relinquish_file_membership)) 2223 | The current user relinquishes their membership in the designated file. Note that the current user may still have inherited access to this file through the parent folder. 2224 | 2225 | ```js 2226 | dropbox({ 2227 | resource: 'sharing/relinquish_file_membership', 2228 | parameters: { 2229 | 'file': 'id:3kmLmQFnf1AAAAAAAAAAAw' 2230 | } 2231 | }, (err, result, response) => { 2232 | //see docs for `result` parameters 2233 | }); 2234 | ``` 2235 | 2236 | 2237 | ### sharing/relinquish_folder_membership ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-relinquish_folder_membership)) 2238 | The current user relinquishes their membership in the designated shared folder and will no longer have access to the folder. A folder owner cannot relinquish membership in their own folder. 2239 | This will run synchronously if leave_a_copy is false, and asynchronously if leave_a_copy is true. 2240 | 2241 | ```js 2242 | dropbox({ 2243 | resource: 'sharing/relinquish_folder_membership', 2244 | parameters: { 2245 | 'shared_folder_id': '84528192421', 2246 | 'leave_a_copy': false 2247 | } 2248 | }, (err, result, response) => { 2249 | //see docs for `result` parameters 2250 | }); 2251 | ``` 2252 | 2253 | 2254 | ### sharing/remove_file_member_2 ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-remove_file_member_2)) 2255 | Removes a specified member from the file. 2256 | 2257 | ```js 2258 | dropbox({ 2259 | resource: 'sharing/remove_file_member_2', 2260 | parameters: { 2261 | 'file': 'id:3kmLmQFnf1AAAAAAAAAAAw', 2262 | 'member': { 2263 | '.tag': 'email', 2264 | 'email': 'justin@example.com' 2265 | } 2266 | } 2267 | }, (err, result, response) => { 2268 | //see docs for `result` parameters 2269 | }); 2270 | ``` 2271 | 2272 | 2273 | ### sharing/remove_folder_member ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-remove_folder_member)) 2274 | Allows an owner or editor (if the ACL update policy allows) of a shared folder to remove another member. 2275 | 2276 | ```js 2277 | dropbox({ 2278 | resource: 'sharing/remove_folder_member', 2279 | parameters: { 2280 | 'shared_folder_id': '84528192421', 2281 | 'member': { 2282 | '.tag': 'email', 2283 | 'email': 'justin@example.com' 2284 | }, 2285 | 'leave_a_copy': false 2286 | } 2287 | }, (err, result, response) => { 2288 | //see docs for `result` parameters 2289 | }); 2290 | ``` 2291 | 2292 | 2293 | ### sharing/revoke_shared_link ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-revoke_shared_link)) 2294 | Revoke a shared link. 2295 | Note that even after revoking a shared link to a file, the file may be accessible if there are shared links leading to any of the file parent folders. To list all shared links that enable access to a specific file, you can use the :route:`list_shared_links` with the file as the :field:`ListSharedLinksArg.path` argument. 2296 | 2297 | ```js 2298 | dropbox({ 2299 | resource: 'sharing/revoke_shared_link', 2300 | parameters: { 2301 | 'url': 'https://www.dropbox.com/s/2sn712vy1ovegw8/Prime_Numbers.txt?dl=0' 2302 | } 2303 | }, (err, result, response) => { 2304 | //see docs for `result` parameters 2305 | }); 2306 | ``` 2307 | 2308 | 2309 | ### sharing/set_access_inheritance ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-set_access_inheritance)) 2310 | Change the inheritance policy of an existing Shared Folder. Only permitted for shared folders in a shared team root. 2311 | If a :field:`ShareFolderLaunch.async_job_id` is returned, you'll need to call :route:`check_share_job_status` until the action completes to get the metadata for the folder. 2312 | 2313 | ```js 2314 | dropbox({ 2315 | resource: 'sharing/set_access_inheritance', 2316 | parameters: { 2317 | 'shared_folder_id': '84528192421', 2318 | 'access_inheritance': 'inherit' 2319 | } 2320 | }, (err, result, response) => { 2321 | //see docs for `result` parameters 2322 | }); 2323 | ``` 2324 | 2325 | 2326 | ### sharing/share_folder ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-share_folder)) 2327 | Share a folder with collaborators. 2328 | Most sharing will be completed synchronously. Large folders will be completed asynchronously. To make testing the async case repeatable, set `ShareFolderArg.force_async`. 2329 | If a :field:`ShareFolderLaunch.async_job_id` is returned, you'll need to call :route:`check_share_job_status` until the action completes to get the metadata for the folder. 2330 | 2331 | ```js 2332 | dropbox({ 2333 | resource: 'sharing/share_folder', 2334 | parameters: { 2335 | 'path': '/example/workspace', 2336 | 'acl_update_policy': 'editors', 2337 | 'force_async': false, 2338 | 'member_policy': 'team', 2339 | 'shared_link_policy': 'members', 2340 | 'access_inheritance': 'inherit' 2341 | } 2342 | }, (err, result, response) => { 2343 | //see docs for `result` parameters 2344 | }); 2345 | ``` 2346 | 2347 | 2348 | ### sharing/transfer_folder ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-transfer_folder)) 2349 | Transfer ownership of a shared folder to a member of the shared folder. 2350 | User must have :field:`AccessLevel.owner` access to the shared folder to perform a transfer. 2351 | 2352 | ```js 2353 | dropbox({ 2354 | resource: 'sharing/transfer_folder', 2355 | parameters: { 2356 | 'shared_folder_id': '84528192421', 2357 | 'to_dropbox_id': 'dbid:AAEufNrMPSPe0dMQijRP0N_aZtBJRm26W4Q' 2358 | } 2359 | }, (err, result, response) => { 2360 | //see docs for `result` parameters 2361 | }); 2362 | ``` 2363 | 2364 | 2365 | ### sharing/unmount_folder ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-unmount_folder)) 2366 | The current user unmounts the designated folder. They can re-mount the folder at a later time using :route:`mount_folder`. 2367 | 2368 | ```js 2369 | dropbox({ 2370 | resource: 'sharing/unmount_folder', 2371 | parameters: { 2372 | 'shared_folder_id': '84528192421' 2373 | } 2374 | }, (err, result, response) => { 2375 | //see docs for `result` parameters 2376 | }); 2377 | ``` 2378 | 2379 | 2380 | ### sharing/unshare_file ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-unshare_file)) 2381 | Remove all members from this file. Does not remove inherited members. 2382 | 2383 | ```js 2384 | dropbox({ 2385 | resource: 'sharing/unshare_file', 2386 | parameters: { 2387 | 'file': 'id:3kmLmQFnf1AAAAAAAAAAAw' 2388 | } 2389 | }, (err, result, response) => { 2390 | //see docs for `result` parameters 2391 | }); 2392 | ``` 2393 | 2394 | 2395 | ### sharing/unshare_folder ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-unshare_folder)) 2396 | Allows a shared folder owner to unshare the folder. 2397 | You'll need to call :route:`check_job_status` to determine if the action has completed successfully. 2398 | 2399 | ```js 2400 | dropbox({ 2401 | resource: 'sharing/unshare_folder', 2402 | parameters: { 2403 | 'shared_folder_id': '84528192421', 2404 | 'leave_a_copy': false 2405 | } 2406 | }, (err, result, response) => { 2407 | //see docs for `result` parameters 2408 | }); 2409 | ``` 2410 | 2411 | 2412 | ### sharing/update_file_member ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-update_file_member)) 2413 | Changes a member's access on a shared file. 2414 | 2415 | ```js 2416 | dropbox({ 2417 | resource: 'sharing/update_file_member', 2418 | parameters: { 2419 | 'file': 'id:3kmLmQFnf1AAAAAAAAAAAw', 2420 | 'member': { 2421 | '.tag': 'email', 2422 | 'email': 'justin@example.com' 2423 | }, 2424 | 'access_level': 'viewer' 2425 | } 2426 | }, (err, result, response) => { 2427 | //see docs for `result` parameters 2428 | }); 2429 | ``` 2430 | 2431 | 2432 | ### sharing/update_folder_member ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-update_folder_member)) 2433 | Allows an owner or editor of a shared folder to update another member's permissions. 2434 | 2435 | ```js 2436 | dropbox({ 2437 | resource: 'sharing/update_folder_member', 2438 | parameters: { 2439 | 'shared_folder_id': '84528192421', 2440 | 'member': { 2441 | '.tag': 'email', 2442 | 'email': 'justin@example.com' 2443 | }, 2444 | 'access_level': 'editor' 2445 | } 2446 | }, (err, result, response) => { 2447 | //see docs for `result` parameters 2448 | }); 2449 | ``` 2450 | 2451 | 2452 | ### sharing/update_folder_policy ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-update_folder_policy)) 2453 | Update the sharing policies for a shared folder. 2454 | User must have :field:`AccessLevel.owner` access to the shared folder to update its policies. 2455 | 2456 | ```js 2457 | dropbox({ 2458 | resource: 'sharing/update_folder_policy', 2459 | parameters: { 2460 | 'shared_folder_id': '84528192421', 2461 | 'member_policy': 'team', 2462 | 'acl_update_policy': 'owner', 2463 | 'shared_link_policy': 'members' 2464 | } 2465 | }, (err, result, response) => { 2466 | //see docs for `result` parameters 2467 | }); 2468 | ``` 2469 | 2470 | 2471 | ### sharing/create_shared_link ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-create_shared_link)) 2472 | Create a shared link. 2473 | If a shared link already exists for the given path, that link is returned. 2474 | Previously, it was technically possible to break a shared link by moving or renaming the corresponding file or folder. In the future, this will no longer be the case, so your app shouldn't rely on this behavior. Instead, if your app needs to revoke a shared link, use :route:`revoke_shared_link`. 2475 | 2476 | ```js 2477 | dropbox({ 2478 | resource: 'sharing/create_shared_link', 2479 | parameters: { 2480 | 'path': '/Homework/Math/Prime_Numbers.txt', 2481 | 'short_url': false 2482 | } 2483 | }, (err, result, response) => { 2484 | //see docs for `result` parameters 2485 | }); 2486 | ``` 2487 | 2488 | 2489 | ### sharing/get_shared_links ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_links)) 2490 | Returns a list of :type:`LinkMetadata` objects for this user, including collection links. 2491 | If no path is given, returns a list of all shared links for the current user, including collection links, up to a maximum of 1000 links. 2492 | If a non-empty path is given, returns a list of all shared links that allow access to the given path. Collection links are never returned in this case. 2493 | 2494 | ```js 2495 | dropbox({ 2496 | resource: 'sharing/get_shared_links', 2497 | parameters: { 2498 | 'path': '' 2499 | } 2500 | }, (err, result, response) => { 2501 | //see docs for `result` parameters 2502 | }); 2503 | ``` 2504 | 2505 | 2506 | ### sharing/remove_file_member ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#sharing-remove_file_member)) 2507 | Identical to remove_file_member_2 but with less information returned. 2508 | 2509 | ```js 2510 | dropbox({ 2511 | resource: 'sharing/remove_file_member', 2512 | parameters: { 2513 | 'file': 'id:3kmLmQFnf1AAAAAAAAAAAw', 2514 | 'member': { 2515 | '.tag': 'email', 2516 | 'email': 'justin@example.com' 2517 | } 2518 | } 2519 | }, (err, result, response) => { 2520 | //see docs for `result` parameters 2521 | }); 2522 | ``` 2523 | 2524 | 2525 | ### users/features/get_values ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#users-features-get_values)) 2526 | Get a list of feature values that may be configured for the current account. 2527 | 2528 | ```js 2529 | dropbox({ 2530 | resource: 'users/features/get_values', 2531 | parameters: { 2532 | 'features': [{ 2533 | '.tag': 'paper_as_files' 2534 | }, { 2535 | '.tag': 'file_locking' 2536 | }] 2537 | } 2538 | }, (err, result, response) => { 2539 | //see docs for `result` parameters 2540 | }); 2541 | ``` 2542 | 2543 | 2544 | ### users/get_account ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#users-get_account)) 2545 | Get information about a user's account. 2546 | 2547 | ```js 2548 | dropbox({ 2549 | resource: 'users/get_account', 2550 | parameters: { 2551 | 'account_id': 'dbid:AAH4f99T0taONIb-OurWxbNQ6ywGRopQngc' 2552 | } 2553 | }, (err, result, response) => { 2554 | //see docs for `result` parameters 2555 | }); 2556 | ``` 2557 | 2558 | 2559 | ### users/get_account_batch ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#users-get_account_batch)) 2560 | Get information about multiple user accounts. At most 300 accounts may be queried per request. 2561 | 2562 | ```js 2563 | dropbox({ 2564 | resource: 'users/get_account_batch', 2565 | parameters: { 2566 | 'account_ids': ['dbid:AAH4f99T0taONIb-OurWxbNQ6ywGRopQngc', 'dbid:AAH1Vcz-DVoRDeixtr_OA8oUGgiqhs4XPOQ'] 2567 | } 2568 | }, (err, result, response) => { 2569 | //see docs for `result` parameters 2570 | }); 2571 | ``` 2572 | 2573 | 2574 | ### users/get_current_account ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#users-get_current_account)) 2575 | Get information about the current user's account. 2576 | 2577 | ```js 2578 | dropbox({ 2579 | resource: 'users/get_current_account' 2580 | }, (err, result, response) => { 2581 | //see docs for `result` parameters 2582 | }); 2583 | ``` 2584 | 2585 | 2586 | ### users/get_space_usage ([see docs](https://www.dropbox.com/developers/documentation/http/documentation#users-get_space_usage)) 2587 | Get the space usage information for the current user's account. 2588 | 2589 | ```js 2590 | dropbox({ 2591 | resource: 'users/get_space_usage' 2592 | }, (err, result, response) => { 2593 | //see docs for `result` parameters 2594 | }); 2595 | ``` 2596 | --------------------------------------------------------------------------------