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.

npm install dropbox-v2-api
INSTALL
IMPORT
SIG · DROPBOX-V2-API
D
dropbox-v2-api
http-networkingjavascriptv2.5.12
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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.

dropboxV2Api
const dropboxV2Api = require('dropbox-v2-api');
import dropboxV2Api from 'dropbox-v2-api';
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.
authenticate
const dropbox = dropboxV2Api.authenticate({ token: 'YOUR_TOKEN' });
const dropbox = require('dropbox-v2-api').authenticate(...);
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.
API Call Function
dropbox({ resource: 'users/get_current_account', parameters: {} }, callback);
dropboxV2Api.users.getCurrentAccount({}, callback);
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.

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 issues
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.
fix
Refer to the official Dropbox API documentation or the library's `api.json` for the most accurate resource names and parameters, especially after any library updates.
affects: >=1.0.0
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.
fix
Ensure all API calls and concepts align with Dropbox API v2 documentation. Migrate any legacy v1 codebases to v2 before using this library.
affects: >=1.0.0
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.
fix
Verify that your access token is current and has the necessary scopes. Implement refresh token logic for long-lived access if using OAuth2, by calling `dropbox.refreshToken()` with the stored `refresh_token`.
affects: >=1.0.0
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.
fix
Always provide a `fs.createReadStream()` or similar readable stream for upload resources. For downloads, ensure you pipe the returned stream to a writable destination, e.g., `fs.createWriteStream()`.
affects: >=1.0.0
Errors
Common errors & fixes
Error: request to https://api.dropboxapi.com/2/users/get_current_account failed, reason: self signed certificate in certificate chain
Often occurs in corporate network environments with SSL inspection or proxy servers that use self-signed certificates, which Node.js's default CA store does not trust.
fix
Set `NODE_TLS_REJECT_UNAUTHORIZED='0'` (NOT recommended for production) or configure Node.js to trust the custom CA certificate by setting the `NODE_EXTRA_CA_CERTS` environment variable.
Error: { error_summary: 'invalid_access_token/...' }
The provided access token is either invalid, expired, or does not have the necessary permissions (scopes) for the requested operation.
fix
Obtain a new access token, verify its validity, and ensure it has all the required Dropbox API scopes (e.g., `files.content.read`, `files.content.write`, `account_info.read`) for the endpoints you are calling.
Error: { error_summary: 'path/restricted_content/...' }
The specified file path is invalid, refers to a non-existent file/folder, or violates Dropbox's path restrictions (e.g., invalid characters, exceeding length limits).
fix
Double-check the `path` parameter in your API call. Ensure the path exists and is correctly formatted according to Dropbox's path rules. Verify that the application has permissions to access that specific path.
TypeError: dropbox is not a function
You are likely attempting to call `dropboxV2Api` directly instead of the function returned by `dropboxV2Api.authenticate()`.
fix
Ensure you first call `const dropbox = dropboxV2Api.authenticate({ token: '...' });` and then use the `dropbox` constant as the function to make API requests.
Upgrade
Version history
2.5.12latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
40 hits · last 30 days
node
36
Amazon
1
OpenAI (training)
1
Resources
dropbox-v2-api — npm install dropbox-v2-api · libregistry