Registry / http-networking / dropbox-v2-api

dropbox-v2-api

JSON →
library2.5.12jsnpmunverified

This package provides a programmatically generated wrapper for the Dropbox V2 API, specifically designed for Node.js environments. It aims to keep the API surface up-to-date by automatically generating PRs when the official Dropbox endpoint descriptions change. Currently at version 2.5.12, it follows a continuous update model for its API generation, ensuring parity with the Dropbox API. Key differentiators include full support for Node.js streams for efficient file uploads and downloads, direct support for the Dropbox Paper API, and a simple, direct mapping of official Dropbox API resource names. It avoids custom function names, instead relying on a structured object for resource and parameter definitions. The package supports both token-based authentication and the full OAuth2 flow, including refresh token management for offline access. It is primarily consumed as a CommonJS module.

http-networkingcommunicationauth-security
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

The library primarily uses CommonJS `require()` syntax. Direct ESM `import` is not officially supported without a transpilation step or specific `type: module` configuration in consuming applications. The main export is an object containing the `authenticate` method.

const dropboxV2Api = require('dropbox-v2-api');

The `authenticate` method is accessed via the `dropboxV2Api` object. It returns a function (`dropbox`) that is then used to make API calls. Do not try to destructure `authenticate` directly from the `require` call unless you are certain of the module's export structure.

const dropbox = dropboxV2Api.authenticate({ token: 'YOUR_TOKEN' });

After authentication, the returned `dropbox` function is the primary interface for all API calls. It takes a single configuration object with `resource` (string) and `parameters` (object) fields, following the official Dropbox API endpoint naming conventions.

dropbox({ resource: 'users/get_current_account', parameters: {} }, callback);

This example demonstrates authenticating with a Dropbox token, fetching current account details, and uploading a local file to Dropbox using Node.js streams. It highlights the basic API call structure.

const dropboxV2Api = require('dropbox-v2-api'); const fs = require('fs'); // Replace with your actual Dropbox access token and desired path const DROPBOX_ACCESS_TOKEN = process.env.DROPBOX_TOKEN ?? 'YOUR_DROPBOX_TOKEN'; const DROPBOX_UPLOAD_PATH = '/my-uploaded-file.txt'; const LOCAL_FILE_PATH = 'local-file.txt'; // Create a dummy local file for upload example fs.writeFileSync(LOCAL_FILE_PATH, 'Hello from dropbox-v2-api!\nThis is a test upload.'); const dropbox = dropboxV2Api.authenticate({ token: DROPBOX_ACCESS_TOKEN }); console.log('Listing current account details...'); dropbox({ resource: 'users/get_current_account', parameters: {} }, (err, result, response) => { if (err) { console.error('Error getting account details:', err); return; } console.log('Account Details:', result); console.log(`Attempting to upload '${LOCAL_FILE_PATH}' to '${DROPBOX_UPLOAD_PATH}'...`); dropbox({ resource: 'files/upload', parameters: { path: DROPBOX_UPLOAD_PATH, mode: 'overwrite' }, readStream: fs.createReadStream(LOCAL_FILE_PATH) }, (uploadErr, uploadResult, uploadResponse) => { if (uploadErr) { console.error('Error uploading file:', uploadErr); return; } console.log('File uploaded successfully:', uploadResult); // Clean up the local dummy file fs.unlinkSync(LOCAL_FILE_PATH); console.log(`Cleaned up local file: ${LOCAL_FILE_PATH}`); }); });
Debug
Known footguns
gotchaThe API resource names and parameter structures are dynamically generated from the official Dropbox API specification. While this ensures currency, minor updates to the underlying Dropbox API could subtly change expected `resource` string values or `parameters` object fields without a major version bump in `dropbox-v2-api`, requiring code adjustments.
breakingOlder versions of the Dropbox API (v1) are not supported. This library is strictly for Dropbox API v2. Attempting to use v1 concepts or endpoints will result in errors.
gotchaIncorrect or expired access tokens will result in `AuthError` responses from the Dropbox API, typically indicating a 401 Unauthorized status. Refresh tokens are only available for `token_access_type: 'offline'` during the OAuth2 flow.
gotchaFor upload and download operations, this library heavily leverages Node.js streams. Mismanaging stream piping or not providing a `readStream` for upload-type resources (e.g., `files/upload`) will lead to errors or hung connections.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
13 hits · last 30 days
gptbot
4
ahrefsbot
3
script
1
Resources