Box Python SDK
The `boxsdk` is the official Python SDK for integrating with the Box Content Cloud. The latest major versions (v10.x.x and above) are built entirely on an auto-generated package, `box_sdk_gen`, providing comprehensive API support and rapid updates. It supports Python 3.8 and above, with a release cadence of minor or patch releases every 2-3 months.
Warnings
- breaking Version 10.0.0 of `boxsdk` entirely replaces the old, manually maintained `boxsdk` package with the auto-generated `box_sdk_gen`. This introduces a new interface for all methods and requires changes to import paths (e.g., `from box_sdk_gen import ...` instead of `from boxsdk import ...`) and potentially client/auth object instantiation.
- deprecated Box Next Generation SDKs, which were developed in parallel, are deprecated as of September 17, 2025. While existing code will continue to function, these separate artifacts will no longer receive new features, updates, or bug fixes. Their functionalities are now integrated into the consolidated Box core SDKs (v4.x.y and v10.x.y).
- gotcha Common authentication issues (e.g., 'Access denied - insufficient permission', 'No "refresh_token" parameter found', 'The "box_subject_type" value is unauthorized') often stem from misconfiguration in the Box Developer Console or not meeting prerequisites for specific authentication methods (e.g., administrator approval for Client Credentials Grant).
- gotcha Achieving FIPS 140-2 compliance when using the SDK, especially with JWT, requires specific setup. Python's default distributions often link against OpenSSL v1.1.1 (not FIPS compliant). You must ensure Python uses a custom SSL library (like OpenSSL 3.0) and that the `cryptography` library (a JWT dependency) is also installed with a FIPS-compliant OpenSSL version.
- gotcha Box SDK uses a modified Semantic Versioning. While `PATCH` releases are generally safe, `MINOR` versions can introduce small breaking changes, primarily to function signatures. `MAJOR` versions denote significant, potentially extensive breaking changes.
Install
-
pip install boxsdk>=10 -
pip install "boxsdk[jwt]>=10"
Imports
- BoxClient, BoxDeveloperTokenAuth
from box_sdk_gen import BoxClient, BoxDeveloperTokenAuth
Quickstart
import os
from box_sdk_gen import BoxClient, BoxDeveloperTokenAuth
# Get your Developer Token from the Box Developer Console for testing.
# It's recommended to use environment variables for sensitive information.
DEVELOPER_TOKEN = os.environ.get('BOX_DEVELOPER_TOKEN', 'YOUR_DEVELOPER_TOKEN')
def get_root_folder_items(token: str):
if not token or token == 'YOUR_DEVELOPER_TOKEN':
print("Please set the 'BOX_DEVELOPER_TOKEN' environment variable or replace 'YOUR_DEVELOPER_TOKEN' in the script.")
return
try:
auth: BoxDeveloperTokenAuth = BoxDeveloperTokenAuth(token=token)
client: BoxClient = BoxClient(auth=auth)
# Get items in the root folder (folder ID '0')
print("\nItems in your Box root folder:")
for item in client.folders.get_folder_items('0').entries:
print(f"- {item.name} ({item.type.value})")
except Exception as e:
print(f"An error occurred: {e}")
if __name__ == '__main__':
get_root_folder_items(DEVELOPER_TOKEN)