一个 JavaScript 接口,用于与 Box API 进行交互。您可以在以下网站找到该节点包:
We are excited to introduce the v10 major release of the Box Node SDK, designed to elevate the developer experience and streamline your integration with the Box Content Cloud.
With this SDK version, you’ll have access to:
Embrace the new generation of Box SDKs and unlock the full potential of the Box Content Cloud.
To enhance developer experience, we have introduced the new generated codebase through the sdk-gen module.
The sdk-gen module is available in two major supported versions: v4 and v10.
In v4 of the Box Node SDK, we are introducing a version that consolidates both the manually written package (legacy SDK) and the generated SDK (currently in v10, formerly known as box-typescript-sdk-gen) into a single SDK package for improved usability and maintenance. This allows developers to use both modules within a single project.
The codebase for v4 of the Box Node SDK is currently available in the combined-sdk branch. Migration guide for migrating from manually written SDK to generated SDK can be found here.
Version v4 is intended for:
sdk-gen module, but do not want to move all their code to the new module immediately.Starting from v10, the SDK is built entirely on the generated sdk-gen module, which fully and exclusively replaces the old boxsdk module.
The codebase for v10 of the Box Node SDK is currently available in the main branch.
Version v10 is intended for:
| Scenario | Recommended Version | Example Dependency |
|---|---|---|
| Creating a new application | Use v10 | npm install box-node-sdk@10 |
| Existing app using box-typescript-sdk-gen artifact | Migrate to v10 | npm install box-node-sdk@10 |
| Existing app using both box-typescript-sdk-gen and box-node-sdk | Upgrade to v4 | npm install box-node-sdk@^4 |
| Existing app using v3 of box-node-sdk artifact | Upgrade to v4 | npm install box-node-sdk@^4 |
For full guidance on SDK versioning, see the Box SDK Versioning Guide.
If you are using npm:
npm install box-node-sdk@If you use yarn, please do this instead:
yarn add box-node-sdk@Warning: The npm
latesttag currently resolves to the legacy v4 line, not the current generated v10 SDK. Runningnpm install box-node-sdkoryarn add box-node-sdkwithout a version pin silently installs the hand-written v4 package, whose API differs significantly from v10. Always pin the major version explicitly — for examplebox-node-sdk@^10for new applications, orbox-node-sdk@^4if you still need the combined v4 package.
The next generation of the SDK starts with version 10.0.0. See Which Version Should I Use? to choose the right major version.
To get started with the SDK, get a Developer Token from the Configuration page of your app in the Box Developer Console. You can use this token to make test calls for your own Box account.
The SDK provides an DeveloperTokenAuth class, which allows you to authenticate using your Developer Token.
Use instance of DeveloperTokenAuth to initialize Client object.
Using Client object you can access managers, which allow you to perform some operations on your Box account.
The example below demonstrates how to authenticate with Developer Token and print names of all items inside a root folder.
const { BoxClient, BoxDeveloperTokenAuth } = require('box-node-sdk');
async function main(token) {
let auth = new BoxDeveloperTokenAuth({ token });
let client = new BoxClient({ auth });
let entries = (await client.folders.getFolderItems('0')).entries;
entries.forEach((entry) => console.log(entry));
}
main('INSERT YOUR DEVELOPER TOKEN HERE');In order to use in browser make sure you include the lib/bundle.js file and then you can access the classes like so:
const { BoxClient, BoxDeveloperTokenAuth } = window['box-node-sdk'];See example.html for an example website using this SDK.
To run the example locally:
npx serve -p 3000 in the project directory.http://localhost:3000 is allowlisted in CORS Domains of your application.http://localhost:3000/example.html.Box Node SDK v10 supports multiple authentication methods including Developer Token, OAuth 2.0, Client Credentials Grant, and JSON Web Token (JWT).
You can find detailed instructions and example code for each authentication method in Authentication document.
Browse the docs or see API Reference for more information.
Migration guides which help you to migrate to supported major SDK versions can be found here.
This SDK works in modern browsers that support ES6+ features. It seamlessly integrates with frontend frameworks like ReactJS, Angular, and NextJS. Check out our example below:
We use a modified version of Semantic Versioning for all changes. See version strategy for details which is effective from 30 July 2022.
Currently, we support versions v10 and v4 of the SDK. New features and functionality are added to v10, while the manually written portion of v4 receives bug fixes and security updates only.
A current release is on the leading edge of our SDK development, and is intended for customers who are in active development and want the latest and greatest features.
We always recommend that all users run the latest available minor release for whatever major version is in use. We highly recommend upgrading to the latest SDK major release at the earliest convenient time and before the EOL date.
| Version | Supported Environments | State | First Release | EOL/Terminated |
|---|---|---|---|---|
| 10 | Node.js >= 18 | Supported | 17 Sep 2025 | TBD |
| 4 | Node.js >= 18 | Supported | 23 Oct 2025 | TBD |
| 3 | Node.js >= 14 and = 8 and <= 14 | EOL | 29 Sep 2021 | 23 Jul 2023 |
| 1 | EOL | 28 Mar 2019 | 29 Sep 2021 |
For information on how to contribute to this project, please see the Contribution guidelines.
The Box Node SDK allows the use of FIPS 140-2 validated SSL libraries, such as OpenSSL 3.0. However, some actions are required to enable this functionality.
By default, the version of OpenSSL Node.js includes is not FIPS enabled. Therefore, if you want to use OpenSSL 3.0 with FIPS, you need to build OpenSSL 3.0 with FIPS enabled and then build Node.js use the shared OpenSSL 3.0 library.
According to Node.js OpenSSL Strategy document, you can use the OpenSSL 3.0 from Node.js v16 or later.
Need to contact us directly? Browse the issues tickets! Or, if that doesn't work, file a new one and we will get back to you. If you have general questions about the Box API, you can post to the Box Developer Forum.
Copyright 2025 Box, Inc. All rights reserve
暂无开放 Issues,或尚未同步最近议题。